mats-robotics / yolov5_ros

A complete ROS interface for running YOLOv5 inference
GNU General Public License v3.0
220 stars 64 forks source link

AssertionError: Invalid CUDA '--device 0' requested, use '--device cpu' or pass valid CUDA device(s) #9

Closed TDVL closed 2 years ago

TDVL commented 2 years ago

Hello, I have installed your repository on Ubuntu 20.04+ROS Noetic VM on VirtualBox. The installation was successful, catkin_make was use used for build, without error. I have copied my best.pt weights in the specified folder and I have changed the weights name in the launch file, according to your instructions. After I launched the package. An AssertionError was reported. something related to CUDA. All processes died. AssertionError: Invalid CUDA '--device 0' requested, use '--device cpu' or pass valid CUDA device(s) What could be the problem, please, will you check it and help me? Also, is it possible to test your yolov5 on *.jpg image? Since I need to test it on images, is it possible? If not, how can I use a video file for testing? Later, if it works well, everything will be installed on desktop computer with appropriate hardware. The screenshot about the error is attached. Thank you in advance. Best regards Screenshot from 2022-09-02 17-25-28

nhatleminh1997 commented 2 years ago

Hi,

My best guess for your CUDA-related error is that your virtual machine (either VMware/VirtualBox) don't provide GPU passthrough but a virtual GPU (vGPU) instead which cannot access CUDA functionalities and therefore is not helpful to run deep learning stuff.

I don't think there is a way to get around this with VMs and suggest you install Ubuntu dual-boot on your GPU-enabled machine.

For other questions related to different sources of input, I suggest you take a look at the cited official YOLOv5 repository and maybe direct them there. My repo is for running inference on image(s) from a ROS topic, so technically it can do what you ask if you are familiar enough with using ROS i.e. publishing image/video(s) to topics and reading from topics or rosbag.