export PATH=/usr/local/cuda-8.0/lib64:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
保存后
# source /etc/profile
# nvcc -V 检查CUDA
# apt-get install cmake 安装cmake
# cd /usr/local/cuda-8.0/samples
# make 测试CUDA
测试时间较长,一段没有error即可中止
===========
= Summary =
===========
Driver: Not Selected
Toolkit: Installed in /usr/local/cuda-8.0
Samples: Installed in /storage/installers/cuda_samples, but missing recommended libraries
Please make sure that
- PATH includes /usr/local/cuda-8.0/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64, or, add /usr/local/cuda-8.0/lib64 to /etc/ld.so.conf and run ldconfig as root
To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/bin
Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-8.0/doc/pdf for detailed information on setting up CUDA.
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 361.00 is required for CUDA 8.0 functionality to work.
To install the driver using this installer, run the following command, replacing with the name of this run file:
sudo .run -silent -driver
Logfile is /tmp/cuda_install_16018.log
# cd cuda
# cp include/cudnn.h
/usr/local/cuda/include
# cp lib64/libcudnn.* /usr/local/cuda/lib64
cuDNN安装完成!
有的博客说要建立软链接,但是我没有做,步骤如下:
# cd /usr/local/cuda/lib64
# rm -rf libcudnn.so libcudnn.so.5
# ln -s libcudnn.5.1.3 libcudnn.so.5
# ln -s libcudnn.so.5 libcudnn.so
首先安装anaconda, 因为很多python库都包含在里面了,一次性安装很方便
# mv /usr/bin/python /usr/bin/python_bk
# ln -s /usr/share/anaconda2/bin/python /usr/bin/python
conda install h5py #注意必须先安装anaconda2
这时会提示升级anaconda,yes即可
ln -s /usr/anaconda2/bin/pip /usr/bin/pip 建立软连接
github下载 tensorflow_gpu-0.12.0rc0-cp27-none-linux-x86_64.whl
pip install tensorflow_gpu-0.12.0rc0-cp27-none-linux-x86_64.whl
安装完成。测试:
python && import tensorflow 测试tensorflow
或者:
# cd /usr/share/anaconda2/lib/python2.7/site-packages/tensorflow/models/image/mnist
# CUDA_VISIBLE_DEVICES = 0(选择显卡) python convolutional.py
开头出现以下字样表示安装成功:
Python 2.7.12 |Anaconda 4.2.0 (64-bit)| (default, Jul 2 2016, 17:42:40)
[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 tensorflow as tf
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so locally