Theano for Keras:无法编译cuda_ndarray.cu:libcublas.so.7.5:无法打开共享对象文件:没有这样的文件或目录

时间:2017-05-25 20:50:59

标签: python keras theano theano-cuda

我试图在虚拟环境中使用Keras和Theano后端。我得到的错误是:

错误(theano.sandbox.cuda):无法编译cuda_ndarray.cu:libcublas.so.7.5:无法打开共享对象文件:没有这样的文件或目录

显示在这里:

(hyperproj) $ python
>> import theano
ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: libcublas.so.7.5: cannot open shared object file: No such file or directory

WARNING (theano.sandbox.cuda): The cuda backend is deprecated and will be removed in the next release (v0.10).  Please switch to the gpuarray backend. You can get more information about how to switch at this URL:
 https://github.com/Theano/Theano/wiki/Converting-to-the-new-gpu-back-end%28gpuarray%29

WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu0 is not available  (error: cuda unavailable)

这是我到目前为止所做的:

$ screen
$ conda create -n hyperproj python=2.7 anaconda
$ source activate hyperproj
(hyperproj) $ conda install numpy
(hyperproj) $ conda install keras
(hyperproj) $ conda install theano
(hyperproj) $ cd $HOME
(hyperproj) $ cd .keras/
(hyperproj) $ vim keras.json

这就是keras.json现在的样子(我将tensorflow后端更改为theano后端):

{
    "image_dim_ordering": "th",
    "epsilon": 1e-07,
    "floatx": "float32",
    "backend": "theano"
}

我需要修改(或创建)我的.theanorc文件:

(hyperproj) $ vim ~/.theanorc

经过几次教程后,它看起来像这样:

[global]
floatX=float32
device=gpu0

[nvcc]
fastmath=True

[cuda]
root = /usr/local/cuda-7.5

有人说我可能需要检查我的.bashrc文件并修改我的$ PATH。这是现在的样子(例如this之后):

# Added by Canopy installer on 2016-06-20
# VIRTUAL_ENV_DISABLE_PROMPT can be set to '' to make bashprompt show that Canopy is active, otherwise 1
VIRTUAL_ENV_DISABLE_PROMPT=1 source /mnt/data/user/pkgs/enthought/canopy-1.5.1/bin/activate

# added by Anaconda2 2.5.0 installer
export PATH="/export/mlrg/user/anaconda2/bin:$PATH"

# added by Anaconda2 4.1.1 installer
export PATH="/mnt/data/user/pkgs/anaconda2/bin:$PATH"

#added to fix the theano libcudnn issue
export PATH=/usr/local/cuda/bin:/usr/local/cuda/lib64:$PATH
export LD_LIBRARY_PATH="/usr/local/cuda/lib64/:$LD_LIBRARY_PATH

我有CUDA 7.5,Ubuntu 14.04,g ++版本4.8.4。

如何解决错误?

1 个答案:

答案 0 :(得分:0)

奇怪的是,通过注销并重新登录来解决问题。当我登录时,我这样做了:

$ screen
$ source activate hyperproj
(hyperproj) $ which nvcc #gave me /usr/local/cuda/bin/nvcc
(hyperproj) $ cd /usr/local/cuda/lib64 #checked that I have libcublas.so
(hyperproj) $ cd $HOME
(hyperproj) $ python
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import keras
Using Theano backend.
WARNING (theano.sandbox.cuda): The cuda backend is deprecated and will be removed in the next release (v0.10).  Please switch to the gpuarray backend. You can get more information about how to switch at this URL:
 https://github.com/Theano/Theano/wiki/Converting-to-the-new-gpu-back-end%28gpuarray%29

Using gpu device 0: GeForce GTX TITAN Black (CNMeM is disabled, cuDNN not available)