miyosuda / async_deep_reinforce

Asynchronous Methods for Deep Reinforcement Learning
Apache License 2.0
592 stars 192 forks source link

Binary files for other games? #25

Closed wsjeon closed 7 years ago

wsjeon commented 7 years ago

Until now, I changed your code for gym and have used it.

However, I notice that the simulation speed critically depends on whether using gym or using ALE in your repository. My GPU is GTX TITAN X PASCAL and the initial speed for each environment is given as follows:

your ALE : about 1000 steps/sec gym: about 500 steps/sec

I cannot figure out why such result occurs...

Anyway, for such reason, I hope to make other binary files for ALE (breakout, or whatever), and would you give some references?

miyosuda commented 7 years ago

@wsjeon

I used skimge in gym branch as a test for image conversion, but recently I found that cv2 is much faster than skimage. So could you try cv2?

import numpy as np
import skimage.color
import skimage.transform
import cv2
import time

def resize_gym():
  observation = np.zeros([210, 160, 3], dtype=np.int8)
  observation = observation.astype(np.float32)  
  grayscale_observation = skimage.color.rgb2gray(observation)
  resized_observation = skimage.transform.resize(grayscale_observation, (84, 84))

def resize_cv2():
  observation = np.zeros([210, 160, 3], dtype=np.int8)
  observation = observation.astype(np.float32)
  grayscale_observation = cv2.cvtColor(observation, cv2.COLOR_RGB2GRAY)
  resized_observation = cv2.resize(grayscale_observation, (84,84))

start = time.time()

for i in range(1000):
  resize_gym()

elapsed_time = time.time() - start
print("gym elapsed_time:{0}".format(elapsed_time) + "[sec]")
# gym elapsed_time:1.04274606705[sec]

start = time.time()

for i in range(1000):
  resize_cv2()

elapsed_time = time.time() - start
print("cv2 elapsed_time:{0}".format(elapsed_time) + "[sec]")
# cv2 elapsed_time:0.169998884201[sec]

And the reason why gym is slower than ALE is that gym doesn't have frame skipping feature. In my ALE version it uses frame skipping of 4 while gym version iterates 4 steps manually.

For ALE roms, how about this site?

https://www.atariage.com/system_items.html?SystemID=2600&ItemTypeID=ROM

Please be aware that we need to rename ROM file name, because ALE distinguishes game type by file names.

For example, Breakout should be "breakout.bin"

https://github.com/mgbellemare/Arcade-Learning-Environment/blob/2b5c3796a8f1536ffe8219db0e25ea190d3727aa/src/games/supported/Breakout.hpp#L50

wsjeon commented 7 years ago

Wow! I really appreciate for your help :)