Title: tensorflow installation

date: 2019-10-28 tags:

  • Anaconda
  • tensorflow

categories:

  • The gpu version
  • The CPU version

Configuration:

  • Windows 10
  • Nvidia independent graphics card

preface

  • Check whether your graphics card supports CUDA: click: http://www.nvidia.com/object/geforce_family.html

Step 1: Install Anaconda

1. Download

  • Download address: www.anaconda.com/download/

  • Choose the version that works with your system.

2. Install

  • Add the installation package directly

  • Do not check ** “Add Anaconda to my PATH enviroment variable” in this step, we will Add it manually later.

3. Configure environment variables

  • The advanced system Settings screen is displayed
  • Add the following three paths to the path variable (note that this is your own installation path).
C:\Users\t-yaoguo\AppData\Local\Continuum\anaconda3
C:\Users\t-yaoguo\AppData\Local\Continuum\anaconda3\Scripts
C:\Users\t-yaoguo\AppData\Local\Continuum\anaconda3\Library\bin
Copy the code

Then win+R open CMD and enter: conda -v If the version number can be displayed normally, the configuration is successful.

Step 2: Install TensorFlow

1. Create a Conda environment

Conda create -n tensorflow PIP python=3.7Copy the code

Replace the tutorial

2. Activate the environment

Then enter the command:

activate tensorflow
Copy the code

3. Install TensorFlow

Note: It must be installed in an active environment. Installing the GPU Version

pip install --ignore-installed --upgrade tensorflow-gpu 
Copy the code

Installing the CPU Version

pip install --ignore-installed --upgrade tensorflow
Copy the code

If the network timeout error occurs, you can use the following command:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu
Copy the code

The SAME goes for the CPU version

Since our new TensorFlow environment is mostly empty, we need to install some Anaconda packages as follows:

conda install anaconda
Copy the code

Step 3: Install CUDA Toolkit + cuDNN

1. Check the VERSION of CUDA+cuDNN to be installed

Click the check you install the latest TensorFlow support CUDA version: www.tensorflow.org/install/ins…

Note: The TensorFlow and CUDA versions must be compatible or the installation will fail. Comparison of TensorFlow and CUNA

2.CUDA+cuDNN download and install

Download link link: developer.nvidia.com/cuda-toolki…

Enter the Download page

Developer.nvidia.com/rdp/cudnn-a…

3. Install CUDA Toolkit and cuDnn

Install CUDA first. To avoid errors during installation, uninstall the installed graphics card driver before installing CUDN Toolkit.

Double-click the CUDA installation package to start the installation

C: Program Files\NVIDIA GPU Computing Toolkit\CUDA\ v9.0C: Program Files\NVIDIA GPU Computing Toolkit\CUDA\ v9.0bin C: Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\ Lib \x64 C: Program Files\NVIDIA GPU Computing The Toolkit \ CUDA \ v9.0 \ libnvvpCopy the code

Step 4: Test

1. Check whether the GPU is used (you can also check whether TensorFlow is successfully installed)

Win +R Enter CMD

Command: activate tensorflow

Input: Python

Input:

import tensorflow as tf
tf.test.gpu_device_name()
Copy the code

Note:

Description:

Versions after TensorFlow 1.0 are very different from TensorFlow 2.0. If your project uses TensorFlow 1.0, do not install TensorFlow 2.0 or your project will not work.

To install a specific version of TensorFlow, run the following command:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu==1.x.0
Copy the code

X: indicates the version number

If the required version number is not available, an error message will be sent back to you indicating which version is available for download.

Tensorflow history download address: pypi.org/project/ten…

Reference: www.cnblogs.com/guoyaohua/p…