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())#