Use anaconda to install multiple versions of CUDA and CUDNN in a virtual environment
Article directory
1. Check the cuda version of your system
nvcc -V
2. Check version support
(My current environment is: python 3.10.9, tensorflow 2.13.0, CUDA 11.5, CUDNN 8.8;
the new environment installed is: python 3.6, tensorflow 1.15.0, CUDA 10, CUDNN 7.4)
Be sure to check whether your current conda supports the CUDA and CUDNN of the model you want to install by running the following command. If not found, please change the conda version.
Open Anaconda Prompt, check the CUDA Toolkit version currently supported by Conda, and run the following command:
conda search cudatoolkit --info
Open Anaconda Prompt, check the CUDNN version currently supported by Conda, and run the following command:
conda search cudnn --info
3. Create a virtual environment
To view, create, switch, and delete virtual environments in anaconda, you can refer to this blog of mine, click to jump.
#创建虚拟环境
conda create -n TF1_PY36 python=3.6
#切换虚拟环境
conda activate TF1_PY36
4.Install CUDA
conda install cudatoolkit==10.0
5.Install CUDNN
conda install cudnn==7.6.5
6.Install tensorflow
conda install tensorflow-gpu==1.15.0
7. Check whether the installation is successful
conda list
Enter python on the command line, enter the python environment, try to load tensorflow, and observe whether it succeeds.
You can see that there is no problem with the import, indicating that our tensorflow1.0 version has been successfully built.
It should be noted that ours is CUDA and CUDNN in the virtual environment, which is different from what is installed in our system. When we use it to nvcc -V
view the version number, we are actually viewing the system, which is our first installation. The version number, not the version number we are installing now, the version number installed in the current virtual environment conda list
can be viewed.