Authored by Tony Feng
Created on June 26th, 2021
Last Modified on Sept 1st, 2022
Intro
This is the tutorial of deep learning framework deployment (GPU version), covering the basic steps of installation, solutions to some errors, and other key points. If you meet any bugs that are not mentioned here, then Google them :)
Prerequisites
To build up an deep learning environment, you need to install a NVIDIA driver that supports your GPU. Also, you need to pay attention to the versions of your deep learning framework, CUDA, CUDNN, Python. Be sure that they are compatible with each other.
You can refer to these webpages: - The relationship between between GPU, CUDA, CUDNN - What is GPU, NVCC, CUDA, CUDNN?
Anaconda
Anaconda is a Python distribution that is particularly popular for data analysis and scientific computing. This platform can integrate many useful tools, such as Visual Studio Code, Jupyter Notebook, R Studio, PyCharm, etc.
The software provides a flexible solution that allows users to build, distribute, install, update, and manage software in a cross-platform manner. The multiple environments can be maintained and run separately without interference from each other.
You can download Anaconda here and choose a version matching your OS.
After installing the software, (base) will be displayed in front of each line in your termial. This means you are in the root environment.
Now, I am gonna show you some basic conda operations in the terminal. Firstly, let’s build a new enviroment.
|
|
If you already has multiple environments and forget their names, you can enter the command under the base environment.
|
|
You can delete the enviroment if necessary, and all packages inside will be deleted as well. Be careful and don’t do this to the base.
|
|
Then, move into the environment.
|
|
You can exit the environment and go to the base with the command:
|
|
If you want to check what packages have been installed in the environment, you can enter:
|
|
For more instructions, please refer to this webpage.
PyTorch
In this section, I will illustrate how to install PyTorch under the Anaconda environment.
Firstly, we create an environment for PyTorch, namely pt and move into the environment
|
|
Next, we can go to the PyTorch’s official website and click Get Started. You can choose the configuration you want and the webpage can provide the corresponding command. Also, you could visit here to download historical versions. For example,
|
|
Then, we intall cudnn through conda command.
|
|
You can use the following code to test if the installation is successful.
|
|
Tensorflow 1.x
The deployment of TF1.x is much different from that of TF2.x. If you need to install TF2.x, you can refer to this webpage. In this part, I will go through the process of TF 1.x deployment. If the following instructions are not clear, you can visit this webpage.
Firstly, we create an environment, namely tf1,for Tensorflow 1.x, and step into the environment
|
|
Then, install the GPU version of TF 1.x
|
|
Before installing the CUDA, CUDNN, you can visit here to find versions of CUDA Toolkit and cuDNN SDK, compatible with your TF version.
|
|
You can use the following code to test if the installation is successful.
|
|
If the result of print(tf.test.is_gpu_available())
is false
, try to check if tensorflow detects your GPU. Re-installing the tensorflow may solve the issue. You can visit this webpage to acquire more details.
|
|
Some tips
-
If your network is slow, you may configure a mirror to facilitate the package downloading. You may refer to this webpage to find more details.
1
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
-
You can check the versions of CUDA and CUDNN with the commands:
1 2
conda list cuda conda list cudnn
-
If you want to find a campatible combination of CUDA, CUDNN, the following command can list a series of suported versions.
1 2
conda search cudatoolkit conda search cudnn