Stable-Baselines3

Reliable, tested implementations of reinforcement learning algorithms (PPO, DQN, SAC, A2C and TD3) on PyTorch with a simple API.

ActiveBeginnerv2.9.2MITReinforcement Learning

Official documentationTry the examples

Basic information

NameStable-Baselines3
Full nameStable-Baselines3
CategoryReinforcement Learning
DeveloperDLR-RM and the SB3 community
Release yearNot specified
Official websitegithub.com/DLR-RM/stable-baselines3
GitHub repositoryDLR-RM/stable-baselines3
Official documentationstable-baselines3.readthedocs.io
Package on PyPIstable-baselines3
LicenseMIT (PyPI license)
Project statusActive Had a release in the last 12 months
Latest version26 October 2026 (version 2.9.2)
Programming languagePython
Operating systemsNot specified
Required Python version>=3.10
Difficulty levelBeginner

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

Reinforcement Learning

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 supportSupported
GPU supportSupported
CUDA compatibilitySupported
Distributed training or computingPartial or through an add-onMultiple parallel environments on one machine.
Automatic differentiation (Autodiff)SupportedThrough PyTorch.
Model deploymentPartial or through an add-on
Pre-trained modelsPartial or through an add-onTrained models through RL Zoo and the Hugging Face Hub.
Supported data typesGymnasium environments
Integration with other librariesGymnasium, PyTorch
Flexibility (editorial estimate)Medium
Performance (editorial estimate)Good
Community (editorial estimate)Large
Documentation quality (editorial estimate)Excellent documentation

Installation and running

Shell
pip install stable-baselines3

Compatibility: 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.

Python — example.py
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.

Requirements

Shell
pip install stable-baselines3 gymnasium

How to run

Save the code in a file example.py then run it:

Shell
python example.py

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

Example page

All Stable-Baselines3 examples in the Code Explorer

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

VersionRelease dateChecked on
2.9.226 October 202621 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.

Report information that needs updating