pytorch安装

pytorch的安装

1. 安装了anaconda
2. conda切换为清华镜像源提高下载速度
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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --set show_channel_urls yes
3. 明确自己计算机的cuda的版本,然后对应https://pytorch.org/get-started/previous-versions/找到合适的pytorch版本下载命令,
# CUDA 10.0
conda install pytorch1.0.0 torchvision0.2.1 cuda100 -c pytorch
表示,cuda版本为10.0,其对应的pytorch版本为1.0.0.下载命令见上。
注意:conda切换为国内镜像时,下载命令为conda install pytorch1.0.0 torchvision0.2.1 cuda100
注意:去掉末尾的-c pytorch。来提高下载速度
4. 验证是否安装成功torch。
From the command line, type:
python
then enter the following code:
import torch
x = torch.rand(5, 3)
print(x)
The output should be something similar to:
tensor([[0.3380, 0.3845, 0.3217],
[0.8337, 0.9050, 0.2650],
[0.2979, 0.7141, 0.9069],
[0.1449, 0.1132, 0.1375],
[0.4675, 0.3947, 0.1426]])
Additionally, to check if your GPU driver and CUDA is enabled and accessible by PyTorch, run the following commands to return whether or not the CUDA driver is enabled:
import torch
torch.cuda.is_available()
只有当返回值为True时候,才表明安装成功,否则就是cuda版本与pytorch版本之间不对应,需要重现进行安装。注意对应合适的python版本。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值