Ubuntu20.04安装 Pytorch1.7.0 GPU版 torchvision=0.8.1 (已装好CUDA和CUDNN)

  • 创建虚拟环境
    conda create -n pytorch python=3.8
    conda env list
    conda activate pytorch

  • 官网下载对应的安装命令:
    pip install torch==1.7.0+cu101 torchvision==0.8.1+cu101 torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html


    不过,下载的有点慢,我是先用Motrix下载Torch:https://download.pytorch.org/whl/cu101/torch-1.7.0%2Bcu101-cp38-cp38-linux_x86_64.whl
    然后先安装torch(需要切换到下载torch的目录下):pip install torch-1.7.0+cu101-cp38-cp38-linux_x86_64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple/
    最后用该命令进行下载其余的库: pip install torch==1.7.0+cu101 torchvision==0.8.1+cu101 torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html

  • 测试是否安装完成:

    import torch
    import torchvision
    
    if __name__ == "__main__":
        print(torch.__version__)  # 查看torch当前版本号
        print(torchvision.__version__)
    
        # 查看CUDA版本号:
        print(torch.version.cuda)  # 编译当前版本的torch使用的cuda版本号
    
        # 测试Cudnn是否安装成功
        from torch.backends import cudnn
        print(cudnn.is_available())
    
        # 是否GPU可用
        print(torch.cuda.is_available())  # 查看当前cuda是否可用于当前版本的Torch,如果输出True,则表示可用
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值