Could not compile cuda_ndarray.cu: libcublas.so.7.5: cannot open shared objects file

I am trying to import the anano library into an aws instance to use the GPU. I wrote a python script using boto to automate the installation of aws, which essentially will make ssh for the instance from my local machine, and then run a bash script where I do " python -c 'import theano" to start the GPU. But I get the following error:

ERROR (theano.sandbox.cuda): Could not compile cuda_ndarray.cu: libcublas.so.7.5: cannot open shared objects file: no such file or directory

When I tried to import the anano module directly in the command shell of the instance, it automatically starts using the GPU.

Using GPU 0: GRID K520 (CNMeM Disabled)

I assume that I am missing another import that needs to be done when importing using my python automation script. What could be the solution?

+6
source share
4 answers

I will try to solve this problem clearly and concisely, as I did not find a very good answer for people who start using unix or are not familiar with compilation and links.

The problem is related to dynamic communication, and it can be solved in two ways. The first is setting the environment variable LD_LIBRARY_PATH. Assuming cuda is installed in / usr / local / cuda /, just add / etc / enviroment to the environment file:

LD_LIBRARY_PATH=/usr/local/cuda/ 

Or just in your bashrc:

 export LD_LIBRARY_PATH=/usr/local/cuda/lib64/ 

This solution is not recommended by the unix guru (I am not the one I just read on the Internet and I follow the linux guru). So the solution I found is simple, change the path where linux ld looks for default libraries. To do this, just do it (you have to do it as root):

 cd /etc/ld.so.conf.d/ 

Then select, for example, and edit:

 vi libc.conf 

Inside this file, just add the path to the lib64 root, for example:

 /usr/local/cuda/lib64/ 

In the file you will get something like this:

 \# libc default configuration /usr/local/lib /usr/local/cuda/lib64/ 

And then just run:

 sudo ldconfig 

Hope this answer helps people who are starting to see programming, or using high-level languages ​​like python, which uses the C code below (like anano) and are not familiar with compilation, linkig ...

+6
source

I ran into the same error on Ubuntu 16.04 with cuda 7.5 and found a solution here :

  • cuda 7.5 does not support the default g ++ version. Install a supported version and make it the default:

     sudo apt-get install g++-4.9 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 10 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 10 sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30 sudo update-alternatives --set cc /usr/bin/gcc sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30 sudo update-alternatives --set c++ /usr/bin/g++ 
  • Bypass the glibc error - create .theanorc in your home directory with the following settings:

     [global] device=gpu floatX=float32 [nvcc] flags=-D_FORCE_INLINES 

And don't forget to check the environment variables: PATH should contain your cuda bin folder location, and CUDA_HOME should contain your cuda home location

I added it to my .bashrc file as follows:

 export PATH="/usr/local/cuda/bin:$PATH" export CUDA_HOME="/usr/local/cuda:$CUDA_HOME" 
+4
source

I had a similar problem lately and I spent a lot of time figuring out what went wrong (before I messed up the Linux installation and had to complete a new installation).

A potential solution for this error is to remove the .theano/ directory , which (possibly) is in your home directory:

 sudo rm -rf ~/.theano 

To avoid this error, do not run your scripts as root (i.e. without sudo ).

Running the script with root privileges will create a hidden directory with root privileges, which will make it inaccessible to other processes.

+3
source

At the suggestion of Kumar here , I did

 sudo ldconfig /usr/local/cuda/lib64 

And this magic began to work. Thank you Kumar!

0
source

All Articles