- Check your computer’s GPU
CUDA download: https://developer.nvidia.com/cuda-toolkit-archive CUDNN download: https://developer.nvidia.com/rdp/cudnn-download pytorch download: pytorch.org
PIP install Torch ==1.8.1+cu111 TorchVision ==0.9.1+cu111 Torchaudio ==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html in cuda and the before installation
2. Install the NVIDIA control panel to find the version driverwww.nvidia.cn/geforce/dri…Download the control panel. I have it on my computer
3. CUDA11 installationDeveloper.nvidia.com/cuda-toolki…Download the corresponding version
- CUDNN download and configuration developer.nvidia.com/zh-cn/cudnn
After a series of registration operations, it is finally available for download
- Install using an image
PIP install Torch ==1.8.1+cu111 TorchVision ==0.9.1+cu111 Torchaudio == 0.8.1-f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
PIP install -i is installed successfullypypi.doubanio.com/simple/–trusted-host pypi.doubanio.com Package name Other mirror address Doubanpypi.douban.com/simple/
Tsinghua university pypi.tuna.tsinghua.edu.cn/simple/
Ali cloud mirrors.aliyun.com/pypi/simple…
Pypi.mirrors.ustc.edu.cn/simple/ China university of science and technology
University of science and technology of China pypi.mirrors.ustc.edu.cn/simple/
7. View the installation result
Successful import
CUDA download and CUDNN are not installed yet. It shows that you can use the GPU. Does that mean that the previous search so many articles about installation are in vain? What if I train a model and I run out of GPU memory? .
8. Double-check
Is_available () if flag: print(" CUDa available ") else: Print ("CUDA unavailable ") ngpu= 1 # Decide which device we want to run on device = torch. Device ("CUDA :0" if (Torch.cuda.is_available() and NGPU > 0) else "CPU ") print(" device: ") print("GPU: ",torch.cuda.get_device_name(0))Copy the code
- Refer to www.huaweicloud.com/articles/7c…
Pytorch CPU version &GPU version environment installation (with CUDA and CUDNN)