Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

Speed part 3 #13

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Speed part 3 #13

wants to merge 13 commits into from

Conversation

JobJob
Copy link
Member

@JobJob JobJob commented Sep 15, 2018

Uses unsafe_gettpl! from JuliaPy/PyCall.jl#486 to get faster access to the elements from the s, r, done, info tuple returned by gym env.step functions in Python.

This is two extra commits on top of #12

Requires

You can test this out by checking out the dev branch on https://github.com/JobJob/PyCall.jl, and the fixes-for-1.0 branch for https://github.com/JobJob/Reinforce.jl, and the branch for this PR - speedierer on https://github.com/JobJob/OpenAIGym.jl

There may be some artifacts in the timing, but speed of stepping the environments in a loop (with random actions) seems slightly faster in Julia than Python for all envs.

Here's the performance vs Python 3 on my machine using the Julia and Python benchmarks the tests:

------------------------------ Begin Julia Speed Check ------------------------------
env.pyenv: PyObject <TimeLimit<AtariEnv<Pong-v4>>> num_eps: 4 t: 2.560144323 steps: 5390
microsecs/step (lower is better): 474.98039387755097
------------------------------
env.pyenv: PyObject <TimeLimit<AtariEnv<PongNoFrameskip-v4>>> num_eps: 4 t: 2.877211298 steps: 14272
microsecs/step (lower is better): 201.59832525224218
------------------------------
env.pyenv: PyObject <TimeLimit<AtariEnv<MsPacman-v4>>> num_eps: 9 t: 2.747953905 steps: 5611
microsecs/step (lower is better): 489.74405720905366
------------------------------
env.pyenv: PyObject <TimeLimit<AtariEnv<MsPacmanNoFrameskip-v4>>> num_eps: 9 t: 3.852006364 steps: 19048
microsecs/step (lower is better): 202.22628958420833
------------------------------
env.pyenv: PyObject <TimeLimit<CartPoleEnv<CartPole-v0>>> num_eps: 5000 t: 0.9092510549999988 steps: 107408
microsecs/step (lower is better): 8.465394151273637
------------------------------
env.pyenv: PyObject <gym.envs.toy_text.blackjack.BlackjackEnv object at 0x127d56be0> num_eps: 30000 t: 0.15676215100000562 steps: 11215
microsecs/step (lower is better): 13.97790022291624
------------------------------
------------------------------ End Julia Speed Check ------------------------------

------------------------------ Begin Python Speed Check ------------------------------
WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype.
<TimeLimit<AtariEnv<Pong-v4>>> num_eps: 4 t: 2.288335084915161 steps: 4672
 microsecs/step (lower is better): 489.7977493397177
------------------------------
<TimeLimit<AtariEnv<PongNoFrameskip-v4>>> num_eps: 4 t: 3.096867084503174 steps: 15103
 microsecs/step (lower is better): 205.04979702729085
------------------------------
<TimeLimit<AtariEnv<MsPacman-v4>>> num_eps: 9 t: 2.9955520629882812 steps: 6010
 microsecs/step (lower is better): 498.4279638915609
------------------------------
<TimeLimit<AtariEnv<MsPacmanNoFrameskip-v4>>> num_eps: 9 t: 3.5945401191711426 steps: 17145
 microsecs/step (lower is better): 209.6553000391451
------------------------------
<TimeLimit<CartPoleEnv<CartPole-v0>>> num_eps: 5000 t: 1.1792187690734863 steps: 111920
 microsecs/step (lower is better): 10.536264913094053
------------------------------
<BlackjackEnv<Blackjack-v0>> num_eps: 30000 t: 1.3064210414886475 steps: 41357
 microsecs/step (lower is better): 31.58887350360634
------------------------------
------------------------------ End Python Speed Check ------------------------------

Plus:
* update abstract type syntax for 0.6+
* remove a non-universal linux workaround
AFAICT Universe is not maintained by OpenAI anymore, and should probably have it's own file/project anyway to reduce clutter
oopsie daisy : D - was quite broken without this
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants