[Bug]: ReplayBuffer cannot detect the real memory constraints in Kubernetes.
Author: LarryLiZimoCreated Nov 1, 2025Updated Aug 28, 2026
Labelsdocumentationcheck the checklist
Bug
In stable_baselines3/common/buffers.py, around line 200, it uses psutil to determine available memories, which fails to detect the actually available memory.
# in the `__init__` of `ReplayBuffer`
if psutil is not None:
mem_available = psutil.virtual_memory().availableMy server has over 700G memory but only 64 G available in my k8s container. I ran a training script, which is estimated to require 30 G memory. As a consequence, it is terminated silently. If warned earlier by StableBaslines3, other users may be spared of this potential problem.
To Reproduce
No response
Relevant log output / Error message
System Info
No response
Checklist
- My issue does not relate to a custom gym environment. (Use the custom gym env template instead)
- I have checked that there is no similar issue in the repo
- I have read the documentation
- I have provided a minimal and working example to reproduce the bug
- I've used the markdown code blocks for both code and stack traces.
Source: DLR-RM/stable-baselines3