2025年2月24日 星期一 甲辰(龙)年 腊月廿四 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 系统应用 > Windows

win10+GTX1050Ti+anaconda3+tensorflow1.14.0+cuda10.0+cudnn7.6.1.34(带GPU使用检测)

时间:06-26来源:作者:点击数:23

首次安装win10下的GPU深度学习环境

1,首先安装anaconda

下载地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

此处我的版本是:anaconda3-5.0.1(python3.6.3)

2,创建虚拟环境

(之前在直接安装tensorflow中出现了安装失败的问题,然后在虚拟环境中问题解决)

  • C:\Users\Administrator>conda create -n myenv_python367 python=3.6.7
  • Fetching package metadata .....................
  • Solving package specifications: .
  • Package plan for installation in environment D:\Users\Administrator\Anaconda3\envs\myenv_python367:
  • The following NEW packages will be INSTALLED:
  • certifi: 2016.2.28-py36_0 http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  • pip: 9.0.1-py36_1 http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  • python: 3.6.7-h9f7ef89_2 http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  • setuptools: 36.4.0-py36_1 http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  • sqlite: 3.29.0-he774522_0 http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  • vc: 14.1-h0510ff6_4 http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  • vs2015_runtime: 14.15.26706-h3a45250_4 http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  • wheel: 0.29.0-py36_0 http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  • wincertstore: 0.2-py36_0 http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  • Proceed ([y]/n)? y
  • vs2015_runtime 100% |###############################| Time: 0:00:02 1.01 MB/s
  • vc-14.1-h0510f 100% |###############################| Time: 0:00:00 0.00 B/s
  • sqlite-3.29.0- 100% |###############################| Time: 0:00:00 1.13 MB/s
  • python-3.6.7-h 100% |###############################| Time: 0:00:14 1.46 MB/s
  • certifi-2016.2 100% |###############################| Time: 0:00:00 3.18 MB/s
  • wheel-0.29.0-p 100% |###############################| Time: 0:00:00 3.32 MB/s
  • wincertstore-0 100% |###############################| Time: 0:00:00 483.75 kB/s
  • setuptools-36. 100% |###############################| Time: 0:00:00 2.88 MB/s
  • pip-9.0.1-py36 100% |###############################| Time: 0:00:00 2.61 MB/s
  • #
  • # To activate this environment, use:
  • # > activate myenv_python367
  • #
  • # To deactivate an active environment, use:
  • # > deactivate
  • #
  • # * for power-users using bash, you must source
  • #
  • C:\Users\Administrator>activate myenv_python367

3,安装tensorflow

(1)CPU下的:

  • pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade tensorflow

(2)GPU下的:

  • pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade tensorflow-gpu

(3) 测试,tensorflow 出现问题:

  • python
  • import tensorflow as tf

ImportError: Could not find ‘cudart64_100.dll’. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 10.0 from this URL: https://developer.nvidia.com/cuda-90-download-archive

此处解决方案,是找到满足tf1.14对应版本的cuda

在这里插入图片描述

4,下载安装cuda10

环境下载:链接:https://pan.baidu.com/s/12ge9p3lrH-_PL5octX012g

提取码:w9t6

此处参考连接:https://www.cdsy.xyz/computer/programme/artificial_intelligence/240626/cd61960.html

(1)下载在官网:

https://developer.nvidia.com/cuda-10.0-download-archive?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal

在这里插入图片描述

(2)安装:

选择自定义安装:

在这里插入图片描述

如图中所示,去掉VS

在这里插入图片描述

(3)设置路径(根据自己安装路径设置,加入到系统环境路径Path中):

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\include

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\lib\x64

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\extras\ CUPTI\libx64

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\lib

5,安装cudnn-10.0-windows10-x64-v7.6.1.34

只需要将下载后的文件中的dll,放到对应文件夹下即可

在这里插入图片描述

放入下面文件夹即可:

在这里插入图片描述
在这里插入图片描述

6重启电脑,测试成功

  • Microsoft Windows [版本 10.0.17134.885]
  • (c) 2018 Microsoft Corporation。保留所有权利。
  • C:\Users\Administrator>python
  • Python 3.6.3 |Anaconda, Inc.| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)] on win32
  • Type "help", "copyright", "credits" or "license" for more information.
  • >>> import tensorflow as tf
  • >>> sees=tf.Session()
  • 2019-07-18 14:41:52.946173: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library nvcuda.dll
  • 2019-07-18 14:41:53.179001: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties:
  • name: GeForce GTX 1050 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.62
  • pciBusID: 0000:01:00.0
  • 2019-07-18 14:41:53.187423: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check.
  • 2019-07-18 14:41:53.201099: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0
  • 2019-07-18 14:41:53.206420: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
  • 2019-07-18 14:41:53.219906: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties:
  • name: GeForce GTX 1050 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.62
  • pciBusID: 0000:01:00.0
  • 2019-07-18 14:41:53.229929: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check.
  • 2019-07-18 14:41:53.246158: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0
  • 2019-07-18 14:41:54.155172: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1181] Device interconnect StreamExecutor with strength 1 edge matrix:
  • 2019-07-18 14:41:54.160876: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1187] 0
  • 2019-07-18 14:41:54.163470: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1200] 0: N
  • 2019-07-18 14:41:54.176098: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1326] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 3001 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1050 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)
  • >>> a=tf.constant(10)
  • >>> b=tf.constant(20)
  • >>> sess.run(a+b)
  • Traceback (most recent call last):
  • File "<stdin>", line 1, in <module>
  • NameError: name 'sess' is not defined
  • >>> sees.run(a+b)
  • 30
  • >>>

6.1其他调试方法:(这个是在tensorflow1.14虚拟环境下实现的)

参考链接:https://www.cdsy.xyz/computer/programme/artificial_intelligence/240626/cd61959.html

  • C:\Users\Administrator>activate tensorflow1.14
  • (tensorflow1.14) C:\Users\Administrator>python
  • Python 3.6.7 |Anaconda, Inc.| (default, Dec 10 2018, 20:35:02) [MSC v.1915 64 bit (AMD64)] on win32
  • Type "help", "copyright", "credits" or "license" for more information.
  • >>>
  • >>> import tensorflow
  • >>> from tensorflow.python.client import device_lib
  • >>> print(device_lib.list_local_devices())
  • 2019-07-21 09:59:39.657281: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
  • 2019-07-21 09:59:39.661258: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library nvcuda.dll
  • 2019-07-21 09:59:40.617377: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties:
  • name: GeForce GTX 1050 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.62
  • pciBusID: 0000:01:00.0
  • 2019-07-21 09:59:40.621751: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check.
  • 2019-07-21 09:59:40.629822: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0
  • 2019-07-21 09:59:41.207582: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1181] Device interconnect StreamExecutor with strength 1 edge matrix:
  • 2019-07-21 09:59:41.210105: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1187] 0
  • 2019-07-21 09:59:41.211590: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1200] 0: N
  • 2019-07-21 09:59:41.220506: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1326] Created TensorFlow device (/device:GPU:0 with 3001 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1050 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)
  • [name: "/device:CPU:0"
  • device_type: "CPU"
  • memory_limit: 268435456
  • locality {
  • }
  • incarnation: 17227910178020249398
  • , name: "/device:GPU:0"
  • device_type: "GPU"
  • memory_limit: 3146829004
  • locality {
  • bus_id: 1
  • links {
  • }
  • }
  • incarnation: 13565572337421704331
  • physical_device_desc: "device: 0, name: GeForce GTX 1050 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1"
  • ]
  • >>>
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门