win10+GTX1050Ti+anaconda3+tensorflow1.14.0+cuda10.0+cudnn7.6.1.34(帶GPU使用檢測)

首次安裝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
解決連接:https://blog.csdn.net/qq_30622831/article/details/81751159

在這裏插入圖片描述

4,下載安裝cuda10

環境下載:鏈接:https://pan.baidu.com/s/12ge9p3lrH-_PL5octX012g
提取碼:w9t6

此處參考連接:https://blog.csdn.net/aaa_aaa1sdf/article/details/80756424?tdsourcetag=s_pcqq_aiomsg

(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://blog.csdn.net/sinat_33486980/article/details/92806775

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"
]
>>>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章