New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make all with USE_CUDNN := 1 cannot find cudnn.h #1325

Closed
synchro-- opened this Issue Oct 19, 2014 · 22 comments

Comments

Projects
None yet
@synchro--

synchro-- commented Oct 19, 2014

This might really be a stupid error but I cannot locate the 'cudnn.h' file.
The error is this :
./include/caffe/util/cudnn.hpp:5:19: fatal error: cudnn.h: No such file or directory
Someone can help me?

Thank you

@ronghanghu

This comment has been minimized.

Show comment
Hide comment
@ronghanghu

ronghanghu Oct 20, 2014

Member

First download cuDNN from NVIDIA: https://developer.nvidia.com/cudnn and then put the header and library files in the corresponding path on your machine.

Member

ronghanghu commented Oct 20, 2014

First download cuDNN from NVIDIA: https://developer.nvidia.com/cudnn and then put the header and library files in the corresponding path on your machine.

@synchro--

This comment has been minimized.

Show comment
Hide comment
@synchro--

synchro-- Oct 20, 2014

I already did that and the error was the same.
Then I saw that the cuda toolkit can be downloaded with apt (I'm on Ubuntu 14.04) and I prefer to do it with apt. In the Makefile.config there are these lines:
" On Ubuntu 14.04, if cuda tools are installed via
"sudo apt-get install nvidia-cuda-toolkit" then use this instead:
CUDA_DIR := /usr"

So it should work. Any suggestion?

synchro-- commented Oct 20, 2014

I already did that and the error was the same.
Then I saw that the cuda toolkit can be downloaded with apt (I'm on Ubuntu 14.04) and I prefer to do it with apt. In the Makefile.config there are these lines:
" On Ubuntu 14.04, if cuda tools are installed via
"sudo apt-get install nvidia-cuda-toolkit" then use this instead:
CUDA_DIR := /usr"

So it should work. Any suggestion?

@neubotech

This comment has been minimized.

Show comment
Hide comment
@neubotech

neubotech Oct 20, 2014

You need to manually put cudnn.hpp in your cuda/include folder.

neubotech commented Oct 20, 2014

You need to manually put cudnn.hpp in your cuda/include folder.

@synchro--

This comment has been minimized.

Show comment
Hide comment
@synchro--

synchro-- Oct 20, 2014

I thought so, but it's cudnn.h, cudnn.hpp is already there

synchro-- commented Oct 20, 2014

I thought so, but it's cudnn.h, cudnn.hpp is already there

@dreamingo

This comment has been minimized.

Show comment
Hide comment
@dreamingo

dreamingo Oct 20, 2014

In Ubuntu14.04, you can place cudnn.h into /usr/include and set the proper permission of it.

dreamingo commented Oct 20, 2014

In Ubuntu14.04, you can place cudnn.h into /usr/include and set the proper permission of it.

@synchro--

This comment has been minimized.

Show comment
Hide comment
@synchro--

synchro-- Oct 20, 2014

Yes, but where can I find cudnn.h? I've already dowloaded the installer from https://developer.nvidia.com/cudnn and installed the toolkit. That file is missing.

synchro-- commented Oct 20, 2014

Yes, but where can I find cudnn.h? I've already dowloaded the installer from https://developer.nvidia.com/cudnn and installed the toolkit. That file is missing.

@dreamingo

This comment has been minimized.

Show comment
Hide comment
@dreamingo

dreamingo Oct 21, 2014

You don't need to download the installer from the https://developer.nvidia.com/cudnn
At the bottom of that page you can see the "Download" button;
After you register as a developer in nvidia and finish a survey of cudnn, then you can have the permission to download the cudnn6.5 library for Linux/Windows.

If you can't get that library, maybe I can email that to you.

dreamingo commented Oct 21, 2014

You don't need to download the installer from the https://developer.nvidia.com/cudnn
At the bottom of that page you can see the "Download" button;
After you register as a developer in nvidia and finish a survey of cudnn, then you can have the permission to download the cudnn6.5 library for Linux/Windows.

If you can't get that library, maybe I can email that to you.

@synchro--

This comment has been minimized.

Show comment
Hide comment
@synchro--

synchro-- Oct 21, 2014

Ah thank you very much. I was so tired I didn't see the button. Now I'll try to include the cudnn.h file.
Just a little and I'll mark this issue as closed.

synchro-- commented Oct 21, 2014

Ah thank you very much. I was so tired I didn't see the button. Now I'll try to include the cudnn.h file.
Just a little and I'll mark this issue as closed.

@synchro--

This comment has been minimized.

Show comment
Hide comment
@synchro--

synchro-- Oct 21, 2014

By the way you confirm that I can run caffe with CUDA without problem even if I installed the libraries by

sudo apt-get install nvidia-cuda-toolkit
?

synchro-- commented Oct 21, 2014

By the way you confirm that I can run caffe with CUDA without problem even if I installed the libraries by

sudo apt-get install nvidia-cuda-toolkit
?

@beniz

This comment has been minimized.

Show comment
Hide comment
@beniz

beniz Oct 22, 2014

On my server, aptitude reports:

Package: nvidia-cuda-toolkit             
Version: 5.5.22-3ubuntu1

which seems to suggest that this is cuda 5.5. Latest cuda AFAIK is 6.5. CuDNN works against 6.5 AFAIK. From there you know what you should do :)

beniz commented Oct 22, 2014

On my server, aptitude reports:

Package: nvidia-cuda-toolkit             
Version: 5.5.22-3ubuntu1

which seems to suggest that this is cuda 5.5. Latest cuda AFAIK is 6.5. CuDNN works against 6.5 AFAIK. From there you know what you should do :)

