Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

stable-baselines3

> AI 编程
Open source

PyTorch version of Stable Baselines, reliable implementations of reinforcement learning algorithms.

13.6K stars0 likes0 views
WebsiteGitHub

About

PyTorch version of Stable Baselines, reliable implementations of reinforcement learning algorithms.

Stable Baselines3

Stable Baselines3 (SB3) is a set of reliable implementations of reinforcement learning algorithms in PyTorch. It is the next major version of Stable Baselines.

You can read a detailed presentation of Stable Baselines3 in the v1.0 blog post or our JMLR paper.

These algorithms will make it easier for the research community and industry to replicate, refine, and identify new ideas, and will create good baselines to build projects on top of. We expect these tools will be used as a base around which new ideas can be added, and as a tool for comparing a new approach against existing ones. We also hope that the simplicity of these tools will allow beginners to experiment with a more advanced toolset, without being buried in implementation details.

Note: Despite its simplicity of use, Stable Baselines3 (SB3) assumes you have some knowledge about Reinforcement Learning (RL). You should not utilize this library without some practice. To that extent, we provide good resources in the documentation to get started with RL.

Main Features

The performance of each algorithm was tested (see Results section in their respective page). You can take a look at the issues #48 and #49 for more details.

We also provide detailed logs and reports on the OpenRL Benchmark platform.

Features Stable-Baselines3
State of the art RL methods :heavy_check_mark:
Documentation :heavy_check_mark:
Custom environments :heavy_check_mark:
Custom policies :heavy_check_mark:
Common interface :heavy_check_mark:
Dict observation space support :heavy_check_mark:
Ipython / Notebook friendly :heavy_check_mark:
Tensorboard support :heavy_check_mark:
PEP8 code style :heavy_check_mark:
Custom callback :heavy_check_mark:
High code coverage :heavy_check_mark:
Type hints :heavy_check_mark:

Planned features

Since most of the features from the original roadmap have been implemented, there are no major changes planned for SB3; it is now stable. If you want to contribute, you can search in the issues for the ones where help is welcomed and the other proposed enhancements.

While SB3 development is now focused on bug fixes and maintenance (doc update, user experience, ...), there is more active development going on in the associated repositories:

  • newer algorithms are regularly added to the SB3 Contrib repository
  • faster variants are developed in the SBX (SB3 + Jax) repository
  • the training framework for SB3, the RL Zoo, has an active roadmap

Migration guide: from Stable-Baselines (SB2) to Stable-Baselines3 (SB3)

A migration guide from SB2 to SB3 can be found in the documentation.

Documentation

Documentation is available online: https://stable-baselines3.readthedocs.io/

Integrations

Stable-Baselines3 has some integration with other libraries/services like Weights & Biases for experiment tracking or Hugging Face for storing/sharing trained models. You can find out more in the dedicated section of the documentation.

RL Baselines3 Zoo: A Training Framework for Stable Baselines3 Reinforcement Learning Agents

RL Baselines3 Zoo is a training framework for Reinforcement Learning (RL).

It provides scripts for training, evaluating agents, tuning hyperparameters, plotting results and recording videos.

In addition, it includes a collection of tuned hyperparameters for common environments and RL algorithms, and agents trained with those settings.

Goals of this repository:

  1. Provide a simple interface to train and enjoy RL agents
  2. Benchmark the different Reinforcement Learning algorithms
  3. Provide tuned hyperparameters for each environment and RL algorithm
  4. Have fun with the trained agents!

Github repo: https://github.com/DLR-RM/rl-baselines3-zoo

Documentation: https://rl-baselines3-zoo.readthedocs.io/en/master/

SB3-Contrib: Experimental RL Features

We implement experimental features in a separate contrib repository: SB3-Contrib

This allows SB3 to maintain a stable and compact core, while still providing the latest features, like Recurrent PPO (PPO LSTM), CrossQ, Truncated Quantile Critics (TQC), Quantile Regression DQN (QR-DQN) or PPO with invalid action masking (Maskable PPO).

Documentation is available online: https://sb3-contrib.readthedocs.io/

Stable-Baselines Jax (SBX)

Stable Baselines Jax (SBX) is a proof of concept version of Stable-Baselines3 in Jax, with recent algorithms like DroQ or CrossQ.

It provides a minimal number of features compared to SB3 but can be much faster (up to 20x times!): https://twitter.com/araffin2/status/1590714558628253698

Installation

Note: Stable-Baselines3 supports PyTorch >= 2.8

Prerequisites

Stable Baselines3 requires Python 3.10+.

Windows

To install stable-baselines on Windows, please look at the documentation.

Install using pip

Install the Stable Baselines3 package:

bash
pip install 'stable-baselines3[extra]'

