Linux环境下基于Anaconda安装tensorflow

(一)安装Anaconda3

1. 下载

# 添加清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
 
# 添加阿里云镜像源
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/free/
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/main/
 
# 添加中科大源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/

镜像网站下载Anaconda(清华的镜像源老是出各种稀奇古怪的问题),本次下载的是5.3.1版本。
在这里插入图片描述下载好以后上传到服务器里

2. 安装

在文件目录下执行
bash Anaconda3-5.3.1-Linux-x86_64.sh
根据提示输入回车、密码、yes/no
安装完成后配置环境路径(User1为自己的用户名)
echo 'export PATH="/home/User1/anaconda3/bin:$PATH"'>>~/.bashrc
source ~/.bashrc
随后运行anaconda
出现下图情况则说明安装且配置成功
在这里插入图片描述

(二)安装tensorflow

建议使用conda安装tensorflow,我先用pip装的,各种出故障。网上某大佬说建议用conda,会自动下载依赖项,实测有效:
conda install tensorflow==1.14

创建虚拟环境

手动下载并安装 CUDA 及 cuDNN(未采)

tensorflow-gpu 和 CUDA 及 cuDNN 的版本对应关系(官网链接):

在这里插入图片描述

1. CUDA 下载

官网链接

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

2. cuDNN 下载

conda 安装

CUDA 下载

在这里插入图片描述

cuDNN 下载

在这里插入图片描述

(三) 2020年11月19日更新

服务器要重新配置TensorFlow环境
安装 GPU版TensorFlow:
pip install --index https://pypi.douban.com/simple tensorflow-gpu==1.8.0

检查

查看 tensorflow-gpu 中的 GPU 是否可用

import tensorflow as tf
tf.test.is_gpu_available()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值