Ubuntu20.04安装Miniconda3和gymnasium以及CPU版本Pytorch

Ubuntu20.04安装Miniconda3和gymnasium以及CPU版本Pytorch

0.虚拟机Ubuntu20.04环境搭建;

- VMware® Workstation 17 Pro 17.0.0 build-20800274(需要联网安装VMTools)
- 在Ubuntu20.04内Software&Updates配置aliyun源

1.因为Ubuntu20.04 配套的 Python 版本是3.8,所以从官网下载 Miniconda3-py38_23.11.0-2-Linux-x86_64.sh的版本;

wget https://repo.anaconda.com/miniconda/Miniconda3-py38_23.11.0-2-Linux-x86_64.sh

2.授权并安装Miniconda;

sudo chmod +x Miniconda3-py38_23.11.0-2-Linux-x86_64.sh
bash Miniconda3-py38_23.11.0-2-Linux-x86_64.sh

3.初始化Conda;

eval "$(/home/你的安装路径/miniconda3/bin/conda shell.bash hook)"
conda init

4.创建py311虚拟环境;

conda create -n py311 python=3.11.5

5.进入py311虚拟环境;

conda activate py311

6.安装gymnasium[atari];

pip install gymnasium[atari]
pip install gymnasium[accept-rom-license]

7.编辑测试代码atari_demo.py并运行python atari_demo.py;

import gymnasium as gym

env = gym.make('ALE/Breakout-v5', render_mode = "human")

while True:
    s, _ = env.reset()
    done = False
    while not done:
        a = env.action_space.sample()
        s_next, r, dw, tr, info = env.step(a)
        done = (dw or tr)

8.添加清华源;

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/

9.安装cpu版本Pytorch;

conda install pytorch torchvision cpuonly

10.打印pytorch的版本&打印cuda是否可用,输出是False

import torch
print(torch.__version__)#
print(torch.cuda.is_available())#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值