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.3.tar.gz (16.6 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.3-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: async_gym_agents-0.3.3.tar.gz
  • Upload date:
  • Size: 16.6 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.3.tar.gz
Algorithm Hash digest
SHA256 d9d519e08473c743eaf44b96ad7ba5b5794f20197a08c72165f59a9d2d91d2ee
MD5 7560d2349d7cc0d52f8977a63671ada7
BLAKE2b-256 13d7256e623fbb352442873af9c972b72535e8442e7a26442993d08c69c1d1a3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: async_gym_agents-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 23.1 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ab20b9b015eb6f2551dcd1368a2df1a54888a31abc8b052f044959f9bf1519ad
MD5 5a5f8867eec4987ade4770e9659e9f3e
BLAKE2b-256 cfc98f23d0ffbf6e10a3380c603bde25dac8a81159e110f3e76b60a4c59d204f

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