Tensorflow 2.3.0-GPU download and installation tutorial under Windows

Tensorflow 2.3.0-GPU download and installation tutorial under Windows

note:

To install TensorFlow-GPU, you need to confirm that there is at least one NVIDIA GPU on the machine. If you already have one, you first need to install the NVIDIA frameworks cuda and cudnn to take advantage of the powerful computing capabilities of the GPU.

View computer NVIDIA information

1. Right-click on the desktop> NVIDIA Control Panel
Insert picture description here
2. Click Help> System Information on the upper menu bar
Insert picture description here
3. Click on the component to view NVIDIA related information

One, install visual studio 2019

After finding the NVIDIA information of your computer, you first need to install vs2019, because you need to compile the cuda source code with a c++ compiler that supports the Windows operating system during the installation of cuda.

(1) Download vs2019

VS official website: VS official website
Insert picture description here
Select download from the menu bar:
Insert picture description here
select the free version of the community community to download.

(1) Install vs2019

After downloading, double-click the exe program to install:
Insert picture description here
click Continue to start the installation preparations:
Insert picture description here
after the preparations are over, the installation selection interface will pop up:
Insert picture description here

C++ is required. Because a C++ compiler is required to compile the cuda source code, the option "Desktop development using C++" must be selected.

Then start the installation:
Insert picture description here
wait for the installation to complete, restart the computer according to the prompts, and the vs2019 installation is complete.
Insert picture description here
After restarting, the first time you open vs2019, you will be asked to register. You can register for a Microsoft account and log in for free, or you can "talk about it later".

Then enter the option interface:
Insert picture description here
select and start vs2019:
Insert picture description here
Insert picture description here
if there is no error prompt, it proves that vs2019 has been installed correctly.

Two, install cuda

(1) Download the cuda installer

The NVIDIAcuda installation program can be found on the
NVIDIA official website link: NVIDIA official website link
Insert picture description here
click to download
Insert picture description here
According to my NVIDIA version information, I choose the Windows version cuda11.0 download:
click Windows->x86-64->10->exe in turn (local)
Insert picture description here
Cuda download interface, where base installer is the core installation package of the cuda program

(2) Install auda

Double-click to execute the downloaded base installer (cuda_11.0.3_451.82_win10.exe) file:
Insert picture description here
select the extraction file path: the
Insert picture description here
default path generated based on the user name is displayed in the extraction path box, and the default path can be used by long, please try Use the default path, and then you may get an error. After specifying the path, click OK to start extracting the file path.
Insert picture description here
After the extraction is complete, the installation program is launched and the system compatibility check is performed:
Insert picture description here
Since the vs2019 is pre-installed and GPU hardware is available, it can pass smoothly.
After the check is passed, you will enter the "NVIDIA Software License Agreement" interface.
Insert picture description here
Select "Agree and Continue" to enter the "Installation Options" interface:
Insert picture description here
generally select the simplified mode to meet the needs of training neural networks, and then the next step.

Insert picture description here
Wait patiently for the installation to complete. The
Insert picture description here
Insert picture description here
installation is successful. Picture:
Insert picture description here
Login/register NVIDIA account

(3) Check the installation of cuda

NVIDIA cuda will automatically add environment variables to the system. After the installation is complete, you need to make the newly added environment variables take effect to check the installation.
There are two ways to make environment variables take effect:
① Restart the computer
② For win10 system, enter "cmd" in the search function next to the start menu and
Insert picture description here
select "Run as administrator".
Insert picture description here
This step is to ensure that the system can reload the environment variables so that The new environment variable takes effect.

After manually loading environment variables or restarting and loading environment variables, you can check the installation of cuda:
enter the command: nvcc -V
Insert picture description here
will print out the information of the installed cuda, indicating that the cuda installation is complete.

Three, install cudnn'

(1) Download cudnn'

Enter NVIDIA's official website interface and download the cuDNN corresponding to cuda:
Official website link: Official website link
Cudnn download link: Cudnn download link
Insert picture description here
Click download
Insert picture description here
to log in or register (free) to
Insert picture description here
download the compressed package:
Insert picture description here

(2) Install cudnn

Unzip the compressed package:
Insert picture description here
copy all the files in the cuda folder to the cuda installation directory, overwrite the original files, and then you can successfully install cudnn.
The cuda installation directory can be found in the system environment variables:
Insert picture description here
Cuda-path is cuda Installation directory.

Fourth, install python

(1) Check the python installation. It
Insert picture description here
can be seen that the python version I installed is python3.7.4.
If python is not installed, you can check the relevant installation tutorial yourself , which is omitted here.

Five, install anaconda

(1) Check whether anaconda is installed
Open the terminal (win+R->enter cmd) and enter conda –version in cmd.
Insert picture description here
If anaconda is not installed, you can check the relevant installation tutorial by yourself , which is omitted here.

(2) Check the installed environment

Enter conda info ---envs in cmd.
Insert picture description here
If no other environment is created, there is only one default root/base environment in anaconda.

(3) Create a python3.7.4 environment

conda create --name tensorflow python=3.7.4
Insert picture description here
If the above warning appears: don’t panic, just follow the prompts to enter it, continue to enter:
conda update -n base -c defaults conda, upgrade anaconda
Insert picture description here
in the generated "Proceed( [y]/n)?” Under the question, enter y to continue the configuration process. If an error still occurs, repeat the input: conda
create -n py36 python=3.6; sooner or later it will appear: Solving environment: done. It
Insert picture description here
can be seen that the anaconda at this time is already 4.8.4 The latest version.
At this point, continue to create a virtual environment named tensorflow python3.7.4 environment: conda create --name tensorflow
python=3.7.4; under the question of "Proceed([y]/n)?" generated, enter y to continue configuration process.

(4) Activate the new environment

conda activate tensorflow
Insert picture description here
view the installed environment and
Insert picture description here
found that in addition to the original default root environment, there is one more tensorflow.
The (tensorflow) on the left represents entering the new virtual environment, here is tensorflow.

(5) Exit the current environment first

The Deactivate
Insert picture description here
environment name ((tensorflow) on the left) is gone, indicating that it has been exited.

(6) Verify that the python version in the tensorflow environment is correct

Activate the TensorFlow environment: activate TensorFlow

Insert picture description here

Check the python version: python --version

Insert picture description here

Six, install TensorFlow

Enter pip install TensorFlow-gpu -i https://pypi.douban.com/simple/ and
use "-i" to switch to Douban's mirror source (soon) and
Insert picture description here
wait for the installation to succeed.

After the installation is complete, enter the following command in the terminal console to check the installation:
Insert picture description here
here, the installation of the tensorflow-GPU2.3.0 environment is complete.

Seven, create a virtual environment in Pycharm

(1) Create an empty folder and remember the path
Insert picture description here
(2) Open pycharm, click file, and click settings
Insert picture description here

Select the project interpreter, click the drop down, and click show all
Insert picture description here

Click the plus sign in the upper right corner
Insert picture description here

Select virtualenv environment, select new environment path, select the folder path just created, base interpreter select python system interpreter path, click ok:

Insert picture description here

Choose a new environment

Insert picture description here

(3) After the creation is successful, the newly created folder will become like this:
Insert picture description here

(4) Click the terminal at the bottom of the pycharm window, come out the command window, enter the path and execute activate, you can enter the virtual environment
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_45154565/article/details/108648832