CUDNN not enabled when installing pytorch

Pytorch only support cuDNN 6.x or above, but another program on my computer needs cuDNN 5.1. So there are 2 versions on my computer and paths are:
/usr/local/cuda-8.0/lib64/cuDNNv5
/usr/local/cuda-8.0/lib64/cuDNNv6

However, even I add /usr/local/cuda-8.0/lib64/cuDNNv6 in LD_LIBRARY_PATH and CUDNN_LIB_DIR, cudnn is not found when I install pytorch.

Any one can give some help? How to specify CUDNN path for installing pytorch.

Thanks

Can you try setting CUDNN_INCLUDE_DIR to the include folder and CUDNN_LIB_DIR to the lib folder?

I’m not sure what’s under your cuDNNv6 folder but in general the CUDNN_LIB_DIR should have libcudnn.so (of some form) and CUDNN_INCLUDE_DIR should have cudnn.h

2 Likes

Hi , richard, thanks for your reply.

Under /usr/local/cuda-8.0/lib64/cuDNNv6/ there are:
image
and under /usr/local/cuda-8.0/include/cudnnv6/ there is cudnn.h.

export CUDNN_INCLUDE_DIR=/usr/local/cuda-8.0/include/cudnnv6/
exprot CUDNN_LIB_DIR=/usr/local/cuda-8.0/lib64/cuDNNv6/

Setting these two environment path dose not work. And setting LD_LIBRARY_PATH and C_INCLUDE_PATH & CPLUS_INCLUDE_PATH also dose not work.

It seems that pytorch can only find cudnn in /usr/local/cuda-8.0/lib64/ and /usr/local/cuda-8.0/include.

Which exception did you get?
Which GPU architecture are you using?

FYI, here is my build script for PyTorch v0.1.11.r317.gde984558 (May 23, CuDNN 5.1)

I didn’t update to CuDNN v6 yet, but it should be pretty easy to adapt. ENV variables to watch for:

  CC=gcc-5 \
  CXX=g++-5 \
  WITH_CUDA=1 \
  CUDA_HOME=/opt/cuda \
  WITH_CUDNN=1 \
  CUDNN_LIB_DIR=/opt/cuda/lib64 \
  CUDNN_INCLUDE_DIR=/opt/cuda/include \

CC and CXX must be GCC-5 for CUDA-8 and can be GCC-6 for CUDA-9 (I don’t think GCC-7 will work for any of those).
Don’t forget the WITH_CUDA and WITH_CUDNN

1 Like

@QuantScientist @mratsim Thanks for your reply~

I am using GeForce GTX 1080, and pytorch can be installed successfully without CUDNN.
I modified tools/setup_helpers/cudnn.py to print environment path of cudnn, and got None.

print 'CUDNN_INCLUDE_DIR is', os.getenv('CUDNN_INCLUDE_DIR')
print 'CUDNN_LIB_DIR is', os.getenv('CUDNN_LIB_DIR')
exit()
CUDNN_INCLUDE_DIR is None
CUDNN_LIB_DIR is None

However, these two path can be got in raw python cmd correctly. So strange. I do not know why they are invalid in pytorch install script.

I am not familiar with the python package installation, could you please give some help? Many thanks~~

Can you run this:

An then this:

?

Thanks, I’ve tried it. Pytorch can be installed successfully with your scripts. BUT cudnn is not supported.

import torch
print torch.backends.cudnn.version()

output nothing.

I solved this problem by add PATH in tools/setup_helpers/cudnn.py


BUT I still do not find the reason why it dose not work to export these path in terminal.:smiley:

@EthanZhangYi glad you solved it!

You should also consider looking into Docker. It is the best thing ever for keeping different libraries and programs running in their own separate containers, with just a 0.1% performance penalty.

Thanks, @FuriouslyCurious, I will learn to use docker~

Good news !

Regarding Docker, on my side I had mitigated experience while using it for DL competition environment on AWS, it was really slow and a pain to setup. Personally I use a LXC container dedicated to DL (Docker used to use LXC tech in the past) with no perf penalty. Your mileage may vary but any kind of container is good to make sure your DL environment doesn’t pollute/is not polluted by your main system, especially Python version updates. And backup-ing a container is relatively straightforward.

1 Like