2

深度学习框架pytorch安装

 2 years ago
source link: http://blog.wen2go.site/2022/02/19/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E6%A1%86%E6%9E%B6pytorch%E5%AE%89%E8%A3%85/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

环境搭建:(win10, python3.8, N卡)

  1. 安装Anaconda

    conda下载链接, 下载完直接运行,常规软件安装步骤。。一直下一步,到下图这里,建议把添加环境变量也勾选。

    然后点击install,等待安装完成

    image-20220224210720783

    • 指定路径创建虚拟环境, 下面使用创建的虚拟环境配置pytorch,版本管理参考之前文章:优雅的管理python版本

      conda create --prefix=E:\conda_env python=3.8 
  2. 查看cuda信息

    N卡 直接在命令行输入:nvidia-smi 查看显卡版本和cuda版本,查看cuda版本映射表:https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html

    CUDA Toolkit Linux x86_64 Driver Version Windows x86_64 Driver Version

    CUDA 11.6 Update 1 >=510.47.03 >=511.65

    CUDA 11.6 GA >=510.39.01 >=511.23

    CUDA 11.5 Update 2 >=495.29.05 >=496.13

    CUDA 11.5 GA >=495.29.05 >=496.04

    CUDA 11.5 Update 1 >=495.29.05 >=496.13

    CUDA 11.4 Update 4 >=470.82.01 >=472.50

    CUDA 11.4 Update 3 >=470.82.01 >=472.50

    CUDA 11.4 Update 2 >=470.57.02 >=471.41

    CUDA 11.4 Update 1 >=470.57.02 >=471.41

    CUDA 11.4.0 GA >=470.42.01 >=471.11

    CUDA 11.3.1 Update 1 >=465.19.01 >=465.89

    CUDA 11.3.0 GA >=465.19.01 >=465.89

    CUDA 11.2.2 Update 2 >=460.32.03 >=461.33

    CUDA 11.2.1 Update 1 >=460.32.03 >=461.09

    CUDA 11.2.0 GA >=460.27.03 >=460.82

    CUDA 11.1.1 Update 1 >=455.32 >=456.81

    CUDA 11.1 GA >=455.23 >=456.38

    CUDA 11.0.3 Update 1 >= 450.51.06 >= 451.82

    CUDA 11.0.2 GA >= 450.51.05 >= 451.48

    CUDA 11.0.1 RC >= 450.36.06 >= 451.22

    CUDA 10.2.89 >= 440.33 >= 441.22

    CUDA 10.1 (10.1.105 general release, and updates) >= 418.39 >= 418.96

    CUDA 10.0.130 >= 410.48 >= 411.31

    CUDA 9.2 (9.2.148 Update 1) >= 396.37 >= 398.26

    CUDA 9.2 (9.2.88) >= 396.26 >= 397.44

    CUDA 9.1 (9.1.85) >= 390.46 >= 391.29

    CUDA 9.0 (9.0.76) >= 384.81 >= 385.54

    CUDA 8.0 (8.0.61 GA2) >= 375.26 >= 376.51

    CUDA 8.0 (8.0.44) >= 367.48 >= 369.30

    CUDA 7.5 (7.5.16) >= 352.31 >= 353.66

    CUDA 7.0 (7.0.28) >= 346.46 >= 347.62

  3. 根据cuda信息,安装pytorch

    找到对应版本安装指令:https://pytorch.org/get-started/previous-versions/,

    • 进入虚拟环境:
    activate E:/conda_env
    • 控制台输入指令安装pytorch
    conda install pytorch==1.9.0 torchvision==0.10.0 torchaudio==0.9.0 cudatoolkit=11.3 -c pytorch -c conda-forge

    image-20220224221644128

    • python解释器选择刚才创建的虚拟py环境,然后导入pytorch, 以下指令返回True,就代表安装成功

      import torch
      print(torch.cuda.is_available())

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK