Delete check_cuda.py
Browse files- check_cuda.py +0 -19
check_cuda.py
DELETED
|
@@ -1,19 +0,0 @@
|
|
| 1 |
-
import pynvml
|
| 2 |
-
|
| 3 |
-
pynvml.nvmlInit()
|
| 4 |
-
handle = pynvml.nvmlDeviceGetHandleByIndex(0)
|
| 5 |
-
info = pynvml.nvmlDeviceGetMemoryInfo(handle)
|
| 6 |
-
print(f"显存总大小: {info.total / 1024**3:.2f} GB")
|
| 7 |
-
print(f"显存已用: {info.used / 1024**3:.2f} GB")
|
| 8 |
-
print(f"显存空闲: {info.free / 1024**3:.2f} GB")
|
| 9 |
-
|
| 10 |
-
try:
|
| 11 |
-
procs = pynvml.nvmlDeviceGetComputeRunningProcesses(handle)
|
| 12 |
-
if len(procs) == 0:
|
| 13 |
-
print("⚠️ 没有检测到计算进程(可能被隐藏或在容器外)")
|
| 14 |
-
for p in procs:
|
| 15 |
-
print(f"PID: {p.pid}, 显存占用: {p.usedGpuMemory / 1024**2:.0f} MB")
|
| 16 |
-
except Exception as e:
|
| 17 |
-
print(f"获取进程失败: {e}")
|
| 18 |
-
|
| 19 |
-
pynvml.nvmlShutdown()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|