Windows10安裝Cuda、Pytorch

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

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

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
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容