Python- deep learning - learning Notes (9): TensorFlow GPU version installed in win7 environment

Python- deep learning - learning Notes (9): TensorFlow GPU version installed in win7 environment

Tip: Here is the GPU tensorflow installation, if you want to install the CPU, please refer to the link below.

https://blog.csdn.net/cs_hnu_scw/article/details/79695347

Tensorflow before performing the installation, we first need to know the required environment configurations.

1.Anaconda: Installation TensorFlow must install Python, Python and install the most convenient way is to use software packages to install, and install anaconda package will also help us to install a lot of software packages, such as Numpy, Jupyter Notebook, Scipy, Matplotlib , Pandas and so on.
2.CUDA: CUDA (Compute Unified Device Architecture) , is the introduction of the NVIDIA graphics card makers computing platform. CUDA ™ is a launch of NVIDIA's general purpose parallel computing architecture that enable GPU to solve complex computational problems. It contains CUDA instruction set architecture (ISA) and the interior of the GPU parallel computing engine.
3.cuDNN: NVIDIA cuDNN is GPU-accelerated library for deep neural network.
CUDA is regarded as a table, with the above there are many tools, such as hammers, screwdrivers and the like. cuDNN is CUDA-based GPU-accelerated deep learning library with it in order to complete the calculation depth study on the GPU.
4.TensorFlow: TensorFlow is a dataflow programming (dataflow programming) system based on mathematical symbols, it is widely used in various types of machine learning (machine learning) programming algorithm.
Here Insert Picture Description
-----------------------------------------------
environment : win7
Anaconda : Anaconda3-2018.12-Windows-x86_64
CUDA : cuda_9.0.176_windows
cudnn : cudnn-9.0-Windows7-x64-v7.4.1.5
Python : 3.6.0
TensorFlow : 1.7.0
---------- -------------------------------------

The following installation:

1, the installation CUDA:

https://developer.nvidia.com/cuda-90-download-archive?target_os=Windows&target_arch=x86_64&target_version=7

After entering the link above, download the following two exe files.
Here Insert Picture Description

After downloading the two exe files were installed. (Note Before installation before sure to uninstall old NVIDIA clean) Here Insert Picture Description
installation is complete.
Here Insert Picture Description
2, installation cuDNN:

https://developer.nvidia.com/rdp/cudnn-archive

Find the link corresponding to your version of cuDNN, and download, the download is complete package is a form of compression.
Here Insert Picture Description
Decompress it, and replace the three following documents folder to C: \ Program Files \ NVIDIA GPU Computing Toolkit \ CUDA \ v9.0 ( This directory is my cuda8.0 installation directory).
Here Insert Picture Description
You can see if there cudnn class file name appears by tapping into the new bin file, to check whether or not the replacement.
Here Insert Picture Description
3, installation anaconda3:
opening the exe file anaconda3, has been the next step, which this step requires two all points.
Anaconda above is added to the PATH environment variable.
Here is the Anaconda registered as the default Python.
Here Insert Picture Description
After installation, we enter conda environment.
Here Insert Picture Description
Enter the following command and enter y when prompted.

conda create --name python36 python==3.6

The installation is complete.
Here Insert Picture Description

4, installation tensorflow:
Enter the command: activate python36 python3.6 into the virtual environment.
Here Insert Picture Description
Enter tensorflow download command:

pip install tensorflow-gpu==1.7.0

GPU版
pip install tensorflow==1.7.0
CPU版

Check the following:

1. Check the environment:

conda info --envs

Here Insert Picture Description
2. Check whether the installation was successful CUDA:
Enter your address CUDA position, and change directories to be here, check the two files.

cd C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\extras\demo_suite>bandwidthTest

Here Insert Picture Description

cd C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\extras\demo_suite>deviceQuery.exe

Here Insert Picture Description
3, check whether the installation was successful tensorflow:
into your virtual environment in python, import tensorflow, if anything does not appear, but the next line appears ">>>", the installation was successful.
Here Insert Picture Description
4, tensorflow check whether the GPU version:
To obtain your operations and Tensor assigned to run on which devices, with log_device_placement create a new session, and is set to True.

Running a matrix multiplication:

import tensorflow as tf
# 新建一个 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)
# 新建session with log_device_placement并设置为True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# 运行这个 op.
print (sess.run(c))
#任务完成 关闭会话
sess.close()

Finally showed GPU participation.
Here Insert Picture Description

To summarize: This short it means you download a virtual environment of Anaconda, this environment is the default with python3.7, and you use tensorflow if this version is relatively high, so you need to download a virtual python3.6 environment (above become python36), in this environment, you download a version of tensorflow1.7.0 (refer to the specific version follows), so when you use tensorflow, you need to enter the virtual environment python3.6 in ( activate python36), and then proceeds to the python (python3.6 python36 in this environment), and then introduced into tensorflow (import tensorflow as tf) can be used.

Finally, fill the pit stages:

1, and finally import tensorflow, the following problems:ImportError: DLL load failed.
Here Insert Picture Description
Protobuf 3.6.0 can be replaced.

pip install protobuf==3.6.0

2, after downloading tensorflow appear:Requirement already satisfied.
Tensorflow that you have installed this package, either uninstall the old re-install a new, or do not need to continue with the installation.

3, error: FutureWarning: Conversion of the second argument of issubdtype from float

pip install h5py==2.8.0rc1

4, error:distributed 1.21.8 requires msgpack, which is not installed.

pip install msgpack-python
pip install msgpack

5, download the whole mess, trying toEmpty EnvironmentBack to:

conda remove -n envs_name --all

6, after installing tensorflow == No module named 'tensorflow' == problem
switch to your download tensorflow environment (I was activate python36). Or else you are not active, enter:

activate tensorflow

Finally, attach the version table:

Be sure to download the version corresponding to the good times, otherwise all have to be deleted again.
https://tensorflow.google.cn/install/source_windows

Published 55 original articles · won praise 76 · views 20000 +

Guess you like

Origin blog.csdn.net/qq_42826337/article/details/88301239