Stable-Baselines3
Reliable, tested implementations of reinforcement learning algorithms (PPO, DQN, SAC, A2C and TD3) on PyTorch with a simple API.
Basic information
| Name | Stable-Baselines3 |
|---|---|
| Full name | Stable-Baselines3 |
| Category | Reinforcement Learning |
| Developer | DLR-RM and the SB3 community |
| Release year | Not specified |
| Official website | github.com/DLR-RM/stable-baselines3 |
| GitHub repository | DLR-RM/stable-baselines3 |
| Official documentation | stable-baselines3.readthedocs.io |
| Package on PyPI | stable-baselines3 |
| License | MIT (PyPI license) |
| Project status | Active Had a release in the last 12 months |
| Latest version | 26 October 2026 (version 2.9.2) |
| Programming language | Python |
| Operating systems | Not specified |
| Required Python version | >=3.10 |
| Difficulty level | Beginner |
Data last checked: 21 November 2026 — source: PyPI JSON API (2026-11-21)
Overview
SB3 provides reinforcement learning algorithms with a scikit-learn-like API (learn and predict), comprehensive tests and benchmarks, the RL Zoo library of tuned hyperparameters, and sb3-contrib for extra algorithms.
The best starting point for applying reinforcement learning to a Gymnasium environment without writing the algorithms from scratch.
When to choose it? Choose it to apply reliable reinforcement learning algorithms quickly.
Uses
Main uses
- Training agents on Gymnasium environments
- Reliable baselines
Scientific fields
- Reinforcement Learning
- Robotics
Suitable project types
- An agent that learns CartPole or LunarLander
Research applications
- Baselines for comparison
Technical features
A feature is shown as "Supported" only if it is documented in the library's official documentation; anything we have not verified is shown as "Not specified".
| CPU support | Supported |
|---|---|
| GPU support | Supported |
| CUDA compatibility | Supported |
| Distributed training or computing | Partial or through an add-onMultiple parallel environments on one machine. |
| Automatic differentiation (Autodiff) | SupportedThrough PyTorch. |
| Model deployment | Partial or through an add-on |
| Pre-trained models | Partial or through an add-onTrained models through RL Zoo and the Hugging Face Hub. |
| Supported data types | Gymnasium environments |
| Integration with other libraries | Gymnasium, PyTorch |
| Flexibility (editorial estimate) | Medium |
| Performance (editorial estimate) | Good |
| Community (editorial estimate) | Large |
| Documentation quality (editorial estimate) | Excellent documentation |
Installation and running
pip install stable-baselines3Compatibility: Python >=3.10 — according to the package data on PyPI, checked on 21 November 2026
Installing inside a virtual environment (venv or conda) is recommended. If you need compatibility with a specific CUDA version or operating system, refer to the official documentation, because this information changes with every release.
Code examples
Examples marked "Run and tested" were actually run, with their output, test date and library versions recorded; the others need a GPU or model downloads, so they were not run in the test environment.
MediumTraining PPO on CartPoleRun and tested
Goal: Training an agent with a ready algorithm and evaluating it.
import gymnasium as gym
from stable_baselines3 import PPO
from stable_baselines3.common.evaluation import evaluate_policy
env = gym.make("CartPole-v1")
model = PPO("MlpPolicy", env, seed=0, verbose=0, device="cpu")
mean0, _ = evaluate_policy(model, env, n_eval_episodes=5)
model.learn(total_timesteps=20_000)
mean, std = evaluate_policy(model, env, n_eval_episodes=10)
print(f"Return before training: {mean0:.1f}")
print(f"Return after 20k steps: {mean:.1f} ± {std:.1f}")
Code explanation
We create PPO with an MLP policy and train for a limited number of steps, then evaluate with evaluate_policy on separate episodes. The maximum return in CartPole-v1 is 500. The result depends on the number of steps and the seed.
Output recorded during testing
Return before training: 250.4 Return after 20k steps: 500.0 ± 0.0
This example was actually run and tested on 21 November 2026 on a CPU — stable-baselines3 2.9.2, gymnasium 1.4.0, python 3.13.18
Pros
- Reliable, tested implementations
- A simple API
Limitations
- Less suited to radical changes to the algorithms
- Not aimed at large-scale distribution
References and verification
- Package page on PyPI (source of the version, licence and release date) Checked directly
https://pypi.org/project/stable-baselines3/
Checked on: 21 November 2026 — version checked: 2.9.2 — reviewed by: the DLArabic team
- Official website A link the package officially declares on PyPI
https://github.com/DLR-RM/stable-baselines3
Checked on: 21 November 2026 — reviewed by: the DLArabic team
- Official documentation A link the package officially declares on PyPI
https://stable-baselines3.readthedocs.io/
Checked on: 21 November 2026 — reviewed by: the DLArabic team
- Official repository A link the package officially declares on PyPI
https://github.com/DLR-RM/stable-baselines3
Checked on: 21 November 2026 — reviewed by: the DLArabic team
History of verified versions
| Version | Release date | Checked on |
|---|---|---|
| 2.9.2 | 26 October 2026 | 21 November 2026 |
Page information last reviewed: 21 November 2026. The description was written originally for the encyclopedia and is not copied from the official websites.
