美文网首页python
Windows10安装Cuda、Pytorch

Windows10安装Cuda、Pytorch

作者: 承诺一时的华丽 | 来源:发表于2021-04-28 13:07 被阅读0次

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

相关文章

网友评论

    本文标题:Windows10安装Cuda、Pytorch

    本文链接:https://www.haomeiwen.com/subject/iztplltx.html