Win-10 install TensorFlow-GPU
0x00. Reason
Q: Why write a (so low-level) configuration tutorial?
A: (Actually, it's not low-level;The online one is old; it's a headache when you see it compiling), in view of (perhaps) there will be many articles about TensorFlow
(fancy digging) in the future, it is necessary to introduce its installation method here
Q: TensorFlow
What is it?
A:TensorFlow is an Open Source Software Library for Machine Intelligence
An
Tensor
(tensors).Tensor
meansN
dimensional array,Flow
(flow) means computation based on a dataflow graph,TensorFlow
i.e. tensors flowing from one end of the graph to the other.
One of its highlights is the support for distributed computing of heterogeneous devices, which can automatically run models on various platforms, from phones, single to distributed systems consisting ofCPU/GPU
hundreds of thousands of cards. The support algorithm is currently the most popular deep neural network model.GPU
CNN、RNN和LSTM
Image、NLP
Q: Why study this?
A:
Deep learning usually means building large-scale neural networks with many layers.
In addition to the inputX
, the function takes a series of arguments, including scalar values, vectors, and most expensive matrices and higher-order tensors.
Before training the network, a cost function needs to be defined. Common cost functions include the variance of regression problems and the cross entropy during classification.
During training, it is necessary to continuously input multiple batches of new inputs into the network, and after derivation of all parameters, substitute the cost function to update the entire network model.
There are two main problems in this process: 1. The processing of multiplying large numbers or tensors together a million times makes the entire model very expensive. 2. Manual derivation takes a long time.
ThereforeTensorFlow
, the automatic derivation of functions and distributed computing can help us save a lot of time to train the model.
Q: What advantages does it have?
A:
1. Based on
python
, write fast and readable;
2.GPU
Run more smoothly on multiple systems;
3. Code compilation efficiency is high;
4. The community develops very quickly and actively;
5. Can generate display network A visualization of topology and performance.
0x01. Environment
a. Microsoft Windows [版本 10.0.15063](Win 10 x64 Pro 1703 15063.483)
b. Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] on win32
c. JetBrains Pycharm 2017.2 x64 Professional
d. GeForce GTX 965M
0x02. Install
1. Installationpython 36
All the way to the next step, you can tick the environment variable settings. Not recommended python 27
, because it doesn't seem to be supported, so the last step will be reportedCould not find a version that satisfies the requirement tensorflow-gpu (from versions: ) No matching distribution found for tensorflow-gpu
2. Change the pip
default source
The default source server is abroad, and the domestic download is slow, so it is necessary to change to the domestic Ali source.
For example
Win
, create a new file directly in the current user directorypip.ini
, for example: theC:\Users\yuangezhizao\pip.ini
content is as follows:
1 2 3 4 [global] index-url = http://mirrors.aliyun.com/pypi/simple/ [install] trusted-host=mirrors.aliyun.com
3. Upgradepip
py -2 -m pip install --upgrade pip
Since my computer has two versions installed, I use py -2 to select the interpreter of version 2. Similarly, py -3 is to select the interpreter of version 3.
TensorFlow
There are two versions: CPU
version and GPU
version.
If your computer does not have NVIDIA
a graphics card, you must choose to install this version, but the installation of this version is GPU
simpler than the version, and the official also recommends using CPU
the version to experience. TensorFlow
It GPU
is much faster to run CPU
on the above, and if you GPU
can meet the requirements, you can choose the installation GPU
version. GPU
The version needs CUDA
and cuDNN
support. To install the GPU
version, you need to confirm whether the graphics card supports CUDA
it, check whether the GPU supports CUDA3.5
, and the card with greater computing power N
generally supports it...
In addition, it is recommended to install on the Internet Anaconda
, because this integrates a lot of libraries necessary for scientific computing and can avoid many dependency problems. This Pycharm
party is uneasy first (in fact, I am installed, but it may be because I am used to it and feel Pycharm
uncomfortable)
4. Install CUDA
Windows
→ x86_64
→ 10
→ exe (local)
Download the following two files and install them in sequence: Base Installer Download (1.3 GB)
Patch 2 (Released Jun 26, 2017) Download (43.1 MB)
After the installation is complete, enter it on the command line nvcc -V
, and there will be a normal echo...
5. Install cuDNN
cuDNN
GPU
The speed can be roughly 1.5
doubled on the basis of the previous acceleration, which is also developed by the nVIDIA
developer. Register an account on the official website, download the cuDNN v6.0 Library for Windows 10
compressed package, unzip the installation directory to which the corresponding folder ( bin、include、lib
) will be overwritten , that is , then add the environment variable and rename the file in the folder to (here Refer to tensorflow/issues/7705 , in fact, replacing the old version can also solve stackoverflow , because the previous method is used because the reinstallation package is too large), it is completed. https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.0.5/prod/9.1_20171129/cudnn-9.1-windows10-x64-v7CUDA
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin
bin
cudnn64_6.dll
cudnn64_5.dll
http://developer2.download.nvidia.com/compute/machine-learning/cudnn/secure/v7.0.5/prod/9.1_20171129/cudnn-9.1-windows10-x64-v7.zip?ZLrypQyS9qaPi2V24ZffXps-WqZnYaTOsPUaA5O9BY-LV-bJlHkijvtQkvNn-SPFVTDbAGqc0UhtSt5e70qbF66G4mCzvo9BLs3-fAGYNo0afIsTeQ6YwVbARA1yzssWExLzEgOmFeGOv7AscZCeepaNlc3-OdFeUb2s72BF-dXNV8VQx_u7nc2vgWRQypNmFCTeTXZxo-FpoE-t
话说注册账号要求好麻烦,大小写包含特殊符号且不少于6位……
6. pip
Installation TensorFlow-GPU
(last step)
pip3 install --upgrade tensorflow-gpu
In case the online pip
installation fails, install it offline, go to the package downloaded from http://www.lfd.uci.edu/~gohlke/pythonlibs/ , and then run the command prompt (you can drag the file into the command prompt to generate its location)python
whl
tensorflow_gpu‑1.1.0‑cp36‑cp36m‑win_amd64.whl
pip install < 此处填写 .whl 所在位置 >
.whi
0x03. Test
1 2 3 4 5 6 7 |
#! python3 # coding: utf-8 import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello)) |
My output is longer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
C:\Python36\python.exe C:/Users/yuangezhizao/PycharmProjects/deeplearning/helloworld.py 2017-08-03 14:53:23.258570: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations. 2017-08-03 14:53:23.258819: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations. 2017-08-03 14:53:23.259063: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations. 2017-08-03 14:53:23.259307: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations. 2017-08-03 14:53:23.259552: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. 2017-08-03 14:53:23.259790: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. 2017-08-03 14:53:23.260028: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. 2017-08-03 14:53:23.260264: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. 2017-08-03 14:53:24.103495: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:940] Found device 0 with properties: name: GeForce GTX 965M major: 5 minor: 2 memoryClockRate (GHz) 0.9495 pciBusID 0000:01:00.0 Total memory: 2.00GiB Free memory: 1.64GiB 2017-08-03 14:53:24.103772: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:961] DMA: 0 2017-08-03 14:53:24.103900: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:971] 0: Y 2017-08-03 14:53:24.104045: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 965M, pci bus id: 0000:01:00.0) b'Hello, TensorFlow!' |
The reason why there is a red prompt here is because I didn't compile it locally, try to compile (it really won't...), so I restarted and entered Mac
... To be continued
0x04. Reference
http://www.jianshu.com/p/6766fbcd43b9
http://www.jianshu.com/p/c245d46d43f0
http://blog.csdn.net/u010099080/article/details/53418159
http://blog.csdn.net/wx7788250/article/details/60877166
http://www.cnblogs.com/leoking01/p/6913408.html
This article was created: August 3, 2017 10:25:03
The first update was: April 30, 2018 19:30:42
Reprint please indicate the source: https://www.yuangezhizao.cn/ articles/python/TensorFlow/install-tensorflow-gpu-on-Win-10.html