Skip to content
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 · 26 comments
Closed

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

synchro-- opened this issue Oct 19, 2014 · 26 comments

Comments

@synchro--
Copy link

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
Copy link
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.

@synchro--
Copy link
Author

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
Copy link

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

@synchro--
Copy link
Author

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

@dreamingo
Copy link

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

@synchro--
Copy link
Author

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
Copy link

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--
Copy link
Author

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--
Copy link
Author

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
Copy link

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 :)

@synchro--
Copy link
Author

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

@helxsz
Copy link

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
Copy link

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
Copy link

jnhwkim commented Nov 16, 2015

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

@SmallOneHan
Copy link

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
Copy link
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.

@kaderghal
Copy link

kaderghal 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
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

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)

@sumsuddin
Copy link

sumsuddin commented Nov 12, 2018

Install cudnn runtime library & developer library, both of them.

@khazaddim
Copy link

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

Thank you. I could not get cudnn.h in the .deb installers. i had to use the Tar and extract.

@synchro--
Copy link
Author

synchro-- commented May 11, 2023

People commenting on an issue I opened 9 years ago 😢
The feels.

Is Caffe still being used? Isn't everyone on PyTorch?

@Coderx7
Copy link
Contributor

Coderx7 commented May 11, 2023

People commenting on an issue I opened 9 years ago 😢 The feels.

Is Caffe still being used? Isn't everyone on PyTorch?

Caffe is pretty much dead, but there are people still using it for some reason. Turbo c++ was used by some teachers, students like up until 2012, 2015!! Caffe ain't that old yet 😄
Caffe 2 has been merged into pytorch as far I know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests