Windows10安装Cuda、Pytorch
2021-04-28 本文已影响0人
承诺一时的华丽
1、下载CUDA cuda_11.1.0_456.43_win10.exe
链接:https://pan.baidu.com/s/1fRNbB2hr4OGtZ3zKLZfPjQ
提取码:p508
2、安装CUDA
![](https://img.haomeiwen.com/i7339866/9d2ac5225700c3bd.png)
安装,选择自定义安装。
![](https://img.haomeiwen.com/i7339866/8c04d97da4acb9f3.png)
![](https://img.haomeiwen.com/i7339866/e1f4955d0391a03b.png)
![](https://img.haomeiwen.com/i7339866/428f7630a8079c15.png)
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
![](https://img.haomeiwen.com/i7339866/4cc87ee18a98dc67.png)
解决方案:用户迅雷下载,然后安装本地下载文件的方式即可
![](https://img.haomeiwen.com/i7339866/a0d4ab508671762a.png)
- 本地安装
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