@shelhamer shelhamer closed this Oct 27, 2014

@synchro--

This comment has been minimized.

Show comment
Hide comment
@synchro--

synchro-- Oct 27, 2014

Hey I thought I closed this lots of days ago. Btw thank you Beniz and dreammingo. :) It works

synchro-- commented Oct 27, 2014

Hey I thought I closed this lots of days ago. Btw thank you Beniz and dreammingo. :) It works

@helxsz

This comment has been minimized.

Show comment
Hide comment
@helxsz

helxsz Dec 20, 2014

@dreamingo I have downloaded cudnn6.5 library, and place cudnn.h into /usr/include, and I tried to make all , the error of 'cannot find cudnn.h' is gone.
But more errors come out

./include/caffe/util/cudnn.hpp:11:28: note: in definition of macro ‘CUDNN_CHECK’
     cudnnStatus_t status = condition; \
                            ^
In file included from ./include/caffe/loss_layers.hpp:11:0,
                 from ./include/caffe/common_layers.hpp:12,
                 from ./include/caffe/vision_layers.hpp:10,
                 from src/caffe/layer_factory.cpp:5:
./include/caffe/neuron_layers.hpp: At global scope:

./include/caffe/neuron_layers.hpp:467:3: error: ‘cudnnTensor4dDescriptor_t’ does not name a type
   cudnnTensor4dDescriptor_t bottom_desc_;

src/caffe/layer_factory.cpp: In function ‘caffe::SoftmaxLayer<Dtype>* caffe::GetSoftmaxLayer(const string&, const caffe::LayerParameter&) [with Dtype = float; std::string = std::basic_string<char>]’:
src/caffe/layer_factory.cpp:167:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
src/caffe/layer_factory.cpp: In function ‘caffe::PoolingLayer<Dtype>* caffe::GetPoolingLayer(const string&, const caffe::LayerParameter&) [with Dtype = double; std::string = std::basic_string<char>]’:
src/caffe/layer_factory.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]

I don't know why there are so many errors, and I wonder is it because I have't set the permission on the cudnn.h in the path of /usr/include

helxsz commented Dec 20, 2014

