Win10 TensorFlow (GPU) installation detailed

Source: Internet
Author: User
Tags jupyter jupyter notebook

Win10 TensorFlow (GPU) installation detailed

Written in front: TensorFlow is Google's second generation of AI learning systems based on Distbelief, and its naming comes from its own operating principles. Tensor (tensor) means that n-dimensional arrays, flow (flow) means that based on the calculation of the flow graph, the TensorFlow is the calculation process of the tensor from one end of the image to the other. TensorFlow is a system that transmits complex data structures to an artificial neural network for analysis and processing. The project has harvested 40000+ 's star and 18000+ 's fork in a little more than a year since open source last November, which is a demonstration of its heat. TensorFlow's community and documentation are well-established and therefore popular with everyone.

Previously TensorFlow only supported Ubuntu/linux and Mac OS X, and it was easier to install. The first two heavenly communities found that there is already a Windows version, decisive to install a try, this article mainly records WIN10 under the installation of Tensoflow trampled pits.

TensorFlow Official Installation Tutorials
TensorFlow Chinese Community

1. Installation environment (multiple versions of Python management)

TensorFlow currently supports only 64-bit Python 3.5 under Windows, because it has been using Python 2.7 (Anaconda2) +jupyter notebook, and does not want to switch directly to Python 3.5, So prepare to install two versions of Anaconda. Here is the main introduction to how to manage the use of different versions of Python, if you have to use the Python 3.5 of this chapter directly skipped.

Anaconda Download Installation: Window installation is very simple, run the installation package directly next step, the installation process will have a choice to tick the place, the first is to add environment variables, the second is to set anaconda under the Python as the default version, here are the suggestions are checked.


Know Anaconda should all know can use Conda environment to manage different versions of Python, such as I am now installed Anaconda2, the default Python version is 2.7, but I want to use Python 3, this time can be used to create an environment with Conda, In this environment, you can install and run the version you want, and then exit the environment when you are done. The default Python version of the system is still 2.7.

Here's how to deal with it in detail:

(1). Create an environment named Python35, specifying that the Python version is 3.5
Open cmd:conda create --name python35 python=3.5

(2). After the installation is complete, use activate to activate the Python35
activate python35the input can be seen in front of the command line line (PYTHON35), this is the current operating environment
Then run python to see the Python version shown as 3.5.2

(3). If you want to return to the default Python 2.7 environment, first quit Python and then rundeactivate python35

Run python , the Python version is 2.7.12, the front of the command line (PYTHON35) is missing, indicating that the PYTHON35 environment has been exited.

Isn't it convenient? Below the installation path to see below, you can see the ANACONDA2 installation path under the Envs python35 this folder, every time we activate the environment, the system operating environment is under the folder. (The other two are new ones I built later)

Here is actually ready to install the environment, but I used to jupyter notebook, if I now run Anaconda notebook or only Python 2.7.12 version, if you want to use the same as I do jupyter Notebook continues to look down.

Now that you can install Python 3.5 in a new environment, how about installing a Anaconda3 in this environment, and then installing the Python 3.5 jupyter notebook and the Spyder, try it, sure! (Read the comments found this method can not, and now not often on the csdn, passing by the small partners have a solution also wide to share out ...
I didn't have a problem with this outfit last year. I just tried it, and I really can't. Then I tried the other way:
1.conda create–name Test python=3.6
2.activate Test
3.pip Install Jupyter/spyder
4.jupyter Notebook
It's also possible. )

(1). Conda Create a new ANACONDA3 environment
conda create --name Anaconda3
After success, create a new ANACONDA3 environment under the Envs folder under Anaconda2
(2). Then download the ANACONDA3 installation package from the Anaconda website and install
In the installation of attention to the installation path is selected as E:\Anaconda2\envs\Anaconda3 (that is, the newly created Conda environment), in addition to note in the hook interface, two do not tick, and then the normal installation of the end of the line.

(3). After the installation is complete, activate the ANACONDA3 environment, run, python jupyter notebook and finish.

2. TensorFlow Installation

Complete the above python3.5 installation is very simple, direct PIP installation on the line.

Activate the ANACONDA3 environment first: activate Anaconda3
Note: If the video card is low and GPU acceleration is not supported, install the CPU version, this article installs the GPU version

Input: pip install tensorflow-gpu Install, if prompted PIP version issue, follow the prompts to update to the latest version can be.

Installation is complete.
This time, although TensorFlow has been installed, we also need to install Cuda and CUDNN (accelerated libraries specifically for deep learning) because of the need for GPU acceleration.

3. Cuda Installation

(1). Cuda v8.0 installation package download, as well as installation guide and so on, a little look at the line.

According to their own environment to choose the corresponding version, EXE divided into the network and local version, the network version of the installation package is relatively small, the installation of the time to download the required package; The local version of the installation package is a direct download of the full installation package. It is recommended to download the local version (network version I tried to install one night failed ...) ), it is also recommended to use Win10 's own edge browser to download, faster than Google what is much faster.

