1、下載CUDA cuda_11.1.0_456.43_win10.exe
鏈接:https://pan.baidu.com/s/1fRNbB2hr4OGtZ3zKLZfPjQ
提取碼:p508
2、安裝CUDA
image
安裝,選擇自定義安裝。
image
image
image
3、查看CUDA版本,是否安裝成功
C:> nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Tue_Sep_15_19:12:04_Pacific_Daylight_Time_2020
Cuda compilation tools, release 11.1, V11.1.74
Build cuda_11.1.relgpu_drvr455TC455_06.29069683_0
4、安裝Anaconda
- 下載地址
https://mirrors.bfsu.edu.cn/anaconda/archive/ - 配置中科大鏡像源
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 --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
conda config --set show_channel_urls yes
5、安裝pytouch
- 下載安裝地址
https://pytorch.org/get-started/locally/
image.png
注意:Compute Platform 選的CUDA版本要與上面安裝CUDA的版本保持一致 nvcc --version
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge
或者
pip3 install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
3GB下載太慢了
解決方案:用戶迅雷下載,然后安裝本地下載文件的方式即可
10幾倍的差距,幾分鐘就好了
- 本地安裝
pip install e:/torch-1.8.1+cu111-cp37-cp37m-win_amd64.whl
- 測試安裝結果
$ python3
Python 3.8.5 (default, Sep 4 2020, 07:30:14)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> x = torch.empty(5, 3)
>>> print(x)
tensor([[1.0966e+14, 4.5883e-41, 1.0966e+14],
[4.5883e-41, 1.0966e+14, 4.5883e-41],
[1.0968e+14, 4.5883e-41, 1.0966e+14],
[4.5883e-41, 1.0968e+14, 4.5883e-41],
[1.0968e+14, 4.5883e-41, 1.0968e+14]])
- 查看torch 和 CUDA版本
import torch
print(torch.version)
print(torch.cuda.is_available())
print(torch.version.cuda)
其他安裝
- 安裝numpy、sklearn、yacs、tqdm