Repoaner commited on
Commit
28ab3f3
·
verified ·
1 Parent(s): f2577d8

Upload LLaVA-Next-3D/checkcuda.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. LLaVA-Next-3D/checkcuda.py +34 -0
LLaVA-Next-3D/checkcuda.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+
3
+ def check_cuda():
4
+ # 检查是否有可用的 CUDA 设备
5
+ if torch.cuda.is_available():
6
+ print("CUDA is available!")
7
+
8
+ # 获取可用的 CUDA 设备数量
9
+ num_devices = torch.cuda.device_count()
10
+ print(f"Number of CUDA devices available: {num_devices}")
11
+
12
+ # 输出每个设备的信息
13
+ for i in range(num_devices):
14
+ device_name = torch.cuda.get_device_name(i)
15
+ memory_allocated = torch.cuda.memory_allocated(i)
16
+ memory_reserved = torch.cuda.memory_reserved(i)
17
+ print(f"\nDevice {i}: {device_name}")
18
+ print(f" Memory Allocated: {memory_allocated / 1024**2:.2f} MB")
19
+ print(f" Memory Reserved: {memory_reserved / 1024**2:.2f} MB")
20
+ print(f" Max Memory Allocated: {torch.cuda.max_memory_allocated(i) / 1024**2:.2f} MB")
21
+ print(f" Max Memory Reserved: {torch.cuda.max_memory_reserved(i) / 1024**2:.2f} MB")
22
+
23
+ # 获取当前默认的 CUDA 设备
24
+ current_device = torch.cuda.current_device()
25
+ print(f"\nCurrently using CUDA device: {torch.cuda.get_device_name(current_device)}")
26
+
27
+ # 获取当前设备的详细信息
28
+ print(f" Memory Allocated (Current): {torch.cuda.memory_allocated(current_device) / 1024**2:.2f} MB")
29
+ print(f" Memory Reserved (Current): {torch.cuda.memory_reserved(current_device) / 1024**2:.2f} MB")
30
+ else:
31
+ print("CUDA is not available.")
32
+
33
+ # 调用函数检查 CUDA 状态
34
+ check_cuda()