Install cuda10.1, cudnn7.6.5, anaconda3-2019-10, tensorflow-gpu and Pytorch-gpu records in Windows10

1. Install Anaconda3

  1. Download Anaconda3. I found it on Baidu conda 清华镜像. The address is the conda Tsinghua mirror download address . The downloaded version is Anaconda3-2019.10-Windows-x86_64.exe. This version supports Python3.7.4.
  2. Double-click to install and follow the default options until the next step.
  3. Check if the installation is successful, conda list.
  4. Since the image source is from abroad, add the image of the Chinese Academy of Sciences and use conda config.
    	conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
    	conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
    	conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
    	conda config --set show_channel_urls yes
    
  5. Next create a conda environment and use the following commands
    • The creation command conda create -n tf2_gpu python=3.6.5supports Python 3.7, but I used Python 3.6 here. conda env listYou can check which environments have been created.
    • When using jupyter notebook, you sometimes switch between different kernels. Then you need to install nb_conda_kernels and ipykernel in the tf2_gpu environment . First, switch to installing and respectively .conda activate tf2_gpuconda install nb_conda_kernelsconda install ipykernel
    • Associate kernel and environmentpython -m ipykernel install --name tf2_gpu
    • Modify the default configuration of jupyter C:\Users\Administrator.jupyter 's starting directory c.NotebookApp.notebook_dir = 'D:\\00.codes\\jupyter', and then type the command jupyter notebookto start jupyter.
    • View the kernel list,ipython kernelspec list
    • Delete existing kernelipython kernelspec remove kernelname
  6. Some other common commands
    • Delete a conda imageconda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    • conda environment transfer copy
      • Conda exports the existing environment: conda env export > environment.yamlThe environment will be saved in the environmen.yaml file and used to recreate the environment.
      • Conda reproduces the installation environment: conda env create -f environment.yamlThe transplanted environment only installs the packages you installed directly with conda install and other commands in the original environment. Things you installed with pip and the like are not transplanted and need to be reinstalled.
    • Transfer and copy of pip package
      • pip exports the installed libraries to requirements.txt:pip freeze > requirements.txt
      • pip imports the libraries listed in requirements.txt into the system:pip install -r requirements.txt

2.Install NVIDIA CUDA

  1. Check whether your computer supports the version and driver of CUDA. You can check it like this: NVIDIA Control Panel > Help > System Information > Components and check NVCUDA64.DLL in 3D settings.
    cuda version support
  2. First go to the official website to downloadcuda_10.1.243_426.00_win10.exe
  3. Then install it. If VS is not installed on the computer, do not choose it.
    Insert image description here
  4. CUDA installation confirmation
    Insert image description here
  5. .CUPTI Confirm
    Insert image description here

3. Install CUDNN

  1. First, go to the tensorflow official website to confirm the version correspondence. For example, if I install tensorflow_gpu-2.2.0 here, I need to install cuda10.1 and cudnn7.6.
    Insert image description here
  2. Go to the cudnn official website to download the version corresponding to cuda10.1, which requires registration.
    Insert image description here
  3. Unzip, then rename the folder cudnnand copy it to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1the following, as shown in the figure
    Insert image description here
  4. cuDNN confirmed
    Insert image description here

4. Configure environment variables

Insert image description here

	C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin
	C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\libnvvp
	C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\cudnn\bin
	C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\CUPTI\lib64
  1. Add CUPTI path
  2. Tianjian cuDNN path
  3. CUDA test
    Insert image description here

5. Install tensorflow-gpu

	import tensorflow as tf
	print(tf.test.is_gpu_available())

Insert image description here

6. Install pytorch-gpu

  • Find the corresponding versions of cuda and cudnn in the official website installation document
  • Install pytorch1.5.1 version
  • conda install pytorch1.5.1 torchvision0.6.1 cudatoolkit=10.1 -c pytorch
  • Verify if gpu is supported in ipython
    Insert image description here

Guess you like

Origin blog.csdn.net/diaozhida/article/details/118519783