openpi-realworld / openpi /scripts /test_swap.py
Howard Ji
Update openpi code, add VLAC pipeline, track dualview code
2a8368c
Raw
History Blame Contribute Delete
996 Bytes
"""Quick test: allocate more RAM than available and verify swap catches it."""
import numpy as np
import psutil
def main():
mem = psutil.virtual_memory()
swap = psutil.swap_memory()
print(f"RAM: {mem.total / 1e9:.0f}GB total, {mem.available / 1e9:.0f}GB available")
print(f"Swap: {swap.total / 1e9:.0f}GB total, {swap.used / 1e9:.0f}GB used")
print()
target_gb = 300
chunk_gb = 10
chunks = []
print(f"Allocating {target_gb}GB in {chunk_gb}GB chunks...")
for i in range(target_gb // chunk_gb):
chunks.append(np.ones(int(chunk_gb * 1e9 / 8), dtype=np.float64))
allocated = (i + 1) * chunk_gb
swap_now = psutil.swap_memory()
mem_now = psutil.virtual_memory()
print(f" {allocated:>4}GB allocated | RAM used: {mem_now.used / 1e9:.1f}GB | swap used: {swap_now.used / 1e9:.1f}GB")
print()
print("SUCCESS: allocated 300GB without OOM. Swap is working.")
del chunks
if __name__ == "__main__":
main()