@dreamingo I have downloaded cudnn6.5 library, and place cudnn.h into /usr/include, and I tried to make all , the error of 'cannot find cudnn.h' is gone.
But more errors come out

./include/caffe/util/cudnn.hpp:11:28: note: in definition of macro ‘CUDNN_CHECK’
     cudnnStatus_t status = condition; \
                            ^
In file included from ./include/caffe/loss_layers.hpp:11:0,
                 from ./include/caffe/common_layers.hpp:12,
                 from ./include/caffe/vision_layers.hpp:10,
                 from src/caffe/layer_factory.cpp:5:
./include/caffe/neuron_layers.hpp: At global scope:

./include/caffe/neuron_layers.hpp:467:3: error: ‘cudnnTensor4dDescriptor_t’ does not name a type
   cudnnTensor4dDescriptor_t bottom_desc_;

src/caffe/layer_factory.cpp: In function ‘caffe::SoftmaxLayer<Dtype>* caffe::GetSoftmaxLayer(const string&, const caffe::LayerParameter&) [with Dtype = float; std::string = std::basic_string<char>]’:
src/caffe/layer_factory.cpp:167:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
src/caffe/layer_factory.cpp: In function ‘caffe::PoolingLayer<Dtype>* caffe::GetPoolingLayer(const string&, const caffe::LayerParameter&) [with Dtype = double; std::string = std::basic_string<char>]’:
src/caffe/layer_factory.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]

I don't know why there are so many errors, and I wonder is it because I have't set the permission on the cudnn.h in the path of /usr/include

@dreamingo

This comment has been minimized.

Show comment
Hide comment
@dreamingo

dreamingo Dec 20, 2014

Hi, xsz. I have no idea about what's going wrong with you compilation.Can
you compile it successfully without the cudnn flag? I found an issue
related to your situation in google-group. Here is the link:
https://groups.google.com/forum/#!topic/caffe-users/7Quck_AD9AA

In the last comment an user said that:
"I hand very similar error today. Looks like caffe is not ready for
last CuDNN R2. I've downloaded R1 version and everything built with no
errors and passed all tests.

Maybe you may have to check the version of cudnn.
"

On Sat, Dec 20, 2014 at 7:47 PM, xsz notifications@github.com wrote:

@dreamingo https://github.com/dreamingo I have downloaded cudnn6.5
library, and place cudnn.h into /usr/include, and I tried to make all , the
error of 'cannot find cudnn.h' is gone.
But more errors come out

./include/caffe/util/cudnn.hpp:11:28: note: in definition of macro ‘CUDNN_CHECK’
cudnnStatus_t status = condition;
^
In file included from ./include/caffe/loss_layers.hpp:11:0,
from ./include/caffe/common_layers.hpp:12,
from ./include/caffe/vision_layers.hpp:10,
from src/caffe/layer_factory.cpp:5:
./include/caffe/neuron_layers.hpp: At global scope:

./include/caffe/neuron_layers.hpp:467:3: error: ‘cudnnTensor4dDescriptor_t’ does not name a type
cudnnTensor4dDescriptor_t bottom_desc_;

src/caffe/layer_factory.cpp: In function ‘caffe::SoftmaxLayer* caffe::GetSoftmaxLayer(const string&, const caffe::LayerParameter&) [with Dtype = float; std::string = std::basic_string]’:
src/caffe/layer_factory.cpp:167:1: warning: control reaches end of non-void function [-Wreturn-type]
}
src/caffe/layer_factory.cpp: In function ‘caffe::PoolingLayer* caffe::GetPoolingLayer(const string&, const caffe::LayerParameter&) [with Dtype = double; std::string = std::basic_string]’:
src/caffe/layer_factory.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]

I don't know why there are so many errors, and I wonder is it because I
have't set the permission on the cudnn.h in the path of /usr/include


Reply to this email directly or view it on GitHub
#1325 (comment).

dreamingo commented Dec 20, 2014

