skillfed

stable-baselines3

Pytorch version of Stable Baselines, implementations of reinforcement learning algorithms.

stable-baselines3 v2.9.0 1.4M downloads/30d#3,934 on PyPI13,690
Permissive license MIT Active released

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-baselines3

uv

uv add stable-baselines3

poetry

poetry add stable-baselines3

Installing 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

Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13

Tags

reinforcement learning algorithms pytorchRL policy training gymnasiumstable baselines PPO DQNRL agent training frameworkdeep reinforcement learning baselinegym environment policy learningRL algorithm implementations
reinforcement-learningpytorchagent-training

More Artificial Intelligence packages

Further reading