leggedrobotics / darknet_ros

YOLO ROS: Real-Time Object Detection for ROS
BSD 3-Clause "New" or "Revised" License
2.14k stars 1.16k forks source link

cannot find -lcuda #340

Open dylantzx opened 3 years ago

dylantzx commented 3 years ago

I am facing this issue even after trying what was mentioned in #252 and #289

This is what I've done so far. 1) cd catkin_ws/src && git clone --recursive git@github.com:leggedrobotics/darknet_ros.git 2) cd .. 3) catkin build darknet_ros -DCMAKE_BUILD_TYPE=Release

Some other extra information: 1) When run nvidia-smi

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 465.19.01    Driver Version: 465.19.01    CUDA Version: 11.3     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA Quadro P...  On   | 00000000:01:00.0  On |                  N/A |
| N/A   37C    P3    N/A /  N/A |    297MiB /  4036MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

2) Using Ubuntu 18.04 LTS, ROS Melodic with GPU NVIDIA Quadro P1000

3) When I run ls -l /usr/local/cuda-11.3/lib64/libcuda.so I already have: lrwxrwxrwx 1 root root 46 Jul 12 15:10 libcuda.so -> /usr/lib/x86_64-linux-gnu/libcuda.so.465.19.01 So doesn't this mean that I have already have a symbolic link to the cuda lib?

The error output is:

Errors     << darknet_ros:make /home/dylan/catkin_ws/logs/darknet_ros/build.make.012.log                                       
/home/dylan/catkin_ws/src/darknet_ros/darknet_ros/src/image_interface.cpp: In function ‘image** load_alphabet_with_file(char*)’:
/home/dylan/catkin_ws/src/darknet_ros/darknet_ros/src/image_interface.cpp:20:18: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
   char* labels = "/labels/%d_%d.png";
                  ^~~~~~~~~~~~~~~~~~~
/home/dylan/catkin_ws/src/darknet_ros/darknet/src/image_opencv.cpp: In function ‘image load_image_cv(char*, int)’:
/home/dylan/catkin_ws/src/darknet_ros/darknet/src/image_opencv.cpp:89:15: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
         system(buff);
         ~~~~~~^~~~~~
/usr/bin/ld: cannot find -lcuda
collect2: error: ld returned 1 exit status
make[2]: *** [/home/dylan/catkin_ws/devel/.private/darknet_ros/lib/libdarknet_ros_lib.so] Error 1
make[1]: *** [CMakeFiles/darknet_ros_lib.dir/all] Error 2
make: *** [all] Error 2
hypothe commented 2 years ago

Had that same issue while building a catkin env during the build of Docker image (but not when building the project from within the image), using nvidia-container-runtime. If that's your case too, I solved it by adding the library stubs among the directories linked in the darknet_ros CMake like so:

link_directories(
    ${CUDA_TOOLKIT_ROOT_DIR}/lib64
    ${CUDA_TOOLKIT_ROOT_DIR}/lib64/stubs
  )

(line is around 145)

johnny12150 commented 2 years ago

Had that same issue while building a catkin env during the build of Docker image (but not when building the project from within the image), using nvidia-container-runtime. If that's your case too, I solved it by adding the library stubs among the directories linked in the darknet_ros CMake like so:

link_directories(
    ${CUDA_TOOLKIT_ROOT_DIR}/lib64
    ${CUDA_TOOLKIT_ROOT_DIR}/lib64/stubs
  )

(line is around 145)

This works!!