安装tensorflow-gpu前准备
- 下载nvidia 驱动 NVIDIA-Linux-x86_64-418.56.run
- 下载cuda 用的是 cuda_10.0.130_410.48_linux.run
- 下载cudnn 用的是 cudnn-10.0-linux-x64-v7.4.2.24.tgz
- tensorflow-gpu==1.13.1
- 2和3的版本选择 是由tensorflow的版本决定的 具体使用那个查看 https://tensorflow.google.cn/install/source
安装驱动和相关nvidia计算平台相关
- lspci | grep -i nvidia 检查是否由对应的显卡
- gcc --version 检查gcc版本是符合
- uname -r 检查Kernerl 的版本 显示则已经正确安装 没有安装执行4 5
- 安装kernel-devel和kernel-headers
- apt-get install linux-kernel-headers kernel-package
- Centos yum install kernerl-devel kernerl-deaders epel-relaese --enablerepo-epel dkms
- init3
- 安装驱动 sh ./NVIDIA-Linux-x86_64-418.56.run
- 设置环境变量
- export CUDA_HOME=/usr/local/cuda
- export PATH=$PATH:$CUDA_HOME/bin
- export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
- 保存source ~/.bashrc
- 查看是否成功 nvcc -V
- cudnn 解压文件
- sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn* - 检查安装
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2 - 安装pyhton3 下载3.6 解压 长
- ./configure --prefix=/opt/ptyhon3.6
- make
- make install
- 创建软连接 sudo ln -s /opt/python3.6/bin/python3.6 /usr/bin/python3.6
- 安装pip3
wget --no-check-certificate https://github.com/pypa/pip/archive/9.0.1.tar.gz
tar -zvxf 9.0.1.tar.gz
cd pip-9.0.1
python3.6 setup.py install
- 安装sudo pip3 install tensorflow-gpu==1.13.1
- 验证import tensorflow
>>> import tensorflow as tf
>>> matrix1 = tf.constant([[3., 3.]])
>>> matrix2 = tf.constant([[2.],[2.]])
>>> product = tf.matmul(matrix1, matrix2)
>>> sess = tf.Session()