installation steps:
1. Confirm whether the graphics card supports CUDA
Before installation, we must first confirm whether the existing or planned discrete graphics card supports CUDA. The specific operations are as follows:
- Check the graphics card that supports CUDA, as shown in the figure below:
For details, please go to the website https://developer.nvidia.com/cuda-gpus .
-
Check the graphics card
Open the task manager (Ctrl+Shift+Esc) --> "Performance" --> click "GPU" to view the name of the graphics card (the upper right corner of the picture below)With the name of the graphics card, you can refer to the above picture for comparison to see if it supports CUDA.
2. Install CUDA
After we confirm that the system has installed a graphics card that supports CUDA, we can install CUDA. The specific steps are as follows:
-
Download and install CUDA
Download CUDA from NVIDIA official website: https://developer.nvidia.com/cuda-downloads
Note: Installer Type The difference between the two installation methods:
·exe(network): The file is relatively small when downloading, and it will be reinstalled after subsequent installation Download the rest.
·exe(local): When downloading, it is completely downloaded, and there is no need to download it when performing subsequent installations. -
Set the staging directory for the unpacked installer
Wait
-
Agree to the agreement and continue
-
Choose Compact Install
-
Warning Visual Studio is not installed
CUDA can be developed with Visual Studio. The interface warns that Visual Studio is not installed.
Since we will use Python to develop later, there is no need to install Visual Studio.
-
Download the CUDA interface
-
confirm installation
-
The installation is complete
3. Install cuDNN
Then install cuDNN, as follows:
3.1 install cudnn
-
Download cuDNN
Download cuDNN from NVIDIA official website: https://developer.nvidia.com/cudnn .
-
Become a member
To download cuDNN, you must become a member of the Accelerated Computer Developers Program.
-
Enter the download page
After becoming a member and logging in, enter the download page.
-
View the downloaded file
The downloaded file is a ZIP compressed file, which can be directly decompressed and opened in Windows 10.
Rename it to "cuda"
Then place cuda in a suitable location, if you don't know how to put it, you can refer to step 5 -
Copy to another directory
Here I directly placed cuda in a directory on my D drive.
-
View cudnn64_8.dll
in D:\CS\Code\Jupyter\cuda\bin (that is, in the .../cuda/bin directory) and you can see cudnn64_8.dll. This is the dynamic link library through which other programs can use the functions of cuDNN.
3.2 Add the storage location of cudnn64_8.dll to the Path environment variable
In order to let the Windows system know the directory where cuDNN is installed, the Path environment variable must be set, so that other programs can access cudnn64_8.dll through this setting
-
Open the system environment variable
First click "Settings", and then do the following:
-
Edit the user variable in the environment variable
Add "D:\CS\Code\Jupyter\cuda\bin" to the Path environment variable (that is, the installation directory of cudnn64_8.dll)
4. Install TensorFlow GPU version
4.1 Establish TensorFlow GPU virtual environment in Anaconda
-
Restart the Command Prompt program and change to the working directory.
-
Create TensorFlow GPU virtual environment in Anaconda
Create command: conda create --name tensorflow-gpu python=3.9 anaconda
After pressing the y key, the Anaconda virtual environment will be installed and various packages will be installed. After the installation is complete, the screen display interface is as follows:
Order | illustrate |
---|---|
create condas | Create a virtual environment |
–name tensorflow-gpu | The name of the virtual environment is tensorflow-gpu |
python=3.9 | Python version is 3.9 |
anaconda | Add this command option, when creating a virtual environment, other Python software packages will also be installed at the same time, such as Jupyter Notebook, Numpy, SciPy, Matplotlib, Pandas, for data analysis |
- Enable the TensorFlow GPU virtual environment
Start the Anaconda virtual environment: activate tensorflow-gpu
4.2 Install Tensorflow-gpu
Next, install the TensorFlow GPU version in the TensorFlow GPU virtual environment
. Installation command: pip install tensorflow-gpu
4.3 Install Keras
Then install Keras
Installation command: pip install keras
Summarize
In this article, we mainly introduced how to install CUDA and cuDNN, established a TensorFlow GPU virtual environment, and installed the TensorFlow GPU version and Keras in the virtual environment.
Supplement:
If you don't understand Step 4: Installing the TensorFlow GPU version, you can refer to the installation of the TensorFlow CPU version in the Anaconda virtual environment.
For details, please refer to: [AI Study Notes] Installation of TensorFlow and Keras (Windows Anaconda Virtual Environment Edition)
For the powerful function of testing GPU in TensorFlow GPU virtual environment, I will continue to update in the follow-up.