FreeImage is not set up correctly. Please ensure FreeImae is set up correctly

Hi, I followed the steps in: to set up cudnn. Everything seems to be working fine but when I executed “make clean && make”, I got the above warning and no mnistCUDNN was created.

Somebody suggested setting the CUDA_PATH using: export CUDA_PATH=/usr/local.cuda-9.0

but it does not work. I also tried:

sudo ln -s /usr/local/cuda-9.0/ /usr/local/cuda-9.0

but same issue. Then, I tried:

sudo ln -s /usr/local/cuda-9.0/ /usr/local/cuda

Again, same issue.

I also executed the following line as somebody mentioned:

cat /usr/include/x86_64-linux-gnu/cudnn_v7.h | grep CUDNN_MAJOR -A 2

but I still get:

make clean && make
rm -rf *o
rm -rf mnistCUDNN
/usr/bin/ld: -lcublas cannot be found
collect2: error: ld returned 1 exit status

WARNING - FreeImage is not set up correctly. Please ensure FreeImage is set up correctly. <<<

Doing “sudo dpkg -i libcudnn7*.deb” and repeat Sec 2.4 Verifying cuDNN is installed resulted in the same error.

Executing: nvcc --version

leds to "Command ‘nvcc’ not found, but can be installed with:

sudo apt install nvidia-cuda-toolkit"

Not sure if I need to do that.

Could you please help to resolve the issue?

Also, I am concerned that I might set the wrong path and make the wrong symbolic links. Please let me know how to undo the above three lines of command that don’t work.

I am using Pop OS which somebody said is basically ubuntu. Not sure if this is true.


1 Like

Assuming you are using cuda 9. In Ubuntu I put these exports in my .profile. If your .profile is empty then this is not the place to put it. You will have to figure that out yourself. This is in the cuda documentation. You will want to leave out the numbers at the beginning.

sudo nano $HOME/.profile
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

It might also be due to some 3rd party packages. In the cuda documentation it says to get these if you want to use the samples.

sudo apt-get install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev

I also did a quick google search and saw on the third link something about “How To Install and Use FreeImage” it gave a library. So if the other things didn’t work try using the packages below.

sudo apt-get install libfreeimage3 libfreeimage-dev

If that doesn’t work use the Ubuntu that is supported with your cuda and cudnn version and do the things I put above. You probably don’t need to do the last one, though.


I ran into the same issue and this fixed it for me


Same here, this fixed it for me!


This still does not work for me. I have followed these instructions but continue to get the same error.

It seems that the above-mentioned two commands have not made sense to me. It still has the persistent error as follows.

Ubuntu 18.04
Driver: 440.110 ppa
CUDA Toolkit 10.2
cuDNN 7.6.5

$ sudo cp -r /usr/src/cudnn_samples_v7/ $HOME
$ cd $HOME/cudnn_samples_v7/mnistCUDNN
$ make clean && make

/bin/sh: 1: cannot create test.c: Permission denied
/bin/sh: 1: cannot create test.c: Permission denied
g++: error: test.c: No such file or directory
g++: warning: ‘-x c’ after last input file has no effect
g++: fatal error: no input files
compilation terminated.

WARNING - FreeImage is not set up correctly. Please ensure FreeImage is set up correctly. <<<

It is quite strange. After I re-install the Ubuntu System, it has generated the error.

I reinstalled Ubuntu 18.04 system, Official Nvidia Driver 440.33, CUDA Toolkit 10.2 and cuDNN 7.6.5. It is quite strange I got Test passed! after I added the super user command “sudo -i”

$ sudo -i
$ cp -r /usr/src/cudnn_samples_v7/ $HOME
$ cd $HOME/cudnn_samples_v7/mnistCUDNN
$ make clean && make
$ ./mnistCUDNN

Test passed!

Ubunt ppa only allows 440.100 Driver. I had personally thought that it is the incompatibility between 440.100 Driver and CUDA Toollkit 10.2 that indicates the 440.33.01 driver with its detail listed as follows.


However, it still had the error with no inputting “sudo -i”. It does not make sense for me to install libfreeimage3 libfreeimage-dev in the new installed environment. What’s wrong with the error in the condition of no-inputting “sudo -i” command?

My test of mnistCUDNN is finally passed. It is quite strange that the terminal sometimes pops up the requirement of sudo. After adding sudo before the command, it fails. However, the terminal does not require the permission of sudo this time. So it is ok for me right now.

$ cp -r /usr/src/cudnn_samples_v7/ $HOME
$ cd $HOME/cudnn_samples_v7/mnistCUDNN
$ make clean && make
$ ./mnistCUDNN

By the way, It is not necessary for me to install libfreeimage3 libfreeimage-dev with any scenarios.

Test passed!


hello, running in same problem with cudnn_samples_v8. Chmod mnistCUDNN has no effect.
Ubuntu 18.04, Nvidia GTX650-TI-boost, Cuda Toolkit 11, 450.66 drivers

Thx in advance for any help

This solved my issue as well. Thanks @KingDudman