1 配置
系統(tǒng):Windows10 專業(yè)版
CPU:i5-4210m
顯卡:GeForce 940m
2 準(zhǔn)備
? ? 1.Python :python 3.6.5 (tensorflow2.0和最新的2.1都只支持到Python 3.7)
? ? 2.VS2017?:官網(wǎng)下載了后安裝時(shí)沒有點(diǎn)勾所有功能集绰,只安裝了200M(感覺可以不裝耳幢。。),?還有Microsoft Visual C++ 2015 Redistributable Update
? ? 3.Cuda:下載官網(wǎng)Cuda10.0.1 和與其配對的cuDNN7.6.5(下載下來的cuDNN壓縮包解壓后瑞眼,分別把解壓文件夾中bin,include和lib/x64中的文件復(fù)制到Cuda的安裝路徑中的bin,include和lib/x64 下)
3 安裝
? ? 1.pip安裝
在cmd中輸入 :
pip install pip -U? # 升級 pip 到最新的版本 (>=10.0.0) 后進(jìn)行配置
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出錯(cuò):“找不到指定模塊”,換成2.0.0a0就可以import tnesorflow 了鸵赫。)
? ??2.查看gpu是否可用
在python中運(yùn)行:
import tensorflow as tf
tf.test.is_gpu_available()
.結(jié)果為True 說明是gpu可用衣屏。
(因?yàn)橹鞍惭b了又卸載tensorflow ,最后安裝了gpu版的tensorflow,gpu也不是可用辩棒,可能是沒有卸載干凈狼忱,cmd中輸入 pip list ,發(fā)現(xiàn)其中還有tensorflow-estimator? 2.1.0 和?tensorflow-gpu-estimator? 2.1.0, 將兩個(gè)都卸載了
pip uninstall tensorflow-estimator
pip uninstall tensorflow-gpu-estimator
結(jié)果就為True了一睁。)