从零安装tensorflow GPU版本

1. 首先是需要安装anaconda (python版本最好在3.8以上),如果需要换conda源和pip源执行下面的代码

# 更改pip为清华源
pip install pip -U --user
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

#更改conda为清华源
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/msys2/

# 设置搜索时显示通道地址
conda config --set show_channel_urls yes

 

2. tensorflow GPU版 2.6(注意对照cuda的版本) ,cuda 11.3版本及cudnn 8.2.1(你的电脑不一定合适这个版本)

pip install tensorflow_gpu==2.6 -i https://pypi.tuna.tsinghua.edu.cn/simple
conda install cudatoolkit=11.3
conda install cudnn=8.2.1

3. 如果不知道自己的cuda版本可以使用nvdia-smi来查看自己GPU版本最高支持那个版本

4. 然后查看自己conda库(使用之前最好更新一下)的cudnn版本,然后找到适合的版本

conda search cudnn

 5. 根据上面可以看到8.2.1的版本是支持cuda 11.3的,此时只需

conda install cudnn=8.2.1
conda install cuda=11.3

6. 最后别忘了,下载tensorflow2.6就可以了

pip install tensorflow_gpu=2.6 -i https://pypi.tuna.tsinghua.edu.cn/simple

7. 最后测试一下

import tensorflow as tf
tf.config.list_physical_devices('GPU')

 8. 大功告成

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值