OpenAI的Spinning Up项目仅在 Linux 和 OSX 上支持Spinning Up,因此想在Win10系统中安装Linux子系统,以便将Spinning Up项目运行起来,学习一下强化学习。
安装Linux子系统
步骤如下:
- 打开控制面板,选择应用,点击左上角的程序和功能,在弹出窗口中点击启动或关闭Windows功能,勾选适用Linux的Windows子系统。
- 打开Store商店,安装Ubuntu 20.04操作系统。
配置Spinning Up项目
步骤如下:
- 打开cmd,输入wsl命令,进入ubuntu系统。
- 下载并安装Xming。
- 使用如下命令安装x11-apps。
1 2 3
| sudo apt-get install x11-apps export DISPLAY=localhost:0.0 nano ~/.bashrc #(add export DISPLAY=localhost:0.0 at the end. Ctrl+X to exit/save)
|
- 下载并安装miniconda。
- 创建Python虚拟环境。
1 2 3 4 5 6
| # 创建虚拟环境 conda create -n spinningup python=3.7 # 查看虚拟环境 conda info -h # 删除创建的虚拟环境 conda remove -n spinningup --all
|
1
| conda activate spinningup
|
1
| sudo apt-get update && sudo apt-get install libopenmpi-dev
|
1
| sudo apt-get install python-opengl
|
1 2 3
| git clone https://github.com/openai/spinningup.git cd spinningup pip install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple
|
1 2 3 4 5 6
| # 运行登陆器 python -m spinup.run ppo --hid "[32,32]" --env LunarLander-v2 --exp_name installtest --gamma 0.999 # 绘图 python -m spinup.run plot /mnt/i/project/spinningup/data/installtest/installtest_s0 # 视频 python -m spinup.run test_policy /mnt/i/project/spinningup/data/installtest/installtest_s0
|
参考链接
- WSL Linux 子系统,真香!附完整实操,by 猴哥一一.
- 在 Windows 10 中使用 OpenAI Spinning Up ,by csu.
- Anaconda创建环境、删除环境、环境重命名,by CodeAntenna.
- [Bug Report] contextlib has no attribute ‘nullcontext’ for Python3.6 when calling register(),by github.