sparseml: `ModuleNotFoundError: No module named 'ultralytics.nn.modules.conv'; 'ultralytics.nn.modules' is not a package`
Describe the bug
So, I’m trying to train a YOLOv8 Model using sparseml.ultralytics.train, I’ve tried and tested both sparseml-nightly[ultralytics] and sparseml[ultralytics] and both of them are giving me the same error on Google Colab. When I upgraded to the latest ultralytics version, it worked fine when training using ultralytics but it breaks the sparseml training. I’ve tried multiple work arounds including removing all of the version checks but so far that too has failed, I believe that there are two refrences to this bug on Ultraytics GitHub Page dating only 2 weeks back.
Command I’m using:
!sparseml.ultralytics.train \
--model "./best.pt" \
--recipe zoo:cv/detection/yolov8-m/pytorch/ultralytics/coco/pruned75-none.yaml \
--data "./Torus-Segmentation-2/data.yaml" \
--batch 8 \
--patience 0
Expected behavior
Should train a without Giving an Error.
Environment Include all relevant environment information:
- Google Colab Notebook To Reproduce Exact steps to reproduce the behavior:
!pip install sparseml[ultralytics]
!sparseml.ultralytics.train \
--model "./best.pt" \
--recipe zoo:cv/detection/yolov8-m/pytorch/ultralytics/coco/pruned75-none.yaml \
--data "./Torus-Segmentation-2/data.yaml" \
--batch 8 \
--patience 0
This error is happening in the sparseml[ultralytics]==1.5, the latest PyPI release as of now.
Full Traceback
File "/usr/local/bin/sparseml.ultralytics.train", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/sparseml/yolov8/train.py", line 224, in main
model = SparseYOLO(kwargs["model"])
File "/usr/local/lib/python3.10/dist-packages/sparseml/yolov8/trainers.py", line 548, in __init__
ckpt = torch.load(model_str)
File "/usr/local/lib/python3.10/dist-packages/torch/serialization.py", line 789, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "/usr/local/lib/python3.10/dist-packages/torch/serialization.py", line 1131, in _load
result = unpickler.load()
File "/usr/local/lib/python3.10/dist-packages/torch/serialization.py", line 1124, in find_class
return super().find_class(mod_name, name)
ModuleNotFoundError: No module named 'ultralytics.nn.modules.conv'; 'ultralytics.nn.modules' is not a package
Additional context Add any other context about the problem here. Also include any relevant files.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 23 (10 by maintainers)
We have decided with the team, that this is high time we upgraded our
ultralyticsdependency. The overarching goal is to support more yolo tasks, but as a by-product, we should also solve the incompatibility problems, such as the one discussed in this issue.So I’d ask you to be patient, we already have the appropriate work planned into our immediate roadmap.
I will not close this issue for now, let’s do it once all the aforementioned problems go away.
@salwaghanim I faced the same error when I tried to train using
ultralyticsmodule without using sparseml. But when you dopip install --upgrade ultralyticsthen it will fix the issue inultralyticsbut since the latest version isn’t compatible w/ sparseml it’s not going to work even if you remove all of the version checks.@dbogunowicz Hello thanks for your hard work. the earlier issue reported was fixed, however another error occured, this error apeared earlier too in other models, and I never managed to solve it. I tried to prune a custom trained model however it failed in the process of quantization (I think) here is the procedure and the results:
Im using google collab for this process.
!pip list | grep sparsemloutput sparseml-nightly 1.6.0.20230720%cd /content/drive/MyDrive/projects/yolov8output
@kopyl I encourage you to install the current nightly version of the deepsparse. We have updated our support for ultralytics. This should make your error go away!
@kopyl We’re working on integrating the
ultralyticsupdate and its release is pending passing all our internal testing. Thanks@dbogunowicz I noticed that you released sparseml 1.5.1 I tested the model on google collab and still got the same error here is the installation procedure and
output message
@dbogunowicz Hello this is a detailed procedure.
pip install ultralyticsa. Note: make sure that you have installed cuda and its drivers before installing ultralytics.Facing same issue here, I have tested it on both collab and on my local machine. I have tried to remove sparseml and tested on
sparseml-nightly 1.6.0.20230608