Making libtorch

I’m following the steps here https://pytorch.org/cppdocs/installing.html

My folder structure is as follows:

  • build/
  • libtorch/
  • CmakeLists.txt
  • example-app.cpp

The latter files are as described in the link. build is empty and for the libtorch folder I downloaded the gpu version from the main download page.

When I run the following command inside the build folder:

cmake -DCMAKE_PREFIX_PATH=../libtorch ..

I get the following message:

-- Caffe2: CUDA detected: 10.1
-- Caffe2: CUDA nvcc is: /usr/bin/nvcc
-- Caffe2: CUDA toolkit directory: /usr
-- Caffe2: Header version is: 10.1
-- Found cuDNN: v8.0.4  (include: /usr/local/cuda/include, library: /usr/local/cuda/lib64/libcudnn.so)
-- Autodetected CUDA architecture(s):  6.1
-- Added CUDA NVCC flags for: -gencode;arch=compute_61,code=sm_61
-- Configuring done
CMake Warning at CMakeLists.txt:7 (add_executable):
  Cannot generate a safe runtime search path for target example-app because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libnvToolsExt.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/cuda/lib64
    runtime library [libcufft.so.10] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/cuda/lib64
    runtime library [libcurand.so.10] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/cuda/lib64

  Some of these libraries may not be found correctly.


-- Generating done
-- Build files have been written to: /home/joe/Documents/torchscript/build

I am a complete noob with Linux and c++/cmake. I have looked far and wide but cannot find out how to solve this. I don’t understand enough what information I should provide for help but here’s what I know.

Nvidia-smi and nvcc --version tell me I have CUDA 11.1 and driver version 455.23.05. My LD_LIBRARY_PATH is:

/usr/local/cuda-11.1/lib64. 

My PATH is:

usr/local/cuda-11.1/bin:/home/joe/anaconda3/bin:/home/joe/bin:/home/joe/.local/bin:/home/joe/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

I installed Pytorch 1.6 with Anaconda if that matters.

I am out of ideas on how to fix this. Any help is welcome!

Based on the output it seems the build files have been written successfully.
Do you get an error in any step or just this warning?

You are right, it does work! I just get these warnings