1.首先我们需要下载anaconda的安装包,由于在终端使用命令行进行操作,使用wget指令,在Linux终端输入
wget https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh
2.下载完成后在安装目录下之执行安装指令
sh Anaconda3-2019.03-Linux-x86_64.sh
3.安装完成后,终端输入
conda init
若提示conda命令找不到,则需要配置PATH
4.创建虚拟环境
conda create -n tf1.15 python=3.6
5.激活环境
source activate tf1.15
6.pip安装TensorFlow-gpu
pip3 install tensorflow-gpu==1.15.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
7.命令行安装CUDA和CUDNN
%CUDA、CUDNN版本请按照本机显卡算力决定
% 使用TensorFlow1.15版请安装10.0版以上CUDA及7.4版以上CUDNN
conda install cudatoolkit=10.0 -c https://mirrors.ustc.edu.cn/anaconda/pkgs/main/linux-64/
conda install cudnn=7.6.5 -c https://mirrors.ustc.edu.cn/anaconda/pkgs/main/linux-64/
8.验证是否安装成功
先输入python进入交互式界面,然后用如下命令验证是否gpu版本启用
import tensorflow as tf
tf.test.is_gpu_available()