Skip to content

How to get free ~2x improvement in single env mentioned in the README? #158

Answered by Trinkle23897
LucasAlegre asked this question in Q&A
Discussion options

You must be logged in to vote
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

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by LucasAlegre
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants