0

I want to use PyTorch, openCV, CUDA and C++ in Colab.

I found the project https://github.com/prabhuomkar/pytorch-cpp I like CMake for the CUDA option.

But when I do the following in Colab:

!git clone https://github.com/prabhuomkar/pytorch-cpp.git

In the cmake folder in the fetch_libtorch.cmake file I will set the fifth line set(CUDA_V "11.6" CACHE STRING "Determines libtorch CUDA version to download (11.3, 11.6 or none).")

And I continue in Colab

%cd pytorch-cpp

!cmake -B build

This error occurs:

*CMake Warning at CMakeLists.txt:25 (add_executable): Cannot generate a safe runtime search path for target pytorch-cpp because files in some directories may conflict with libraries in implicit directories:

 runtime library [libcudnn.so.8] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
   /content/pytorch-cpp/libtorch/lib

Some of these libraries may not be found correctly.

CMake Warning at utils/image_io/CMakeLists.txt:10 (add_library): Cannot generate a safe runtime search path for target image-io because files in some directories may conflict with libraries in implicit directories:

 runtime library [libcudnn.so.8] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
   /content/pytorch-cpp/libtorch/lib

Some of these libraries may not be found correctly.*

How to build CMake to avoid this error?

I tried changing CMakeLists.txt but I didn't find a solution

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
adamW
  • 1

1 Answers1

0

I had the same issue. It seems it is due to having the share library libcudnn.so.8 locally installed on your machine as well as there being an instance of it in the libtorch/lib folder.

One of the options was to specify CMAKE_PREFIX_PATH, but that did not work since in general I was also specifying libtorch/.

The second option was to uninstall one version of it. Uninstalling it locally was not viable, since it would break my systems dependencies. I opted to just delete the libtorch/lib/libcudnn.so.8 Then CMake used the my local version instead. Using my local version of libcudnn.so.8 and the one found libtorch/lib/ led to no noticeable difference in performance.

moxo26
  • 3
  • 2