Comments (2)
Hi all and thank you for your amazing work!
I managed easily to use your yolov8 example in order to train and prune it and it works like a charm, managed to load it for inference after and I gain 2 time speed-up.
Nevertheless, I need to upgrade to latest ultralytics version. For that I modify some import : from ultralytics.engine.trainer import BaseTrainer from ultralytics.utils import yaml_load, LOGGER, RANK, DEFAULT_CFG_DICT, DEFAULT_CFG_KEYS from ultralytics.utils.checks import check_yaml from ultralytics.utils.torch_utils import initialize_weights, de_parallel
instead of : from ultralytics.yolo.engine.model import TASK_MAP from ultralytics.yolo.engine.trainer import BaseTrainer from ultralytics.yolo.utils import yaml_load, LOGGER, RANK, DEFAULT_CFG_DICT, DEFAULT_CFG_KEYS from ultralytics.yolo.utils.checks import check_yaml from ultralytics.yolo.utils.torch_utils import initialize_weights, de_parallel
and I modify TASK_MAP[self.task][1] to self.task_map[self.task]['trainer'] .
Seems to work at the beginning but at step 1 finetune I got the following error:
Traceback (most recent call last): File "yolov8_pruning_ultralytics_update_light.py", line 406, in prune(args) File "yolov8_pruning_ultralytics_update_light.py", line 367, in prune model.train_v2(pruning=True, **pruning_cfg) File "yolov8_pruning_ultralytics_update_light.py", line 272, in train_v2 self.trainer.train() File "/home/ngolo/anaconda3/envs/torch-pruning/lib/python3.8/site-packages/ultralytics/engine/trainer.py", line 198, in train self._do_train(world_size) File "/home/ngolo/anaconda3/envs/torch-pruning/lib/python3.8/site-packages/ultralytics/engine/trainer.py", line 370, in _do_train self.loss, self.loss_items = self.model(batch) File "/home/ngolo/anaconda3/envs/torch-pruning/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "/home/ngolo/anaconda3/envs/torch-pruning/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl return forward_call(*args, **kwargs) File "/home/ngolo/anaconda3/envs/torch-pruning/lib/python3.8/site-packages/ultralytics/nn/tasks.py", line 88, in forward return self.loss(x, args, **kwargs) File "/home/ngolo/anaconda3/envs/torch-pruning/lib/python3.8/site-packages/ultralytics/nn/tasks.py", line 267, in loss return self.criterion(preds, batch) File "/home/ngolo/anaconda3/envs/torch-pruning/lib/python3.8/site-packages/ultralytics/utils/loss.py", line 219, in call pred_bboxes = self.bbox_decode(anchor_points, pred_distri) # xyxy, (b, h_w, 4) File "/home/ngolo/anaconda3/envs/torch-pruning/lib/python3.8/site-packages/ultralytics/utils/loss.py", line 191, in bbox_decode pred_dist = pred_dist.view(b, a, 4, c // 4).softmax(3).matmul(self.proj.type(pred_dist.dtype)) RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument mat in method wrapper_CUDA_addmv)
Is anyone managed to use latest YOLOV8 (ultralytics) version or have any clue on how can I fix it ?
In advance, thanks.
Where you able to fix it? I am also trying but get a different error instead
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[18], line 1
----> 1 prune(args)
Cell In[6], line 334, in prune(args)
332 pruning_cfg['name'] = f\"step_{i}_finetune\"
333 pruning_cfg['batch'] = batch_size # restore batch size
--> 334 model.train_v2(pruning=True, **pruning_cfg)
336 # post fine-tuning validation
337 pruning_cfg['name'] = f\"step_{i}_post_val\"
Cell In[6], line 243, in train_v2(self, pruning, **kwargs)
240 self.trainer.final_eval = final_eval_v2.__get__(self.trainer)
242 self.trainer.hub_session = self.session # attach optional HUB session
--> 243 self.trainer.train()
244 # Update model and cfg after training
245 if RANK in (-1, 0):
TypeError: BaseTrainer.train() missing 1 required positional argument: 'self'"
I then tried with self.train()
instead and it seems ok but now I get to an AttrbuteError on DetectionTrainer
from torch-pruning.
@CloudRider-pixel could u share your entire code
from torch-pruning.
Related Issues (20)
- Isomorphic pruning integration into Torch-pruning HOT 2
- This is a great project. Can you provide example code on how to predict images after pruning is completed. I made an error while making the prediction:"AttributeError: Can't get attribute 'C2f_v2' on <module '__main__'" HOT 1
- Simple example for pruning LSTM model
- 我使用代码中的剪枝方法对vgg16进行剪枝,程序运行到pruner.step()的时候运行很长时间都不出结果,好像是卡在这里了。请问这是什么情况?
- How to use tp.pruner.MetaPruner with models that have hidden parameter in forward method?
- the new version yolov5,yolov7 didn't work HOT 3
- Training the model causes the issue.
- Metapruner can not work with ViTForImageClassification HOT 3
- MetaPruner can not work with ViTForImageClassification when setting iterative_steps=5 or larger steps HOT 2
- IndexError: index 1536 is out of bounds for dimension 0 with size 1024 HOT 1
- deformable convolution HOT 2
- yolov8在剪枝后finetune模型时,如果设置多卡会报错,Expected all tensors to be on the same device, but found at least two devices, cuda:2 and cuda:0!
- 当我在尝试剪枝YOLOV9时,DG.get_all_groups构建的group中Concat的通道索引不正确 HOT 3
- Why the pruning does not occur (params & flops do not change) HOT 1
- Sudden model size increase for high pruning ratios
- 关于本项目中给的YOLO系列的剪枝训练过程的疑问?
- YOLOv5剪枝后推理无结果
- PixelShuffle
- Is torch-pruning compatible with Detectron2?
- How to record the mapping relationship between remaining channels and the origin channels?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from torch-pruning.