目录
1. 版本对应
1.1 基本形式
虚拟环境(python) + cuda+ cudnn + tensorflow-gpu + keras;
其中,cuda以及cudnn既需要与显卡相匹配,也需要与tf匹配;
1.2 举例tensorflow_gpu 2.2
python3.7 + cudatoolkit10.1 + cudnn7.6.5 + tensorflow-gpu2.2 + keras2.3.1;
1.3 其它版本
cudatoolkit和cudnn版本与tensorflow版本的对应参考
https://www.tensorflow.org/install/source#linux
;
keras版本和tensorflow版本的对应参考https://www.cnblogs.com/carle-09/p/11661261.html
;
2. 查看cuda支持版本
打开NVIDIA控制面板;
点击左下角系统信息;
点击组件,在列表中进行查看即可;
3. 查看conda镜像源下cuda版本信息
conda search cuda;
4. 查看conda镜像源下cudnn版本信息
conda search cudnn;
5. 创建虚拟环境
E: # 进入e盘
md my-envs; # 创建虚拟环境目录
cd my-envs; # 进入目录下准备创建虚拟环境
conda create -n my_env_1 python=3.x; # 创建虚拟环境 my_env_1
conda activate my_env_1; # 激活虚拟环境
conda deactivate my_env_1; # 关闭虚拟环境
conda env list; # 查看所有虚拟环境
conda remove -n my_env_1 --all; # 删除虚拟环境1
6. 安装tf2.2 gpu版
# 创建并激活虚拟环境
conda create -n tf22 python==3.7.10;
conda activate tf22;
# 配套安装
conda install cudatoolkit=10.1;
conda install cudnn=7.6.5;
pip install tensorflow-gpu==2.2.0;
pip install keras==2.3.1;
# 特别的,该版本tensorflow及keras对protobuf版本有依赖
pip uninstall protobuf;
pip install protobuf==3.19.0;
# 清华源pip速度更快
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple xxx;
7. 在python中查看tf基本信息
conda activate tf22;
python;
import tensorflow as tf;
print(tf.__version__);
print(tf.test.is_gpu_available());
quit();
conda deactivate tf22;
8. 参考资料
【1】https://zhuanlan.zhihu.com/p/434517802
【2】https://blog.csdn.net/m0_37748381/article/details/127991902