安装 cuda + cudnn

---恢复内容开始---

为了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

安装成功

 

---恢复内容结束---

猜你喜欢

转载自www.cnblogs.com/yuren1998/p/10934498.html
今日推荐