Comprehension: First of all, the virtual environment of anaconda is really fragrant! Open up a new virtual environment, many environment and version incompatibility problems will no longer exist, especially useful for students who reproduce other people's code.
Conditions: As long as the installed version does not exceed the hardware conditions of your own machine, you can install it.
step:
1. Determine the cuda version installed.
In the virtual environment, first use the conda search cudatoolkit --info command to view all cuda versions in the source and the download address. The red box in the example below indicates the supported cuda version, the corresponding url address and some constraints.
2. Download and install cuda.
Find the cuda version you want and meet your machine conditions, copy the download link corresponding to the url, cd to the download directory you want, and download it with the following code:
wget 复制的 url 链接
Run the following command to install cuda. If it is not in the current directory, an absolute path must be added before the cuda package.
conda install 刚下载的 cuda 安装包
3. Determine the cudnn version corresponding to cuda.
Use the following command to view the version of cudnn supported by conda. It should be noted that the version of cudnn should match the version of cuda. The figure below shows the cudnn version number, url download address and some constraints corresponding to this version.
conda search cudnn --info
4. Download and install cudnn.
Find the cudnn version you want and meet your machine conditions, copy the download link corresponding to the url, and download it with the following code:
wget 复制的 url 链接
Run the following command to install cudnn.
conda install 刚下载的 cudnn 安装包
5. Install pytorch.
After finding the pytorch version supported by the installed cuda version on the official website , copy the command similar to the red box in the figure below to the Linux command line for execution.
You cannot use nvcc -V to test whether cuda is successfully installed in a virtual environment. This is because the command returns the default cuda version of the system, not the cuda version used in the current environment. We can use the pytorch command in the python environment to check which cuda is called when executing the python file in the current environment.