qanastek / HugsVision

HugsVision is a easy to use huggingface wrapper for state-of-the-art computer vision
https://pypi.org/project/hugsvision/
MIT License
195 stars 21 forks source link

Add to device here #27

Closed zihaoz96 closed 2 years ago

zihaoz96 commented 2 years ago

https://github.com/qanastek/HugsVision/blob/d93cdd15da6fc9fe7f3053ca6e6d4196ef758327/hugsvision/inference/TorchVisionClassifierInference.py#L46

qanastek commented 2 years ago

RuntimeError: module must have its parameters and buffers on device cuda:0 (device_ids[0]) but found one of them on device: cpu

qanastek commented 2 years ago

The issue is related to the DataParallel layer at the end of the initialization block for the TorchVision models. Thus, we need to remove the layer to make it working on CPU devices.

Note: Will be merged in the version 0.72

Code edited:

Sources:

qanastek commented 2 years ago

Close with the push: 8529361