1 配置
系统:Windows10 专业版
CPU:i5-4210m
显卡:GeForce 940m
2 准备
1.Python :python 3.6.5 (tensorflow2.0和最新的2.1都只支持到Python 3.7)
2.VS2017 :官网下载了后安装时没有点勾所有功能,只安装了200M(感觉可以不装。。), 还有Microsoft Visual C++ 2015 Redistributable Update
3.Cuda:下载官网Cuda10.0.1 和与其配对的cuDNN7.6.5(下载下来的cuDNN压缩包解压后,分别把解压文件夹中bin,include和lib/x64中的文件复制到Cuda的安装路径中的bin,include和lib/x64 下)
3 安装
1.pip安装
在cmd中输入 :
pip install pip -U # 升级 pip 到最新的版本 (>=10.0.0) 后进行配置
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple #换清华下载源更快
pip install tensorflow-gpu==2.0.0a0 #安装gpu版2.0.0
(之前直接 pip install tensorflow 安装了cpu版2.1.0的,又 pip uninstall tensorflow 卸载,又
pip install tensorflow-gpu 安装后import出错:“找不到指定模块”,换成2.0.0a0就可以import tnesorflow 了。)
2.查看gpu是否可用
在python中运行:
import tensorflow as tf
tf.test.is_gpu_available()
.结果为True 说明是gpu可用。
(因为之前安装了又卸载tensorflow ,最后安装了gpu版的tensorflow,gpu也不是可用,可能是没有卸载干净,cmd中输入 pip list ,发现其中还有tensorflow-estimator 2.1.0 和 tensorflow-gpu-estimator 2.1.0, 将两个都卸载了
pip uninstall tensorflow-estimator
pip uninstall tensorflow-gpu-estimator
结果就为True了。)