torch / torch7

http://torch.ch
Other
8.97k stars 2.38k forks source link

"Could NOT find CUDA" #1138

Open mf27 opened 6 years ago

mf27 commented 6 years ago

I have Ubuntu 16.04, CUDA 9.0. I followed the installation steps, and after running ./install.sh I get this error:

CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find CUDA (missing: CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (found suitable version "9.0", minimum required is "6.5")

Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
/home/marko/torch/install/share/cmake/torch/FindCUDA.cmake:1009 (find_package_handle_standard_args)
CMakeLists.txt:7 (FIND_PACKAGE)

I have tried setting the variables CUDA_INCLUDE_DIRS, CUDA_CUDART_LIBRARY and CUDA_HOME, and it didn't help. Did I miss some necessary steps before the installation?

senmaoy commented 6 years ago

I have met the same error

small-yellow-duck commented 6 years ago

I'm also having the same problem.

CMake Error at /home/usr/anaconda2/envs/pytorch/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:137 (message): Could NOT find CUDA (missing: CUDA_INCLUDE_DIRS) (found suitable version "9.1", minimum required is "7.0") Call Stack (most recent call first): /home/usr/anaconda2/envs/pytorch/share/cmake-3.9/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)

senmaoy commented 6 years ago

I solved this error by add the following code into bashrc and profile

export PATH=/usr/local/cuda-9.0/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64$LD_LIBRARY_PATH  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/disk4/yesenmao/home/cudnn5/lib64

ptomato commented 6 years ago

@small-yellow-duck and I realized the problem was that when you install CUDA on Fedora from the Negativo17 repository, the correct CUDA include dir is /usr/include/cuda. CMAKE expects the path to end in .../include.

For anyone else facing this issue, we solved it by creating a dummy CUDA_HOME tree:

mkdir -p ~/cuda-dummy
cd ~/cuda-dummy
ln -s /usr/bin bin
ln -s /usr/lib64 lib
ln -s /usr/lib64 lib64
ln -s /usr/include/cuda include
ln -s /usr/share/cuda share

and adding export CUDA_HOME=$HOME/cuda-dummy to .bashrc.

Not sure if there's a bug in FindCUDA here — it was impossible to specify the correct include dir to CMAKE, either by setting a CUDA_INCLUDE_DIRS=/usr/include/cuda environment variable, or passing -DCUDA_INCLUDE_DIRS=/usr/include/cuda on the CMAKE command line. No matter what we did, CMAKE claimed the variable wasn't set. But it seems like specifying it should be allowed.

oyviaase commented 6 years ago

Try CUDA_INC_PATH instead of CUDA_INCLUDE_DIRS and add TORCH_NVCC_FLAGS=-D__CUDA_NO_HALF_OPERATORS__ to compile using cuda 9.1 that the Negativo17 repository provides