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.4.tar.gz (16.8 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.4-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: async_gym_agents-0.3.4.tar.gz
  • Upload date:
  • Size: 16.8 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.4.tar.gz
Algorithm Hash digest
SHA256 b640fd60bbf462cc5c2e3e68ea8117a2a10a3fb508926c4408fd2a360908413f
MD5 83e0cf48084729eb4f9d9c94b172038f
BLAKE2b-256 eada75481a5e3d59c78192e5742a961d1cdb835a3f3089884793f28d83a76f98

See more details on using hashes here.

File details

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

File metadata

  • Download URL: async_gym_agents-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 23.4 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ade5f02d9e7aca0107c83695ef57f8ebde98b6d1f0a444ddb580bb6ae9d66152
MD5 e40119d0af6932392544fc474b6eb26b
BLAKE2b-256 2bce7aa7e4a1f332e374ca850c4e8836405a1d878b0b8c8ed7a2e8cc42fefa43

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