Build pytorch v0.4.0 with CuDNN

I was trying to build pytorch 0.4.0 on my linux with cuda 9.1. However, after doing python setup.py install, I found that cudnn is not included given UserWarning: PyTorch was compiled without cuDNN support. To use cuDNN, rebuild PyTorch making sure the library is visible to the build system.

I did some check:

print(torch.backends.cudnn.version())
None
print(torch.cuda.is_available())
True

Further, in terminal

$CUDNN_LIB_DIR
-bash: /usr/local/cuda-9.1/lib64/: Is a directory
$CUDNN_INCLUDE_DIR
-bash: /usr/local/cuda-9.1/include/: Is a directory

Does anyone have some ideas on what I should do now?

libcudnn.so and cudnn.h have to be in their respective CUDNN_LIB_DIR and CUDNN_INCLUDE_DIR, make sure that this is the case.
Cudnn detection during compilation is done in this file https://github.com/pytorch/pytorch/blob/master/tools/setup_helpers/cudnn.py, make sure that cudnn is actually found when you compile.

1 Like

It’s weird that they are not in the corresponding cuda dir. Any thoughts? Also, I once tried to install pytorch with a provided binary file, and I did not get errors when running the code. How does that happen?
Thanks!

You have to separately install cudnn either by downloading it from nvidia’s site or from deb package http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/ or via conda package. Cudnn is not a part of cuda toolkit. Pytorch binaries include cudnn, so when you are using pytorch binaries, you don’t have to separately install cudnn.