This includes optional dependencies like Tensorboard, OpenCV, ale-py to train on atari games, as well as pandas and matplotlib for plotting and analyzing results. If you do not need those, you can use:

bash
pip install stable-baselines3

Please read the documentation for more details and alternatives (from source, using docker).

Example

Most of the code in the library tries to follow a sklearn-like syntax for the Reinforcement Learning algorithms.

Here is a quick example of how to train and run PPO on a cartpole environment:

python
import gymnasium as gym

from stable_baselines3 import PPO

env = gym.make("CartPole-v1", render_mode="human")

model = PPO("MlpPolicy", env, verbose=1)
model.learn(total_timesteps=10_000)

vec_env = model.get_env()
obs = vec_env.reset()
for i in range(1000):
    actions, _states = model.predict(obs, deterministic=True)
    obs, rewards, dones, info = vec_env.step(actions)
    vec_env.render()
    # VecEnv resets automatically
    # if done:
    #   obs = env.reset()

env.close()

Or just train a model with a one liner if the environment is registered in Gymnasium and if the policy is registered:

python
from stable_baselines3 import PPO

model = PPO("MlpPolicy", "CartPole-v1").learn(10_000)

Please read the documentation for more examples.

Try it online with Colab Notebooks!

All the following examples can be executed online using Google Colab notebooks:

  • Full Tutorial
  • All Notebooks
  • Getting Started
  • Training, Saving, Loading
  • Multiprocessing
  • Monitor Training and Plotting
  • Atari Games
  • RL Baselines Zoo
  • PyBullet

Implemented Algorithms

Name Recurrent Box Discrete MultiDiscrete MultiBinary Multi Processing
A2C :x: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
ARS1 :x: :heavy_check_mark: :heavy_check_mark: :x: :x: :heavy_check_mark:
CrossQ12 :x: :heavy_check_mark: :x: :x: :x: :heavy_check_mark:
DDPG :x: :heavy_check_mark: :x: :x: :x: :heavy_check_mark:
DQN :x: :x: :heavy_check_mark: :x: :x: :heavy_check_mark:
DroQ2 :x: :heavy_check_mark: :x: :x: :x: :heavy_check_mark:
HER :x: :heavy_check_mark: :heavy_check_mark: :x: :x: :heavy_check_mark:
Maskable PPO1 :x: :x: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
PPO :x: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
QR-DQN1 :x: :x: :heavy_check_mark: :x: :x: :heavy_check_mark:
RecurrentPPO1 :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
SAC :x: :heavy_check_mark: :x: :x: :x: :heavy_check_mark:
SAC-N2 :x: :heavy_check_mark: :x: :x: :x: :heavy_check_mark:
SimBa2 :x: :heavy_check_mark: :x: :x: :x: :heavy_check_mark:
TD3 :x: :heavy_check_mark: :x: :x: :x: :heavy_check_mark:
TQC1 :x: :heavy_check_mark: :x: :x: :x: :heavy_check_mark:
TRPO1 :x: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:

1: Implemented in SB3 Contrib GitHub repository.

2: Implemented in SBX (SB3 + Jax)

Action

Issues· 90 open

View all issuesOpen on GitHub
  • #2285

    [Bug] gSDE+tanh reconstruction changes PPO replay gradients despite a unit initial ratio

    LLM generatedUpdated Sep 21, 2026
  • #1790

    [Bug]: Reset options ignored when resetting due to termination / truncation from within wrapper's `step`

    bugdocumentationhelp wantedUpdated Sep 15, 2026
  • #2282

    [Bug]: Monitor with override_existing=False writes no header when the file is new

    Updated Sep 4, 2026
  • #2185

    [Bug]: ReplayBuffer cannot detect the real memory constraints in Kubernetes.

    documentationcheck the checklistUpdated Aug 28, 2026
  • #2279

    [Question] Why does VecNormalize normalize rewards by returns instead of rewards?

    duplicatequestionUpdated Aug 25, 2026
  • #2268

    [Bug]: VecEnv sub-environment seeds (seed + i) overlap across runs with adjacent base seeds

    bugUpdated Jul 24, 2026
  • #2090

    [Bug]: `is_image_space` works poorly with Gymnasium's `FrameStackObservation`

    bugdocumentationhelp wantedUpdated May 27, 2026
  • #1692

    [Bug]: Rendering with EvalCallback does not render the initial or final state

    bugUpdated May 26, 2026
  • #627

    [Bug] HER is not updating the done flag of HER transitions

    bugUpdated May 25, 2026
  • #2255

    [Bug]: Render Tests Failure (SDL_RumbleMotor Deps Duplicate)

    bugUpdated May 23, 2026

> Tags

Pythonbaselinesgsdegymmachine-learning

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 2, 2026
CategoryAI 编程
PricingOpen source

> Related tools

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.