安装CUDA toolkit 和显卡驱动
在官网下载对应版本,https://developer.nvidia.com/cuda-downloads
sh cuda*.run
提示安装选择推荐显卡驱动
cuda安装位置:/usr/local/cuda-9.0
软链位置:/usr/local/cuda
环境变量配置:
vim /etc/profile
export PATH=/usr/local/cuda-9.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:/usr/lib/nvidia:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
source /etc/profile
nvcc -V
安装cudnn
下载地址:https://developer.nvidia.com/rdp/cudnn-download
解压
tar xf cudnn-9.0-linux-x64-v7.1.tgz
cd cuda
cp include/cudnn.h /usr/local/cuda/include
cp lib64/libcudnn.* /usr/local/cuda/lib64
安装依赖
apt install linux-headers-$(uname -r)
apt install python3-pip
pip3 install opencv-python imutils termcolor matplotlib nanotime tornado urllib3 sklearn setuptools scipy requests Pillow tensorflow-gpu
测试
>>>import tensorflow as tf
>>>hello = tf.constant('Hello, TensorFlow!')
>>>sess = tf.Session()
>>>print(sess.run(hello))
网友评论