How to get free ~2x improvement in single env mentioned in the README? #158
Replies: 3 comments
-
Could you please share your hardware configuration and the way that you test? Thanks! |
Beta Was this translation helpful? Give feedback.
-
My hardware is a GeForce GTX 1050, Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz and 32GB RAM. Ubuntu 22 I used the following code to test it:
|
Beta Was this translation helpful? Give feedback.
-
In [18]: import gym
...: import envpool
...: import numpy as np
...: import time
...: env = envpool.make_gym('Hopper-v4', num_envs=1)
...: #env = gym.make('Hopper-v4')
...: env.action_space.seed(0)
...: n = 200000
...: env.reset()
...: t = time.time()
...: actions = np.array([env.action_space.sample() for _ in range(n)])
...: print(time.time() - t)
...: print(actions.shape)
...: t = time.time()
...: for i in range(n):
...: #action = env.action_space.sample()
...: #obs, reward, done, info = env.step(actions[i])
...: #for envpool:
...: obs, reward, done, info = env.step(actions[i:i+1])
...: if done:
...: env.reset()
...: print(time.time() - t) I'd recommend moving the random action part ahead of
So the slowest part is the action generation. I tested with some v4 environments but unfortunately didn't see a significant speedup for a single env. That may be because deepmind's mujoco binary and python binding is highly optimized. However, if you test with dm_control environments, you'll definitely see a huge speedup because dm_control's python binding with mujoco is not optimized. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I tested running a single "Hopper-v4" environment using envpool, but the running time is actually slower.
env = envpool.make_gym('Hopper-v4', num_envs=1)
-> 200k steps in 1min29senv = gym.make('Hopper-v4')
-> 200k steps in 43sAm I missing something?
Beta Was this translation helpful? Give feedback.
All reactions