---恢復內容開始---
為了python機器學習裝tensoflow-gpu折騰了兩天,終於安好了,下面記錄一下,希望對大家有所幫助。
如果你還沒有開始裝,那么請按照下面步驟安裝
1,查看自己顯卡的版本與驅動版本,並按照gpu版本與驅動版本安裝cuda
(1)顯卡版本,我的是gtx1050,查看方法請自行百度
https://baijiahao.baidu.com/s?id=1619746395794934508&wfr=spider&for=pc
(2)驅動版本
win+R 鍵 ,輸入cmd ,Enter進入,具體命令如圖

cd..
Program Files\NVIDIA Corporation\NVSMI
nvidia-smi
我的是430.86(重新下載的驅動)

***如果版本不夠又想安裝新版本怎么辦呢?
安裝驅動唄!
https://jingyan.baidu.com/article/19020a0a6f8f44529d2842af.html
https://www.nvidia.cn/Download/index.aspx?lang=cn
參考博客:https://blog.csdn.net/masound/article/details/81909323
https://www.cnblogs.com/liaohuiqiang/archive/2018/10/15/9791365.html
2, 到官網下載cuda和cudnn
具體步驟推薦這篇博客,不再贅述
https://blog.csdn.net/qq_37296487/article/details/83028394
一定注意cuda和cudnn的版本匹配!

參考:https://blog.csdn.net/omodao1/article/details/83241074
3,tensorflow-gpu的安裝
win+R 鍵 ,輸入cmd ,Enter進入,記得激活環境
我之前一直使用pip 一直出問題,使用conda之后好了,具體原理不太清楚,不過建議都試試
pip install tensorflow-gpu
conda install tensorflow-gpu
版本裝最新的就好,不用擔心,python3.7不能使用太舊的版本。
4,檢查
下面使用一個小程序來檢查
import tensorflow as tf
# Build a graph.
a = tf.constant(5.0)
b = tf.constant(6.0)
c = a * b
# Launch the graph in a session.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# Evaluate the tensor `c`.
print(sess.run(c))


device:GPU
安裝成功
---恢復內容結束---
