cuda、torch、torchvision对应版本以及安装

查找torch与torchvision对应版本

github链接:https://github.com/pytorch/vision#installation

在线下载或者离线下载

1、在线下载
pytorch官网选择相应的历史版本,使用conda或者pip安装,使用官网的镜像下载很慢,建议使用其他的镜像源,这里我使用的是阿里的镜像速度还不错。

pip install torch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 -i https://mirrors.aliyun.com/pypi/simple/

2、离线下载
torch网站中选择cuda、torch、torchivsion、python的对应版本,想下载cpu版本的开头选cpu,向下载gpu版本的选cu开头的,注意一定要下载对应的版本,要不然会有很多错误!

cu102/torch-1.7.1-cp38-cp38-linux_x86_64.whl

  • cu102:表示cuda版本为10.2,
  • torch-1.7.1:表示torch版本为1.7.1
  • cp38:表示适用python版本为3.8
  • linux:表示适用于linux系统
  • x86_64:表示同时兼容32和64位系统
  • 下载完成后激活进入环境,pip install 路径\文件名.whl 安装即可

    测试

    如果安装成功,在环境中pip list即可查看安装的torch、torchvision、torchaudio版本

    或者可以执行以下命令查看torch的版本

    python
    import torch
    print(torch.__version__)
    


    使用torch查看cuda、cudnn版本

    import torch
    print(torch.__version__)
    print(torch.version.cuda)
    print(torch.backends.cudnn.version())
    

    来源:李昂的

    物联沃分享整理
    物联沃-IOTWORD物联网 » cuda、torch、torchvision对应版本以及安装

    发表回复