windows下配置OpenAI-gym&baselines

OpenAI Gym website
Gym is a toolkit for developing and comparing reinforcement learning algorithms. It supports teaching agents everything from walking to playing games like Pong or Pinball.
OpenAI Baseline github
OpenAI Baselines is a set of high-quality implementations of reinforcement learning algorithms.

1 安装anaconda&C++编译器

使用Conda的目的是使用虚拟环境,C++编译器可以直接安装Visual Studio 2019。

2 安装Gym

使用 anaconda powershell promopt 来输入:

conda create -n <env-name> python=3.6创建虚拟环境

conda activate <env-name>激活环境

(可选)下载git

conda install git
(可选)如果你需要保存训练的图像,还需要下载ffmpeg包:

conda install -c conda-forge ffmpeg

pip install gym安装gym

或从源码编译:

git clone https://github.com/openai/gym.git
cd gym
pip install -e .xx

源码下载位置为promot当前路径

编译完成后使用

python examples/agents/random_agent.py测试,将会出现经典的 cart-pole 的场景

3 安装Baseline

先安装tensorflow

pip install tensorflow==1.14pip install tensorflow-gpu==1.14

在baseline GitHub页面下载解压到目标文件夹

或用git命令下载

git clone https://github.com/openai/baselines.git
cd baselines
pip install -e .

运行编译成功后,在baselines目录下运行一个DQN算法跑cartpole的例子:

python baselines/deepq/experiments/train_cartpole.py

若报错ImportError: Could not find 'cudart64_100.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 10.0 from this URL: https://developer.nvidia.com/cuda-90-download-archive可以参考[TensorFlow] windows同时安装cuda10.0和cuda10.1

将会用DQN训练agent 100ksteps, 当训练完成后,你可以运行:

python baselines/deepq/experiments/enjoy_cartpole.py

来观看训练结果


版权声明:本文为hello_world_banni原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。