PyTorch 安装 GPU版本(CUDA/cuDNN)

日萌社

人工智能AI:Keras PyTorch MXNet TensorFlow PaddlePaddle 深度学习实战(不定时更新)


Ubuntu 安装 CUDA、cuDNN、anaconda、pycharm、tensorflow、pytorch、JDK1.8

PyTorch 安装 GPU版本(CUDA/cuDNN)

PyTorch 安装 GPU版本(CUDA/cuDNN)

window 安装 PyTorch


pytorch gpu 安装
	1.官网下载安装:https://pytorch.org/get-started/locally/
	  安装命令:conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
	2.国内源直接下载链接
		网站链接:
                    window:https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64/
                    linux:https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64/
		选择下载:
                    window:pytorch-1.5.0-py3.7_cpu_0.tar.bz2
                    linux:pytorch-1.5.0-py3.7_cuda10.1.243_cudnn7.6.3_0.tar.bz2
		下载链接:
                    window:https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64/pytorch-1.5.0-py3.7_cpu_0.tar.bz2
                    linux:https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64/pytorch-1.5.0-py3.7_cuda10.1.243_cudnn7.6.3_0.tar.bz2
		安装:
                    window:conda install pytorch-1.5.0-py3.7_cpu_0.tar.bz2
                    linux:conda install pytorch-1.5.0-py3.7_cuda10.1.243_cudnn7.6.3_0.tar.bz2   
		pip list
			torch  1.5.0
	3.测试GPU版本的代码
		import torch
		#测试 CUDA
		print("Support CUDA ?: ", torch.cuda.is_available()) #返回True
		x = torch.tensor([10.0])
		x = x.cuda()
		print(x)
		y = torch.randn(2, 3)
		y = y.cuda()
		print(y)
		z = x + y
		print(z)
		# 测试 CUDNN
		from torch.backends import cudnn
		print("Support cudnn ?: ",cudnn.is_acceptable(x)) #返回True


1.官网下载安装:https://pytorch.org/get-started/locally/
2.执行命令:conda install pytorch torchvision cudatoolkit=10.1 -c pytorch

3.比如我的是CUDA 10.0的话,需要到https://pytorch.org/get-started/previous-versions/选择其他PyTorch版本
	执行命令:conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
4.添加 清华源 下载
		conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
		conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
		conda config --set show_channel_urls yes
		conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
5.国内下载
	https://download.pytorch.org/whl/torch_stable.html

4.测试GPU版本的代码

import torch
if __name__ == '__main__':
    #测试 CUDA
    print("Support CUDA ?: ", torch.cuda.is_available())
    x = torch.tensor([10.0])
    x = x.cuda()
    print(x)
 
    y = torch.randn(2, 3)
    y = y.cuda()
    print(y)
 
    z = x + y
    print(z)
 
    # 测试 CUDNN
    from torch.backends import cudnn
    print("Support cudnn ?: ",cudnn.is_acceptable(x))

Pytorch的安装

目标

  1. 知道如何安装pytorch

1. Pytorch的介绍

Pytorch是一款facebook发布的深度学习框架,由其易用性,友好性,深受广大用户青睐。

2. Pytorch的版本

3. Pytorch的安装

安装地址介绍:https://pytorch.org/get-started/locally/

安装步骤:

pip3 install torch torchvision

安装之后打开ipython

输入:

In [1]:import torch
In [2]: torch.__version__
Out[2]: '1.3.1'

注意:代码中都是使用torch

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

あずにゃん

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值