Skip to main content

Async agents for Stable Baselines 3

Project description

Async Gym Agents

Wrapper environments and agent injectors to allow for drop-in async training.

import gymnasium as gym
from functools import partial
from stable_baselines3 import TD3

from async_gym_agents.agents.async_agent import get_injected_agent
from async_gym_agents.envs.multi_env import IndexableMultiEnv
from async_gym_agents.profiler import render_profiler_report

# Create env with 8 parallel envs (Also supports VecEnvs)
env = IndexableMultiEnv([partial(gym.make, "Pendulum-v1") for i in range(8)])

# Create the model, injected with async capabilities
model = get_injected_agent(TD3)("MlpPolicy", env, use_mp=False)

# Train the model
model.learn(total_timesteps=10)

# Inspect main-thread and worker timing
report = model.get_profiler_report()
print(render_profiler_report(report))

# Shut down workers
model.shutdown()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

async_gym_agents-0.3.1.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

async_gym_agents-0.3.1-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file async_gym_agents-0.3.1.tar.gz.

File metadata

  • Download URL: async_gym_agents-0.3.1.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.8 Windows/10

File hashes

Hashes for async_gym_agents-0.3.1.tar.gz
Algorithm Hash digest
SHA256 538218cad4a02d2adf09ea596fdf5fa13a701c9ed68838aa2f769df900673571
MD5 b1ff89f5c251ef384ca8f9aa3b05555f
BLAKE2b-256 146820996cd2bbb20b735433cbdc4e007a240bd6ac9a256e6297abae8d913906

See more details on using hashes here.

File details

Details for the file async_gym_agents-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: async_gym_agents-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 23.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.8 Windows/10

File hashes

Hashes for async_gym_agents-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 650eb1a16549616ab8817cf646184e593cc9b1de7d0a6cce62abc272cc731d68
MD5 86071ab3e840939710e9ab6fd83735ba
BLAKE2b-256 8c4cb0182ce836b9296d234df7e22e7792b907f13f87f3192439ea2f40f69305

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page