-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetInfo.py
More file actions
30 lines (21 loc) · 1.18 KB
/
Copy pathgetInfo.py
File metadata and controls
30 lines (21 loc) · 1.18 KB
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
28
29
import pycuda.autoinit
import pycuda.driver as drv
def get_gpu_info():
device = drv.Device(0) # 0 represents the first GPU, change it to the appropriate GPU index if needed
# Get device properties
props = device.get_attributes()
# Get the number of SMs (CUDA cores)
num_sm = props[drv.device_attribute.MULTIPROCESSOR_COUNT]
# Get the size of shared memory per block
shared_mem_per_block = props[drv.device_attribute.MAX_SHARED_MEMORY_PER_BLOCK]
# Get the maximum number of threads per block
max_threads_per_block = props[drv.device_attribute.MAX_THREADS_PER_BLOCK]
# Get the maximum number of warps per block
max_warps_per_block = props[drv.device_attribute.MAX_THREADS_PER_MULTIPROCESSOR] // 32
return num_sm, shared_mem_per_block, max_threads_per_block, max_warps_per_block
if __name__ == "__main__":
num_sm, shared_mem_per_block, max_threads_per_block, max_warps_per_block = get_gpu_info()
print(f"Number of SMs on the GPU: {num_sm}")
print(f"Shared memory per block: {shared_mem_per_block / 1024} KB")
print(f"Max number of thread per block: {max_threads_per_block}")
print(f"Max number of warp per block: {max_warps_per_block}")