stable-baselines3
Pytorch version of Stable Baselines, implementations of reinforcement learning algorithms.
What it is and what it does
Stable Baselines3 is a collection of production-ready reinforcement learning algorithms implemented in PyTorch. It provides a unified, scikit-learn-inspired interface for training RL agents on Gymnasium environments, making it accessible for both researchers and practitioners. The library abstracts away low-level implementation details while maintaining flexibility for customization.
The package is built on top of gymnasium, numpy, torch, and cloudpickle, handling the complexity of policy networks, value functions, and training loops so users can focus on environment design and hyperparameter tuning. It supports algorithms like PPO and DQN and is designed as a foundation for building new RL approaches or comparing novel methods against established baselines.
Use it for:
- Train a reinforcement learning agent on a custom or standard Gymnasium environment for robotics or game-playing tasks.
- Establish a baseline for comparing new RL algorithms or techniques against well-tested implementations.
- Prototype RL solutions quickly using pre-built algorithms without implementing training loops from scratch.
- Conduct RL research with a modular, extensible codebase that separates policy, value, and environment concerns.
- Deploy trained RL policies in production systems where reproducibility and reliability are critical.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Stable Baselines3 provides PyTorch implementations of reinforcement learning algorithms designed to work with Gymnasium environments, following a scikit-learn-like API for training and inference.
Yes. Stable Baselines3 is actively maintained, has no known vulnerabilities, installs with low friction, and is widely used (top 5000 PyPI packages). It's the standard choice for RL practitioners who want reliable algorithm implementations without reinventing core components. Install it if you're training RL agents or need a trusted baseline for comparison.
Install
stable-baselines3 on PyPI
pip
pip install stable-baselines3uv
uv add stable-baselines3poetry
poetry add stable-baselines3Installing stable-baselines3
Before you install
Low install friction with a pure-Python wheel and four runtime dependencies (gymnasium, numpy, torch, cloudpickle). The project is actively maintained with a recent release and high repository engagement (13690 stars), indicating stable ongoing support.
License in practice
MIT license permits commercial and private use with minimal restrictions, making the package suitable for both research and production deployments without licensing concerns.
Quickstart
pip install stable-baselines3
import gymnasium
from stable_baselines3 import PPO
env = gymnasium.make("CartPole-v1")
model = PPO("MlpPolicy", env, verbose=1)
model.learn(total_timesteps=10_000)
action, _states = model.predict(env.reset()[0])
Requires PyTorch (torch) as a runtime dependency; ensure a compatible PyTorch installation is available for your system before importing.
Verify before relying
- Whether pre-trained model checkpoints or zoo environments are available beyond the core library.
- Performance characteristics and scalability limits for large-scale RL training tasks.
- GPU acceleration requirements and CUDA compatibility details for torch-based training.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — gymnasium, numpy, torch, cloudpickle |
| Maintenance | actively maintained — 60 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,412,536/month — #3,934 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: stable_baselines3-2.9.0-py3-none-any.whl
Keywords: reinforcement-learning-algorithms, reinforcement-learning, machine-learning, gymnasium, gym, openai, stable, baselines, toolbox, python, data-science
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
sb3-contribProvides experimental reinforcement learning…
permissive · top 15,000 on PyPI
tianshouTianshou is a PyTorch-based reinforcement…
permissive · top 15,000 on PyPI
gymnasiumGymnasium provides a standard Python API for…
permissive · top 5,000 on PyPI
dopamine-rlDopamine is a research framework for…
permissive · top 15,000 on PyPI
skrlskrl is a modular reinforcement learning…
permissive · top 15,000 on PyPI
rsl-rl-libRSL-RL is a GPU-accelerated reinforcement…
permissive · top 15,000 on PyPI
reasoning-gymReasoning Gym generates procedurally verifiable…
permissive · top 15,000 on PyPI
nemo-gymNeMo Gym provides infrastructure for building,…
permissive · top 5,000 on PyPI
torchrlTorchRL is a PyTorch-native toolkit for…
unclear · top 5,000 on PyPI
gym-alohaProvides a Gymnasium environment for the ALOHA…
permissive · top 15,000 on PyPI