The first thing you’ll need for Theano to use your GPU is Nvidia’s GPU-programming toolchain. You should install
at least the CUDA driver and the CUDA Toolkit, as described here. The CUDA Toolkit installs a folder on your
computer with subfolders bin, lib, include, and some more too. (Sanity check: The bin subfolder should contain an
nvcc program which is the compiler for GPU code.) This folder is called the cuda root directory. You must also add
the ‘lib’ subdirectory (and/or ‘lib64’ subdirectory if you have a 64-bit Linux computer) to your
$LD_LIBRARY_PATH environment variable.
You must then tell Theano where the CUDA root folder is, and there are three ways to do it. Any one of them is
enough.
Define a $CUDA_ROOT environment variable to equal the cuda root directory, as in CUDA_ROOT=/path/to/cuda/root, or
add a cuda.root flag to THEANO_FLAGS, as in THEANO_FLAGS=’cuda.root=/path/to/cuda/root’, or
add a [cuda] section to your .theanorc file containing the option root = /path/to/cuda/root.
On Debian, you can ask the software package manager to install it for you. We have a user report that this works
for Debian Wheezy (7.0). When you install it this way, you won’t always have the latest version, but we were told
that it gets updated regularly. One big advantage is that it will be updated automatically. You can try the sudo
apt-get install nvidia-cuda-toolkit command to install it.
CUDA Toolkit 8.0
https://developer.nvidia.com/cuda-downloads
安装完成后,配置环境变量,在home下的.bashrc中加入
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
export CUDA_HOME=/usr/local/cuda:$CUDA_HOME
THEANO_FLAGS=mode=FAST_RUN,device=gpu,nvcc.flags=-D_FORCE_INLTNES floatX=float32 python check1.py
nvcc fatal : Path to libdevice library not specified
WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not available (error: cuda unavailable)
Using gpu device 0: GeForce GTX 1080 (CNMeM is disabled, cuDNN not available)
ERROR (theano.sandbox.cuda): nvcc compiler not found on $PATH. Check your nvcc installation and try again.