Spaces:
Runtime error
Runtime error
ljy266987
commited on
Commit
·
3b1bd69
1
Parent(s):
4d99f77
try
Browse files
app.py
CHANGED
@@ -13,6 +13,21 @@ import subprocess
|
|
13 |
result = subprocess.run(
|
14 |
['nvidia-smi'], text=True
|
15 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
##
|
18 |
|
|
|
13 |
result = subprocess.run(
|
14 |
['nvidia-smi'], text=True
|
15 |
)
|
16 |
+
##
|
17 |
+
import torch
|
18 |
+
|
19 |
+
# 检查CUDA是否可用
|
20 |
+
if torch.cuda.is_available():
|
21 |
+
print("CUDA is available. Listing available GPUs:")
|
22 |
+
# 获取并打印GPU数量
|
23 |
+
num_gpus = torch.cuda.device_count()
|
24 |
+
for i in range(num_gpus):
|
25 |
+
print(f"GPU {i}: {torch.cuda.get_device_name(i)}")
|
26 |
+
# 其他相关信息,例如内存
|
27 |
+
print(f" Memory Allocated: {torch.cuda.memory_allocated(i) / 1024 ** 2:.0f} MB")
|
28 |
+
print(f" Memory Reserved: {torch.cuda.memory_reserved(i) / 1024 ** 2:.0f} MB")
|
29 |
+
else:
|
30 |
+
print("CUDA is not available.")
|
31 |
|
32 |
##
|
33 |
|