Git Product home page Git Product logo

Comments (2)

eduardz1 avatar eduardz1 commented on September 23, 2024

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.

ajithvcoder avatar ajithvcoder commented on September 23, 2024

@CloudRider-pixel could u share your entire code

from torch-pruning.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.