使用anaconda prompt 安装tensorflow2 gpu版本,以及可用的keras版本
一、安装anaconda并决定安装tensorflow的版本
这里按照第一行所示版本进行安装
版本查询:
https://tensorflow.google.cn/install/source_windows#install_gpu_support_optional
安装anaconda完成后打开prompt,查看现有环境
conda env list
新建环境
conda create -n your_env_name python=x.x
这里将环境命名为tensorflow2gpu
选择python=3.7
激活环境
activate tensorflow2gpu
二、安装tensorflow=gpu及相应包
1.安装CUDA
在激活的环境中输入
conda install cudatoolkit=11.2
2.安装cuDNN
在激活的环境里输入
conda install cudnn=8.1
3.安装tensorflow-gpu
在激活的环境里输入
pip install tensorflow-gpu==2.6.0
4.安装其他包
我使用spyder、jupyter notebook进行编译
在激活的环境里输入
pip install spyder
pip install jupyter notebook
三、更改keras版本
在安装完成后,进行CNN代码学习时候发现错误:
cannot import name ‘dtensor’ from ‘tensorflow.compat.v2.experimental’
经查询发现keras2.9版本会导致此错误,故将keras降级到2.6.0
pip install keras==2.6.0
参考:
https://blog.csdn.net/m0_49090516/article/details/113576003