百度飞桨 AI studio中使用PyTorch

百度飞桨 AI studio中使用PyTorch

1.打开shell,输入命令 ls -a,如下所示:

aistudio@jupyter-7849654-7210433:~$ ls -a

![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/20e36d9f378c4ddcaa23754f12980fe4.png

2.如果出现".condarc"文件夹,则需要进行删除:

aistudio@jupyter-7849654-7210433:~$ rm -r .condarc

3.更换清华源

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

4.创建环境

conda create -n pytorch python=3.10

5.查看是否已经创建完成

aistudio@jupyter-7849654-7210433:~$ conda env list

在这里插入图片描述

6.进入虚拟环境

source activate pytorch

7.下载PyTorch

去官网,下载CUDA版本对应的PyTorch:
(这里下载如图所示的版本)
在这里插入图片描述

aistudio@jupyter-7849654-7210433:~$ pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

下载完成:
在这里插入图片描述

8.查看版本号

aistudio@jupyter-7849654-7210433:~$ pip list

在这里插入图片描述
可以找到torch和torchvision,说明安装成功。

9.测试

创建"test.py"文件,编写以下内容:

import torch

print(torch.cuda.is_available())
print(torch.version)

运行python文件:

aistudio@jupyter-7849654-7210433:~/work$ python test.py

出现以下结果则说明可以正常使用:
在这里插入图片描述

  • 10
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值