Hi, xsz. I have no idea about what's going wrong with you compilation.Can
you compile it successfully without the cudnn flag? I found an issue
related to your situation in google-group. Here is the link:
https://groups.google.com/forum/#!topic/caffe-users/7Quck_AD9AA

In the last comment an user said that:
"I hand very similar error today. Looks like caffe is not ready for
last CuDNN R2. I've downloaded R1 version and everything built with no
errors and passed all tests.

Maybe you may have to check the version of cudnn.
"

On Sat, Dec 20, 2014 at 7:47 PM, xsz notifications@github.com wrote:

@dreamingo https://github.com/dreamingo I have downloaded cudnn6.5
library, and place cudnn.h into /usr/include, and I tried to make all , the
error of 'cannot find cudnn.h' is gone.
But more errors come out

./include/caffe/util/cudnn.hpp:11:28: note: in definition of macro ‘CUDNN_CHECK’
cudnnStatus_t status = condition;
^
In file included from ./include/caffe/loss_layers.hpp:11:0,
from ./include/caffe/common_layers.hpp:12,
from ./include/caffe/vision_layers.hpp:10,
from src/caffe/layer_factory.cpp:5:
./include/caffe/neuron_layers.hpp: At global scope:

./include/caffe/neuron_layers.hpp:467:3: error: ‘cudnnTensor4dDescriptor_t’ does not name a type
cudnnTensor4dDescriptor_t bottom_desc_;

src/caffe/layer_factory.cpp: In function ‘caffe::SoftmaxLayer* caffe::GetSoftmaxLayer(const string&, const caffe::LayerParameter&) [with Dtype = float; std::string = std::basic_string]’:
src/caffe/layer_factory.cpp:167:1: warning: control reaches end of non-void function [-Wreturn-type]
}
src/caffe/layer_factory.cpp: In function ‘caffe::PoolingLayer* caffe::GetPoolingLayer(const string&, const caffe::LayerParameter&) [with Dtype = double; std::string = std::basic_string]’:
src/caffe/layer_factory.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]

I don't know why there are so many errors, and I wonder is it because I
have't set the permission on the cudnn.h in the path of /usr/include


Reply to this email directly or view it on GitHub
#1325 (comment).

@jnhwkim

This comment has been minimized.

Show comment
Hide comment
@jnhwkim

jnhwkim Nov 16, 2015

In my case, cudnn.h took place in /opt/cudnn/cuda/include/ by unknown.

jnhwkim commented Nov 16, 2015

In my case, cudnn.h took place in /opt/cudnn/cuda/include/ by unknown.

@SmallOneHan

This comment has been minimized.

Show comment
Hide comment
@SmallOneHan

SmallOneHan Dec 31, 2015

Hello, I met the same issue in the beginning. I have fixed it now by doing these.
https://developer.nvidia.com/cudnn
resigier and download cudnn-7.0-linux-x64-v4.0-rc.tgz
explode file in ~/ directory

SmallOneHan commented Dec 31, 2015

Hello, I met the same issue in the beginning. I have fixed it now by doing these.
https://developer.nvidia.com/cudnn
resigier and download cudnn-7.0-linux-x64-v4.0-rc.tgz
explode file in ~/ directory

@Coderx7

This comment has been minimized.

Show comment
Hide comment
@Coderx7

Coderx7 Jan 27, 2016

Contributor

