From 285e01f64aa8ba4bd15aa339c45876d56ed0c3b4 Mon Sep 17 00:00:00 2001 From: Antonin RAFFIN Date: Sat, 27 Apr 2024 15:08:38 +0200 Subject: [PATCH] Hotfix: revert loading with `weights_only=True` (#1913) --- docs/misc/changelog.rst | 17 +++++++++++++++++ stable_baselines3/common/save_util.py | 3 ++- stable_baselines3/version.txt | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/misc/changelog.rst b/docs/misc/changelog.rst index 4fa9043..203f15e 100644 --- a/docs/misc/changelog.rst +++ b/docs/misc/changelog.rst @@ -33,11 +33,23 @@ Others: Bug Fixes: ^^^^^^^^^^ +Documentation: +^^^^^^^^^^^^^^ + +Release 2.3.2 (2024-04-27) +-------------------------- + +Bug Fixes: +^^^^^^^^^^ +- Reverted ``torch.load()`` to be called ``weights_only=False`` as it caused loading issue with old version of PyTorch. + + Documentation: ^^^^^^^^^^^^^^ - Added ER-MRL to the project page (@corentinlger) - Updated Tensorboard Logging Videos documentation (@NickLucche) + Release 2.3.1 (2024-04-22) -------------------------- @@ -55,6 +67,11 @@ Release 2.3.0 (2024-03-31) **New defaults hyperparameters for DDPG, TD3 and DQN** +.. warning:: + + Because of ``weights_only=True``, this release breaks loading of policies when using PyTorch 1.13. + Please upgrade to PyTorch >= 2.0 or upgrade SB3 version (we reverted the change in SB3 2.3.2) + Breaking Changes: ^^^^^^^^^^^^^^^^^ diff --git a/stable_baselines3/common/save_util.py b/stable_baselines3/common/save_util.py index 2d86520..a85c9c2 100644 --- a/stable_baselines3/common/save_util.py +++ b/stable_baselines3/common/save_util.py @@ -447,7 +447,8 @@ def load_from_zip_file( file_content.seek(0) # Load the parameters with the right ``map_location``. # Remove ".pth" ending with splitext - th_object = th.load(file_content, map_location=device, weights_only=True) + # Note(antonin): we cannot use weights_only=True, as it breaks with PyTorch 1.13, see GH#1911 + th_object = th.load(file_content, map_location=device, weights_only=False) # "tensors.pth" was renamed "pytorch_variables.pth" in v0.9.0, see PR #138 if file_path == "pytorch_variables.pth" or file_path == "tensors.pth": # PyTorch variables (not state_dicts) diff --git a/stable_baselines3/version.txt b/stable_baselines3/version.txt index e96f44f..f90b1af 100644 --- a/stable_baselines3/version.txt +++ b/stable_baselines3/version.txt @@ -1 +1 @@ -2.4.0a0 +2.3.2