Windows10+TensorFlow1.9-gpu+Anaconda3+CUDA9.0+cuDNN v7.14环境配置笔记

一,TensorFlow版本与CUDA、cuDNN版本搭配

在安装TensorFlow时,必须要注意与CUDA、cuDNN版本之间的搭配,否则有可能安装失败。下图是windows系统下版本对应关系:

二,安装环境准备

TensorFlow即可以支持CPU,也可以支持CPU+GPU。前者的环境需求简单,后者需要额外的支持。TensorFlow1.4及以下是基于VC++2015开发的,所以需要下载安装VisualC++ Redistributable for Visual Studio 2015 来获取MSVCP140.DLL的支持。

TensorFlow1.9版本需要安装VisualC++ Redistributable for Visual Studio 2017,我这里已经安装了VS2017,所以就不需要安装了。如果要安装GPU版本(有N卡,即NVIDIA显卡),需要以下额外环境:

  1. 有支持CUDA计算能力3.0或更高版本的NVIDIAGPU卡。
  2. 下载安装CUDA Toolkit 9.0,并确保其路径添加到PATH环境变量里;
  3. 下载安装cuDNN v7.0或v7.1,并确保其路径添加到PATH环境变量里;
  4. CUDA9.0相关的NVIDIA驱动。

CPU版本不要完成显卡环境大搭建,直接pip安装TensorFlow即可。

三,使用Anaconda3安装TensorFlow1.9-gpu

  1. 下载anaconda3并安装,因为是tf1.9最新版本,所以支持python3.5及以上。
  2. 打开命令行窗口,创建conda环境 conda create -n tensorflow python=3.5
  3. 激活conda环境 activate tensorflow
  4. 发出相关命令以在conda环境中安装 TensorFlow-GPU版。请输入以下命令:(tensorflow)C:> pip install –ignore-installed –upgrade tensorflow-gpu

四,验证是否安装成功

验证TensorFlow安装是否成功,可以在命令行窗口输入python进入python环境,或者运行python3.5命令行后输入以下代码:

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

如果能正常输出hello字符串,则安装成功。如下图所示:

五,导入tensorflow ,提示警告信息的消除

tensorflow版本信息

tensorflow 1.19.0 
numpy 1.12.1

警告信息

导入tensorflow 时会出现的警告信息

FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.

解决办法

首先,只是一个警告信息,可以不用管,不影响使用,想去掉的话,网上有“强行”不显示警告信息的方法,也有不同的朋友导入不同库时报这个信息,解决的也有装不同库的办法,StackOverflow上看到一个比较有理有据的解决方案。

This might or might not be your case, but the same warning is also spit out from h5py package: 
/home/user/bin/conda3/lib/python3.6/site-packages/h5py/init.py:34: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters
For anyone coming here with this problem, it is a known h5py issue, introduced with numpy 1.14. As stated by the devs:
You can ignore the warning, it’s not going to cause any issues at the moment, but you should upgrade to the next release of h5py when it becomes available.
so it’s harmless. The fix has just been merged to master. But until the update is released, the workaround is to downgrade numpy to a previous version:

在cmd命令下输入以下代码,重新安装numpy1.13.0版本,解决了警告信息。

pip install numpy==1.13.0

就是说,这个问题是由于numpy1.15版本引入的警告信息,没有影响,在新版本更新之前,有效的方法是降级到numpy 1.13.0,试着安装numpy1.13.0,果然解决了问题。看来至少是保证 numpy 1.13 这个版本没问题,但是如果是其他tensorflow 版本的话,可能会要求其他相匹配版本的numpy了,这个需要注意下。总之安装tensorflow,安装相应依赖库和软件一定要主要相应版本匹配问题

六,参考资料

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

嵌入式视觉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值