I had the same problem, I thought installing cuda tool-kit would install everything,! apparently I was wrong!.
So as @synchro-- and @dreamingo suggested, I downloaded the cuddn library package ( in my case (cudnn-7.0-linux-x64-v3.0-prod.tgz) and after extracting its contetnt (include and lib64 directories) I placed their contents in the usr/include and usr/lib respectively . everything compiled just fine.

Contributor

Coderx7 commented Jan 27, 2016

I had the same problem, I thought installing cuda tool-kit would install everything,! apparently I was wrong!.
So as @synchro-- and @dreamingo suggested, I downloaded the cuddn library package ( in my case (cudnn-7.0-linux-x64-v3.0-prod.tgz) and after extracting its contetnt (include and lib64 directories) I placed their contents in the usr/include and usr/lib respectively . everything compiled just fine.

@sabako123

This comment has been minimized.

Show comment
Hide comment
@sabako123

sabako123 May 11, 2016

Good Morning,

The file 'cudnn.h' is located in the foler where you have installed your 'cudnn', for exemple :

cp lib64/* /usr/local/cuda/lib64/
cp include/cudnn.h /usr/local/cuda/include/

so you have to edit the Makefile.config which is in the caffe root folder,
-- edit Makefile.config ---
uncomment this line "USE_CUDNN := 1" for acceleration GPU
add /usr/local/cuda/include/ to INCLUDE_DIRS ( just add withspace between two path)
and add /usr/local/cuda/lib64/ to LIBRARY_DIRS ( just add withspace between two path)

cordially.

sabako123 commented May 11, 2016

Good Morning,

The file 'cudnn.h' is located in the foler where you have installed your 'cudnn', for exemple :

cp lib64/* /usr/local/cuda/lib64/
cp include/cudnn.h /usr/local/cuda/include/

so you have to edit the Makefile.config which is in the caffe root folder,
-- edit Makefile.config ---
uncomment this line "USE_CUDNN := 1" for acceleration GPU
add /usr/local/cuda/include/ to INCLUDE_DIRS ( just add withspace between two path)
and add /usr/local/cuda/lib64/ to LIBRARY_DIRS ( just add withspace between two path)

cordially.

@luisitobarcito

This comment has been minimized.

Show comment
Hide comment
@luisitobarcito

luisitobarcito May 17, 2016

I would suggest not to copy the cudnn library files into /usr/local/cuda directory. This may create issues with newer versions of the library.
An easier solution is to modify the Makefile.config:
add <your_cudnn_location>/cuda/include/ to INCLUDE_DIRS ( just add withspace between two path)
and add <your_cudnn_location>/cuda/lib64/ to LIBRARY_DIRS ( just add withspace between two path)

and edit your .bashrc file adding the following line:
export LD_LIBRARY_PATH=<your_cudnn_location>/cuda/lib64/:${LD_LIBRARY_PATH}

<your_cudnn_location> is the place here you untar the library files obtained from https://developer.nvidia.com/cudnn
Notice that at the moment, caffe supports cudnn v4.0 not v5.0 (current version)

luisitobarcito commented May 17, 2016

I would suggest not to copy the cudnn library files into /usr/local/cuda directory. This may create issues with newer versions of the library.
An easier solution is to modify the Makefile.config:
add <your_cudnn_location>/cuda/include/ to INCLUDE_DIRS ( just add withspace between two path)
and add <your_cudnn_location>/cuda/lib64/ to LIBRARY_DIRS ( just add withspace between two path)

and edit your .bashrc file adding the following line:
export LD_LIBRARY_PATH=<your_cudnn_location>/cuda/lib64/:${LD_LIBRARY_PATH}

<your_cudnn_location> is the place here you untar the library files obtained from https://developer.nvidia.com/cudnn
Notice that at the moment, caffe supports cudnn v4.0 not v5.0 (current version)

@monajalal

This comment has been minimized.

Show comment
Hide comment
@monajalal

monajalal Aug 23, 2016

After downloading CuDNN library folder in tgz format you get cudnn.h in /cuda/include folder, then I did so:
sudo cp /home/jalal/cudnn/cuda/include/cudnn.h /usr/include/

monajalal commented Aug 23, 2016

After downloading CuDNN library folder in tgz format you get cudnn.h in /cuda/include folder, then I did so:
sudo cp /home/jalal/cudnn/cuda/include/cudnn.h /usr/include/

@anshkapil

This comment has been minimized.

Show comment
Hide comment
@anshkapil

anshkapil Aug 29, 2016

Is it possible to link caffe to a local cudnn installation instead of copying the include and lib64 files?

I tried to change cuda.cmakelists , but its not successful

anshkapil commented Aug 29, 2016

Is it possible to link caffe to a local cudnn installation instead of copying the include and lib64 files?

I tried to change cuda.cmakelists , but its not successful

@vg123

This comment has been minimized.

Show comment
Hide comment
@vg123

vg123 Jun 7, 2017

In Makefile I changed GPU=1 CUDNN=1 OPENCV=0. but initially It was giving error this.

ubuntu@ip-10-0-0-226:~/$ make
gcc  -DGPU -I/usr/local/cuda-7.0/include/ -DCUDNN  -Wall -Wfatal-errors  -Ofast -DGPU -DCUDNN -c ./src/gemm.c -o obj/gemm.o
In file included from ./src/gemm.c:3:0:
./src/cuda.h:15:19: fatal error: cudnn.h: No such file or directory
 #include "cudnn.h"
                   ^
compilation terminated.
make: *** [obj/gemm.o] Error 1

And when I included the cudnn.h in /usr/include/ it is giving this error.

ubuntu@ip-10-0-0-226:~/$ make
gcc  -DGPU -I/usr/local/cuda-7.0/include/ -DCUDNN  -Wall -Wfatal-errors  -Ofast -DGPU -DCUDNN -c ./src/gemm.c -o obj/gemm.o
In file included from ./src/cuda.h:15:0,
                 from ./src/gemm.c:3:
/usr/include/cudnn.h:54:0: error: unterminated #if
 #if !defined(CUDNN_H_)
 ^
compilation terminated due to -Wfatal-errors.
make: *** [obj/gemm.o] Error 1

Please tell me how can I solve this error.

vg123 commented Jun 7, 2017

In Makefile I changed GPU=1 CUDNN=1 OPENCV=0. but initially It was giving error this.

ubuntu@ip-10-0-0-226:~/$ make
gcc  -DGPU -I/usr/local/cuda-7.0/include/ -DCUDNN  -Wall -Wfatal-errors  -Ofast -DGPU -DCUDNN -c ./src/gemm.c -o obj/gemm.o
In file included from ./src/gemm.c:3:0:
./src/cuda.h:15:19: fatal error: cudnn.h: No such file or directory
 #include "cudnn.h"
                   ^
compilation terminated.
make: *** [obj/gemm.o] Error 1

And when I included the cudnn.h in /usr/include/ it is giving this error.

ubuntu@ip-10-0-0-226:~/$ make
gcc  -DGPU -I/usr/local/cuda-7.0/include/ -DCUDNN  -Wall -Wfatal-errors  -Ofast -DGPU -DCUDNN -c ./src/gemm.c -o obj/gemm.o
In file included from ./src/cuda.h:15:0,
                 from ./src/gemm.c:3:
/usr/include/cudnn.h:54:0: error: unterminated #if
 #if !defined(CUDNN_H_)
 ^
compilation terminated due to -Wfatal-errors.
make: *** [obj/gemm.o] Error 1

Please tell me how can I solve this error.

@kz81

This comment has been minimized.

Show comment
Hide comment
@kz81

kz81 Jul 30, 2018

Under windows, you need to take the three folders included in cudnn-7.5-windows7-x64-v5.0-ga.zip (or other CUDNN archive) and copy them into your CUDA folder (e.g. "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5"). If you extract the .zip directly there, then it will make "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\Cuda" and put the folders there. But they need to be directly in "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5"!
(That was the simple solution that took me so long to find)

kz81 commented Jul 30, 2018

Under windows, you need to take the three folders included in cudnn-7.5-windows7-x64-v5.0-ga.zip (or other CUDNN archive) and copy them into your CUDA folder (e.g. "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5"). If you extract the .zip directly there, then it will make "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\Cuda" and put the folders there. But they need to be directly in "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5"!
(That was the simple solution that took me so long to find)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment