-
Notifications
You must be signed in to change notification settings - Fork 845
Expand file tree
/
Copy pathtest.py
More file actions
27 lines (22 loc) · 727 Bytes
/
Copy pathtest.py
File metadata and controls
27 lines (22 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python3
import gc
import torch
def clear_memory():
"""Free GPU and CPU memory before running SGLang."""
try:
if torch.cuda.is_available():
torch.cuda.empty_cache()
torch.cuda.ipc_collect()
torch.cuda.synchronize()
gc.collect()
print("✅ Memory cleared")
except Exception as e:
print(f"⚠️ Memory cleanup failed: {e}")
print('testing SGLang...')
clear_memory() # <-- Clean before anything else
import sglang as sgl
print(f"SGLang version: {sgl.__version__}")
print(f"CUDA available: {torch.cuda.is_available()}")
if torch.cuda.is_available():
print(f"CUDA device: {torch.cuda.get_device_name(0)}")
print('SGLang OK\n')