AI = > tensorflow2.0 (win10 & beta & GPU version) installation

Time:2019-12-2

Preface

If the python & CUDA & cudnn & video card & tensorflow version doesn’t match well, it may get stuck..
This article describes the whole installation process and the pit I stepped on.

Environmental recommendation

I didn’t do it all at once. When tf-13rc came out, it took a long time.
To mention a little, python 3.7 on the homepage of Python official website is Win32.
I’ve been reinstalling the system and downloading it. It took a long time to discover that it was 32-bit….
Tensorflow must be win 64 bit. (input Python under the terminal to see how many bits of XX bit it is)
Note: the installation path is in English!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

The final successful supporting version is as follows:

win10
Gtx1050 (other models, not guaranteed, should be similar)
Python 3.7 (I don't think the python problem is particularly big. Recommendation 3.7)
cuda:     cuda_10.0.130_411.31_win10
cudnn:    cudnn-10.0-windows10-x64-v7.4.2.24
tensorflow-gpu==2.0.0-beta0

Resource sharing (Baidu net)

Resource composition: CUDA + cudnn + 4 VC environments
My online disk: https://pan.baidu.com/s/1z6ha
Extraction code: 2qut

Don’t mess around after downloading. See the following tutorial installation in order. Dependent.

Install CUDA

Official chain: https://developer.nvidia.com /… (if you don’t want to use my toolkit, you can use CUDA official chain by yourself)

If you go to install CUDA directly, you may be prompted that you need to rely on vs201 + environment.
In fact, we don’t need to install the large volume of VS, but install the VC redist plug-in.

Installation:

  1. You can see that among the resources I share, there are 4 VC “redists.
    Download it, leak proof, and install it from top to bottom. (instant installation is fast. If you are prompted that it has been installed, don’t worry. Install all)
  2. Then install CUDA, double-click install (select thin version) (remember the installation path, I remember it seems to be the default automatic path, forget)
  3. Next step along the way, you can install successfully

Configuration:

1. The default path for automatic installation is as follows: (if you choose a custom installation, you should remember your path)
   C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin
2. Configure this path to the environment variable 
3. Turn off all CMD, reopen CMD, and input nvcc - V
4. No error indicates that the installation is successful.

Install CUDNN

Official chain: https://developer.nvidia.com /… (if you don’t want to use my toolkit, you can use the official chain by yourself)
(it seems that cudnn needs to be logged in under the official website)

Operation:

  1. You can see that cudnn is one of the resources I share. Download it and unzip it (any location is OK, just remember it).
  2. After unzipping, enter the unzipping directory, you will see a CUDA directory, go in! Then do the following operations!!!
    2.1. Enter the bin directory, copy the files (there should be one) to the

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

    2.2 enter the include directory, copy the files (there should be one) to the

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

    2.3 enter the Lib directory, and then continue to enter the x64 directory. Copy the files (there should be only one) to the

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

    Say: the above 3 paths, install CUDA mentioned (the simplified version of the default path, you and I are exactly the same, copy directly).

  3. Add this path to the environment variable (it is also the default path, which can be copied directly and matched):

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

Install tensorflow

Everyone has their own habits. It is recommended to use virtual environment to install things. I am more proficient in virtualenv + virtualenvwrapper win
Of course, it’s OK for you to pretend directly.

Install tensorflow GPU = = 2.0.0-beta0:

pip install tensorflow-gpu==2.0.0-beta0  -i http://pypi.douban.com/simple/  --trusted-host pypi.douban.com

If you are Anaconda (you need to open Anaconda prompt PIP first) (Science):

pip install tensorflow-gpu==2.0.0-beta0  

Install Matplotlib (it’s not necessary, but it’s something you can’t do without, just install it)

pip install scipy matplotlib pandas sklearn -i http://pypi.douban.com/simple/  --trusted-host pypi.douban.com

At this point, the installation is complete, and the next test.

Test installation & test for GPU

import tensorflow as tf

print(tf.__version__)
print(tf.test.gpu_device_name())

Just three lines of code. See the print result:

2.0.0-beta0 - this is the version information
/The word device: GPU: 0 ා GPU indicates that GPU can be used.

The struggle of obsessive-compulsive disorder

When executing the above code test, I have a large number of warnings here. Warning about data types. It doesn’t really hurt.
No, it’s very hurt. I went to GitHub to find it. In fact, your numpy version is too new. It’s OK to replace it with a version less than 1.17.
CMD can directly run the following command:

pip uninstall -y numpy && pip install numpy==1.16.4

OCD helper link: https://github.com/tensorflow

Concluding remarks

I bought my machine a while ago. It’s gtx1050. Everyone’s appearance is different.
So maybe the matching version I give can’t meet everyone’s needs.
Let’s talk about the problems I encountered in the previous installation:

  1. Remember to install as many paths as possible in English.
  2. CUDA can’t be installed because of the lack of vs201 +, (as I said above, install the four VC redist small files I share instead of installing VS)
  3. If you are prompted when you install tensorflow, the module is not found:
    3.1 maybe your Python and pip versions are too low
    3.2 maybe your Python is 32-bit. (don’t be lazy to install Python 3.7 of the home page, which is 32-bit. Must use 64 bit)
  4. When you install tensorflow or import tensorflow, you will get a lot of errors:
    4.0 first see if you can understand the error
    4.1 may be the matching version I gave. It’s not enough for your machine. Then you have to find the corresponding version yourself
    4.2 when I got it, I remember that there was a comparison table of NVIDIA & CUDA & cudnn. Forget to record. You can find it yourself.