CMake does not properly find CUDA library

后端 未结 3 798
终归单人心
终归单人心 2021-01-18 07:40

I\'m trying to build a program that requires CUDA. To the CMake script I supply:

cmake -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda ..

CUDA is

3条回答
  •  时光说笑
    2021-01-18 08:30

    The C++ file with host calls doesnt know it needs to link to libcudart. You have to explicitly set dependencies for the file/binary that file is in, eg.

    target_link_libraries(clu ${CUDA_LIBRARIES})
    

    The above response is slightly wrong. It looks like libcuda.so is installed in unexpected location for whatever reason. You can try setting CMAKE_LIBRARY_PATH or/and CUDA_LIB_PATH to that path.

    The CUDA_LIB_PATH needs to be set outside cmake I think, eg export CUDA_LIB_PATH=/usr/local/cuda/lib64/stubs/

提交回复
热议问题