ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
49.69k stars 16.11k forks source link

Unable to use deepsarse #11528

Closed Vikram12301 closed 1 year ago

Vikram12301 commented 1 year ago

Search before asking

Question

On running the code from the documentation of deepsparse:

sparseml.yolov5.train \
  --data VOC.yaml \
  --cfg models_v5.0/yolov5s.yaml \
  --weights zoo:cv/detection/yolov5-s/pytorch/ultralytics/coco/pruned_quant-aggressive_94?recipe_type=transfer \
  --hyp data/hyps/hyp.finetune.yaml \
  --recipe zoo:cv/detection/yolov5-s/pytorch/ultralytics/coco/pruned-aggressive_96

I am getting the following error:

TypeError: Unable to convert function return value to a Python type! The signature was () -> handle

Also, I have the best.pt with me of my custom data and custom.yaml file of my dataset, Can you please provide a small reproducible code to convert this using deepsparse to improve the performance of the mode?

Additional

No response

glenn-jocher commented 1 year ago

@Vikram12301 hello,

It seems that the error you are getting could be related to an incompatibility between the version of PyTorch and CUDA being used. Can you please confirm the versions of PyTorch and CUDA that you are running?

Regarding your additional question, you can use DeepSparse to sparsify your custom YOLOv5 model. You can load your custom configuration file, dataset and trained weights by modifying the commands mentioned in the documentation as per your custom files' paths.

Let me know if this helps.

Vikram12301 commented 1 year ago

I am using google colab and used the below code to install the required libraries

!pip install deepsparse[server] sparseml[torch,torchvision]

And in the second question, would the below work? sparseml.yolov5.train \ --data custom.yaml \ --cfg models_v5.0/yolov5s.yaml \ --weights best.pt \ --hyp data/hyps/hyp.finetune.yaml \ --recipe zoo:cv/detection/yolov5-s/pytorch/ultralytics/coco/pruned-aggressive_96

glenn-jocher commented 1 year ago

@Vikram12301 hello,

Regarding your first question, it seems that the error you are getting could be related to an incompatibility between the version of PyTorch and CUDA being used. Can you please confirm the versions of PyTorch and CUDA that you are running?

For your second question, yes, you can use the command you have mentioned to sparsify your custom YOLOv5 model with DeepSparse. Make sure to specify the correct paths for your custom configuration file, dataset, and trained weights.

Let us know if you face any other issues.

Thanks.

Vikram12301 commented 1 year ago

torch - Version: 1.12.0

CUDA: Cuda compilation tools, release 11.8, V11.8.89 Build cuda_11.8.r11.8/compiler.31833905_0

Vikram12301 commented 1 year ago

@glenn-jocher What are the correct versions?

glenn-jocher commented 1 year ago

@Vikram12301 hey there. I'm not sure exactly as I'm not a DeepSparse expert, but I think if you raise this issue on the DeepSpare repo they might be able to provide some help there! The repo is here: https://github.com/neuralmagic/deepsparse

mgoin commented 1 year ago

Hi @Vikram12301 this error happens because Tensorboard tries to incorrectly load Tensorflow while we are using PyTorch. Please remove Tensorflow to get past the error: pip uninstall -y tensorflow

glenn-jocher commented 1 year ago

Hello @mgoin,

As mentioned in the previous comment, this error can occur because of Tensorboard's attempt to load Tensorflow while PyTorch is being used. Removing Tensorflow should resolve the issue. You can proceed with the following command to uninstall Tensorflow: pip uninstall -y tensorflow.

Hope this helps! Let me know if you need any further assistance.