conda安装Tensorflow2.9的GPU版本

有的API只有高版本的tensorflow有,所以这里再装个tensorflow2.9,我看了下,官网最新版本是2.10

anaconda这个环境隔离机制有点类似于docker,用起来太爽了。

每次换环境都要查下别人文章,太麻烦了,自己装个,方便后续查看。

1、新建环境

conda create -n tf2.9 python=3.8

image-20220917094724744

2、激活环境

conda activate tf2.9

3、cuda与cudnn的版本选择

这个我们先看下自己电脑的显卡驱动

image-20220917094820991

image-20220917094857842

可以看到,我们的CUDA版本是11.7,由于tensorflow 每个版本都与cuda和cudnn的版本绑定,所以只要绑定的cuda是11.7版本以下的,我们都能安装

官网查看tensorflow、python、tensorflow-gpui、cuda、cudnn的对应关系

https://tensorflow.google.cn/install/source_windows?hl=en#gpu

VersionPython versionCompilerBuild toolscuDNNCUDA
tensorflow_gpu-2.10.03.7-3.10MSVC 2019Bazel 5.1.18.111.2
tensorflow_gpu-2.9.03.7-3.10MSVC 2019Bazel 5.0.08.111.2
tensorflow_gpu-2.8.03.7-3.10MSVC 2019Bazel 4.2.18.111.2
tensorflow_gpu-2.7.03.7-3.9MSVC 2019Bazel 3.7.28.111.2
tensorflow_gpu-2.6.03.6-3.9MSVC 2019Bazel 3.7.28.111.2
tensorflow_gpu-2.5.03.6-3.9MSVC 2019Bazel 3.7.28.111.2
tensorflow_gpu-2.4.03.6-3.8MSVC 2019Bazel 3.1.08.011.0
tensorflow_gpu-2.3.03.5-3.8MSVC 2019Bazel 3.1.07.610.1
tensorflow_gpu-2.2.03.5-3.8MSVC 2019Bazel 2.0.07.610.1
tensorflow_gpu-2.1.03.5-3.7MSVC 2019Bazel 0.27.1-0.29.17.610.1
tensorflow_gpu-2.0.03.5-3.7MSVC 2017Bazel 0.26.17.410
tensorflow_gpu-1.15.03.5-3.7MSVC 2017Bazel 0.26.17.410
tensorflow_gpu-1.14.03.5-3.7MSVC 2017Bazel 0.24.1-0.25.27.410
tensorflow_gpu-1.13.03.5-3.7MSVC 2015 update 3Bazel 0.19.0-0.21.07.410
tensorflow_gpu-1.12.03.5-3.6MSVC 2015 update 3Bazel 0.15.07.29.0
tensorflow_gpu-1.11.03.5-3.6MSVC 2015 update 3Bazel 0.15.079
tensorflow_gpu-1.10.03.5-3.6MSVC 2015 update 3Cmake v3.6.379
tensorflow_gpu-1.9.03.5-3.6MSVC 2015 update 3Cmake v3.6.379
tensorflow_gpu-1.8.03.5-3.6MSVC 2015 update 3Cmake v3.6.379
tensorflow_gpu-1.7.03.5-3.6MSVC 2015 update 3Cmake v3.6.379
tensorflow_gpu-1.6.03.5-3.6MSVC 2015 update 3Cmake v3.6.379
tensorflow_gpu-1.5.03.5-3.6MSVC 2015 update 3Cmake v3.6.379
tensorflow_gpu-1.4.03.5-3.6MSVC 2015 update 3Cmake v3.6.368
tensorflow_gpu-1.3.03.5-3.6MSVC 2015 update 3Cmake v3.6.368
tensorflow_gpu-1.2.03.5-3.6MSVC 2015 update 3Cmake v3.6.35.18
tensorflow_gpu-1.1.03.5MSVC 2015 update 3Cmake v3.6.35.18
tensorflow_gpu-1.0.03.5MSVC 2015 update 3Cmake v3.6.35.18

可以看到,tensorflow2.9对应的CUDA版本是11.2,cuDNN版本是8.1

安装CUDA

 conda install cudatoolkit=11.2

image-20220917095257594

安装cuDNN

conda install cudnn=8.1

image-20220917095343272

4、安装tensorflow2.9-gpu

pip install tensorflow-gpu==2.9.0

image-20220917095446366

5、验证是否安装成功

python
import tensorflow as tf
tf.__version__

image-20220917100135607

验证GPU是否可用

tf.test.is_gpu_available()

image-20220917100148823

返回true说明没有问题。

6、安装ipykernel

为了方便我们在jupyter中使用

pip install ipykernel

前提是你base环境中已经使用conda install nb_conda_kernels命令安装过nb_conda_kernels

7、镜像

7.1 conda镜像

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
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/pkgs/free/
conda config --set show_channel_urls yes

7.2 conda中配置pip镜像

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

查看现有镜像

conda config --show channels

image-20220917100620824

到此,安装就搞完了,版本对应上应该没啥问题的。

镜像和ipykernel这部分没必要写,放这里是为了方便查看。

  • 11
    点赞
  • 54
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值