Download it and install it properly.

(2). CUDNN Library Download

Download this installation package needs to register and fill out a bunch of questionnaires, the next time the relevant packages do not install, directly to the CUDA path corresponding to the folder below the line (said later).

(3). Cuda Test
Cuda installation will automatically download some example, run tests on their own, the problem is not big.

(4). Key Pit (running TensorFlow)
When I am ready to set up a wave of cars, come out with all kinds of mistakes, as the young old driver I talk about experience. TensorFlow is a programming system that uses diagrams to represent computational tasks that must be started in a session. The session distributes the OP (operation) of the diagram to a device such as a CPU or GPU. So, this time you run Python and then you won't get an import tensorflow as tf error, but you might have a problem when you do tf.Session() . This time the Cuda will be called, and the problem I am encountering here is that various lib,dll cannot be loaded. After some inspection, locate the problem, CUDA installation after the default environment variable configuration is not correct, Cuda_path is C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0 , but this does not directly access to the bin and lib\x64 under the package, in path to add these two paths.

Another wave of cars, the result is still a problem ... There is a library can not be loaded, is the above CUDNN library, very simple, decompression just down the installation package, the three folders under the files copied to cuda corresponding folder can be.

That's it.

4.TensorFlow Test

(1). Code test:

import tensorflow as tf

hello = tf.constant(‘Hello, TensorFlow!‘)sess = tf.Session()
    • 1
    • 2
    • 3

(2). Official Tutorial Code test:

The TensorFlow Implement
ation translates the graph definition into executable operations distributed across available compute resources, such as t He CPU or one of your computer ' s GPU cards. Specify CPUs or GPUs explicitly. TensorFlow uses your first GPU, if you had one, for as many operations as possible.

#Creates a graph.a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name=‘a‘)b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name=‘b‘)c = tf.matmul(a, b)#Creates a session with log_device_placement set to True.sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))#Runs the op.print sess.run(c)

Output:

Device mapping:/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: Tesla K40c, pci busid: 0000:05:00.0b: /job:localhost/replica:0/task:0/gpu:0a: /job:localhost/replica:0/task:0/gpu:0MatMul: /job:localhost/replica:0/task:0/gpu:0[[ 22.  28.] [ 49.  64.]]


(2). Example Test

Download the TensorFlow source on GitHub with a lot of sample code

Run Example:

python mnist_with_summaries.py..............................

The results just started to stall ...couldn‘t open CUDA library cupti64_80.dll

Check, this DLL in NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\CUPTI\libx64 , because this also did not add to the system variables, simple processing, the inside of the file is also copied to the environment variable bin folder.

Start again, finally happy run up.

Finally, I want to look at the GPU situation and find this: NVIDIA System Management Interface
In fact, C:\Program Files\NVIDIA Corporation\NVSMI\nvidia-smi under the installation path already has
How to operate, still in the exploration ...

5. Finish

The usual, recommend some good information.

TensorFlow official tutorials, as well as the Chinese community, the beginning of the article has been linked.

Good to know the column: Https://zhuanlan.zhihu.com/hsmyy

Hiton's Course: https://www.coursera.org/learn/neural-networks/home

Other relatively hot deep learning frame: Keras, mxnet ...

Finally, the installation process is also concerned about Docker, really a black technology! And so play well in the PO tutorial come up.

Win10 TensorFlow (GPU) installation detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.