win10 GeForce MX150 anaconda tensorflow-gpu 1.120 cuda 9.0 cudNN6

预览
本想安装tensorflow-gpu 2,但是安装之后总是报错,之后发现是tensorflow-gpu版本太高,降低为1.12.0之后就可以了。

配置
显卡NVIDIA GeForce Mx150
驱动程序版本:388.73
cuda driver版本9.1.126
下载的文件

主要模块版本
vs2017
cuda 9 [cuda_9.0.176_win10.exe]
cudnn 7 [cudnn-9.0-windows10-x64-v7.6.5.32.zip]
Anoconda3 [Anaconda3-2019.10-Windows-x86_64.exe]
python3.6
tensorflow-gpu 1.12.0
1、笔记本配置
vs2017

显卡NVIDIA GeForce Mx150
驱动程序版本:388.73
cuda driver版本9.1.126

查看方式:

桌面右键->NVIDIA 控制面板

2、安装
首先明确版本对应关系【重要】
CUDA版本、英伟达 驱动版本对应关系

我电脑驱动程序版本:388.73,所以选择CUDA9.0

tensorflow-gpu、python、CUDA、cuDNN版本对应关系

CUDA9最多对应tensorflow-gpu-1.12.0,python3.6,cuDNN7。

2.1 cuda 9 [cuda_9.0.176_win10.exe]
https://developer.nvidia.com/cuda-toolkit-archive官网下载
选择cuda toolkit 9.0

双击下载的exe文件,选择自定义安装(安装cuda截取的是视频中的图)

对于CUDA下的Virtual Studio Integration,去掉勾。没有安装virtual studio一定要去掉勾,安装了vs也可以去掉。我选择去掉。【重要】

对于Driver component下的Display driver,如果新版本大于等于当前版本可以打钩安装,如果新版本小于当前版本绝对不能打钩安装,如果没有安装驱动一定要打钩安装。此处我选的是不打勾,我的电脑上没有显示当前版本号,比较新版本和驱动程序版本:388.73之后,我选择了不打勾。【超级重要】

对于NVDIA GXXX,没有作用,选择不打勾

环境变量记录(应该不需要手动添加环境变量)
自动增加环境变量

path完整情况

手动增加了用户变量Path值 添加C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin;

手动增加了.DLL,可能没用

2.2 cudnn [cudnn-9.0-windows10-x64-v7.6.5.32.zip]
https://developer.nvidia.com/rdp/cudnn-download官网下载,需要注册,选择和CUDA符合的版本,即for CUDA 9.0

下载完之后解压

之后把cudnn的3个文件拷贝到C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0

2.3 anoconda [Anaconda3-2019.10-Windows-x86_64.exe] python3.6
清华Anoconda镜像 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive
点一下按时间排序

拉到最后找到最新版本的windows的Anoconda

双击exe安装anoconda
注意选择自动添加环境变量

安装成功之后

在Anoconda中创建一个环境
进入cmd

修改Anoconda的源为清华的
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
1
2
3
创建1个环境,名称为tensorflow-gpu,python版本为3.6
conda create -n tensorflow-gpu python=3.6
1
envs下出现新的环境

2.4 tensorflow-gpu 1.12.0
激活并进入新创建的环境
conda activate tensorflow-gpu
1
在新创建的环境中安装tensorflow-gpu(用清华的源)
pip install tensorflow-gpu1.12.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
1
注意此处必须用tensorflow-gpu
1.12.0,如果用pip install tensorflow-gpu,则安装之后,在import tensorflow as tf 时会报错。

2.5 在pycharm中使用tensorflow
在项目的setting中配置对应的Project Intepreter(项目编译器),选择Anoconda中创建环境的python.exe即可。

测试
import tensorflow as tf

print(tf.version)
print(tf.test.is_gpu_available())

使用TensorFlow输出Hello

创建一个常量操作( Constant op )

这个 op 会被作为一个节点( node )添加到默认计算图上.

该构造函数返回的值就是常量节点(Constant op)的输出.

hello = tf.constant(‘Hello, world!’)

启动TensorFlow会话

sess = tf.Session()

运行 hello 节点

print(sess.run(hello))
sess.close()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
结果:

C:\Users\NFTC\Anaconda3\envs\tensorflow-gpu\python.exe C:/Users/NFTC/PycharmProjects/tensorflow-projects/hello.py
1.12.0
2020-02-07 01:04:21.737456: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2020-02-07 01:04:22.785635: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1432] Found device 0 with properties:
name: GeForce MX150 major: 6 minor: 1 memoryClockRate(GHz): 1.5315
pciBusID: 0000:01:00.0
totalMemory: 2.00GiB freeMemory: 1.63GiB
2020-02-07 01:04:22.786553: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0
2020-02-07 01:04:25.199960: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-02-07 01:04:25.200187: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988] 0
2020-02-07 01:04:25.200315: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0: N
2020-02-07 01:04:25.205147: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/device:GPU:0 with 1380 MB memory) -> physical GPU (device: 0, name: GeForce MX150, pci bus id: 0000:01:00.0, compute capability: 6.1)
True
2020-02-07 01:04:25.241036: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0
2020-02-07 01:04:25.241258: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-02-07 01:04:25.241453: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988] 0
2020-02-07 01:04:25.241570: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0: N
2020-02-07 01:04:25.241728: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1380 MB memory) -> physical GPU (device: 0, name: GeForce MX150, pci bus id: 0000:01:00.0, compute capability: 6.1)
b’Hello, world!’

Process finished with exit code 0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
可能存在的问题
tensorflow的 【 CUDA driver version 】 is insufficient for 【CUDA runtime version】 问题

参考&致谢
安装步骤
网易云 深度学习与TensorFlow 2入门实战
https://blog.csdn.net/qq_41760767/article/details/97444053
https://blog.csdn.net/xiaohuihui1994/article/details/83589701
https://blog.csdn.net/huahuazhu/article/details/89282173
https://blog.csdn.net/gongxsh00/article/details/81318404
查错
https://blog.csdn.net/pkxpp/article/details/88925868
https://blog.csdn.net/b657938016/article/details/101700648
添加链接描述
版本对应关系
https://jingyan.baidu.com/article/d5c4b52bb93db6da560dc53b.html
https://www.cnblogs.com/superxuezhazha/p/10623270.html
修改pip和conda的源
https://blog.csdn.net/xd_wjc/article/details/80588343
————————————————
版权声明:本文为CSDN博主「weixin_44350694」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_44350694/article/details/104203343

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值