Skip to content

Commit 631901b

Browse files
authored
Add torch version constraint to be equal or less than 2.8.0 to prevent breaking onnx changes in torch 2.9.0 (#6251)
* Pin torch version to 2.8.0 to prevent breaking onnx changes in 2.9.0 The ` 2.9.0` version results in an issue finding `onnxscript`. Pinning the `2.8.0` prevent this error. I'm not exactly of the exact root cause but it seems there were some backwards incompatible changes to onnx: https://github.com/pytorch/pytorch/releases/tag/v2.9.0#backwards-incompatible-changes. Stack trace on exiting training: ``` File "C:\Users\Samuel\miniconda3\envs\mlagents\lib\site-packages\mlagents\trainers\torch_entities\model_serialization.py", line 164, in export_policy_model torch.onnx.export( File "C:\Users\Samuel\miniconda3\envs\mlagents\lib\site-packages\torch\onnx\__init__.py", line 282, in export from torch.onnx._internal.exporter import _compat File "C:\Users\Samuel\miniconda3\envs\mlagents\lib\site-packages\torch\onnx\_internal\exporter\_compat.py", line 16, in <module> from torch.onnx._internal.exporter import ( File "C:\Users\Samuel\miniconda3\envs\mlagents\lib\site-packages\torch\onnx\_internal\exporter\_core.py", line 18, in <module> import onnxscript ModuleNotFoundError: No module named 'onnxscript' ``` * Add torch version constraint to be equal or less than 2.8.0 Previously commit forced only 2.8.0, however adding this constraint is a bit nicer, as I see in some of installation docs sometimes torch 2.2.0 is installed: https://github.com/Unity-Technologies/ml-agents/blob/release_22_docs/docs/Installation.md. * Update CHANGELOG.md
1 parent d1147c1 commit 631901b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

com.unity.ml-agents/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to
1212
- Fixed tensor indexing to use correct CHW layout (#6239)
1313

1414
#### ml-agents / ml-agents-envs
15+
- Set the Torch version constraint to 2.8 (#6251)
1516
- Fixed CUDA/CPU mismatch in threaded training (#6245)
1617

1718
## [4.0.0] - 2025-08-15

ml-agents/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def run(self):
6262
"Pillow>=4.2.1",
6363
"protobuf>=3.6,<3.21",
6464
"pyyaml>=3.1.0",
65-
"torch>=2.1.1",
65+
"torch>=2.1.1,<=2.8.0",
6666
"tensorboard>=2.14",
6767
# adding six explicit dependency since tensorboard needs it but doesn't declare it as a dep
6868
"six>=1.16",

0 commit comments

Comments
 (0)