tensorflow-gpu1.14 + Win10 + CUDA10.0 + CUDNN7.5.0 + Python3.6 + VS2015安装

最近学习深度学习,在配置环境中的过程中遇到很多问题,在这进行总结,希望对大家有帮助。

一、整个软件安装配置过程,很多博客写的很详细,附上链接;

  1. https://blog.csdn.net/qq_36026791/article/details/88793488
  2. https://blog.csdn.net/huanyingzhizai/article/details/89298964

二、安装完成后测试如下;

  1. 整个tensorflow测试过程
    (base) C:\Users\Wang>activate tensorflow--gpu//激活tensorflow环境
    
    (tensorflow--gpu) C:\Users\Wang>python
    Python 3.6.10 |Anaconda, Inc.| (default, Jan  7 2020, 15:18:16) [MSC v.1916 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from tensorflow.python.client import device-lib
      File "<stdin>", line 1
        from tensorflow.python.client import device-lib
                                                   ^
    SyntaxError: invalid syntax
    >>> from tensorflow.python.client import device_lib
    >>> print(device_lib.list_local_devices())
    2020-03-08 09:44:53.011007: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
    2020-03-08 09:44:53.892132: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties:
    name: GeForce MX150 major: 6 minor: 1 memoryClockRate(GHz): 1.0375
    pciBusID: 0000:01:00.0
    totalMemory: 2.00GiB freeMemory: 1.62GiB
    2020-03-08 09:44:53.914731: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0
    2020-03-08 09:44:55.706053: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix:
    2020-03-08 09:44:55.722874: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990]      0
    2020-03-08 09:44:55.731764: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0:   N
    2020-03-08 09:44:55.746369: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/device:GPU:0 with 1364 MB memory) -> physical GPU (device: 0, name: GeForce MX150, pci bus id: 0000:01:00.0, compute capability: 6.1)
    [name: "/device:CPU:0"
    device_type: "CPU"       //抓到CPU
    memory_limit: 268435456
    locality {
    }
    incarnation: 17524159819158732381
    , name: "/device:GPU:0"
    device_type: "GPU"     //抓到GPU
    memory_limit: 1431112499
    locality {
      bus_id: 1
      links {
      }
    }
    incarnation: 5191225488240913321
    physical_device_desc: "device: 0, name: GeForce MX150, pci bus id: 0000:01:00.0, compute capability: 6.1"
    ]
    >>> import tensorflow as tf
    >>> gjm = tf.constant("Hello World ! I love TensorFlow ! ")
    >>> sess = tf.Session()
    2020-03-08 09:46:10.621388: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0
    2020-03-08 09:46:11.108336: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix:
    2020-03-08 09:46:11.124001: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990]      0
    2020-03-08 09:46:11.133490: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0:   N
    2020-03-08 09:46:11.264295: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1364 MB memory) -> physical GPU (device: 0, name: GeForce MX150, pci bus id: 0000:01:00.0, compute capability: 6.1)
    >>> print (sess.run(gjm))
    2020-03-08 09:46:44.969417: E tensorflow/core/grappler/clusters/utils.cc:83] Failed to get device properties, error code: 30
    b'Hello World ! I love TensorFlow ! '    //输出
    >>> sess.close()
    >>>

     

  2. 查看cuda是否安装成功
  3. 其他过程参见链接博客

、遇到的几个问题;

  1. 首先是在安装过程中,python、tensorflow、Cuda版本的对应,这里我的版本如下python3.6(在安装Anaconda3时候自带为python3.7,这里在Anaconda Prompt里执行降版本,降为3.6即可)、tensorflow1.14rc0、Cuda 10.0。如果版本有问题,不兼容,后面测试会一直报错。
  2. Cuda 10.0安装完成后,一定要配置环境变量,具体如下:检查一下环境变量 我的电脑—> 属性—> 高级系统设置—> 环境变量—>系统变量      


    确认环境变量,CUDA_PATH和CUDA_PATH_V10已经存在

    依此添加下列三个路径到Path里
    C:\NVIDIA\CUDAv10.1\bin
    C:\NVIDIA\CUDAv10.1\include
    C:\NVIDIA\CUDAv10.1\lib\x64
    否则在Windows CMD命令窗口执行 nvcc -V 的时候,会发生错误,查不到Cuda版本信息,并且在后续测试Tensorflow的时候,会发生如下错误找不到指定模块

  3. 安装tensorflow,如果直接使用镜像,下载速度非常慢,而且容易出现错误。这里推荐使用清华镜像pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu==1.14.0rc0
  4. 还有一点,在安装完tensorflow后,一般会同时安装numpy,但是自带的numpy版本过高,会出现以下错误

这里对numpy进行降版本操作就行。

就是先卸载原来的numpy     pip uninstall numpy 然后用清华镜像重新安装pip install -i https://pypi.tuna.tainghua.edu.cn/simple numpy==1.16.0

以上是我遇到的一些问题及坑的解决方法,欢迎大家参考,有问题留言交流。

 

 

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值