MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / print_device_info

Function print_device_info

python/1_GettingStarted/deviceQuery/deviceQuery.py:128–286  ·  view source on GitHub ↗

Print detailed information for a single CUDA device. Uses device.properties (cuda.core) for most fields; cuda.bindings for runtime version and global memory (not yet in high-level API).

(dev_id, device)

Source from the content-addressed store, hash-verified

126
127
128def print_device_info(dev_id, device):
129 """
130 Print detailed information for a single CUDA device.
131 Uses device.properties (cuda.core) for most fields; cuda.bindings for
132 runtime version and global memory (not yet in high-level API).
133 """
134 device.set_current()
135 props = device.properties
136
137 print()
138 print(f"Device {dev_id}: {device.name}")
139
140 # cuda.bindings workaround: runtime version not in cuda.core
141 driver_major, driver_minor = system.get_user_mode_driver_version()
142 err, runtime_version = cudart.cudaRuntimeGetVersion()
143 if err != cudart.cudaError_t.cudaSuccess:
144 raise RuntimeError(f"Failed to get CUDA runtime version: {err}")
145 runtime_major = runtime_version // 1000
146 runtime_minor = (runtime_version % 1000) // 10
147
148 print_property(
149 "CUDA Driver Version / Runtime Version",
150 f"{driver_major}.{driver_minor} / {runtime_major}.{runtime_minor}",
151 )
152 print_property(
153 "CUDA Capability Major/Minor version number:",
154 f"{props.compute_capability_major}.{props.compute_capability_minor}",
155 )
156
157 # cuda.bindings workaround: global memory (free/total) not in device.properties
158 err, free_mem, total_mem_bytes = cuda.cuMemGetInfo()
159 if err != cuda.CUresult.CUDA_SUCCESS:
160 raise RuntimeError(f"Failed to get memory info: {err}")
161 print_property("Total amount of global memory:", fmt_bytes(total_mem_bytes))
162
163 sm_cores = convert_sm_ver_to_cores(
164 props.compute_capability_major, props.compute_capability_minor
165 )
166 total_cores = sm_cores * props.multiprocessor_count
167 print_property(
168 f"({props.multiprocessor_count:3d}) Multiprocessors, "
169 f"({sm_cores:3d}) CUDA Cores/MP:",
170 f"{total_cores} CUDA Cores",
171 )
172
173 print_property("GPU Max Clock rate:", fmt_hz(props.clock_rate))
174 print_property("Memory Clock rate:", f"{props.memory_clock_rate * 1e-3:.0f} Mhz")
175 print_property("Memory Bus Width:", f"{props.global_memory_bus_width}-bit")
176 if props.l2_cache_size > 0:
177 print_property("L2 Cache Size:", f"{props.l2_cache_size} bytes")
178
179 print_property(
180 "Maximum Texture Dimension Size (x,y,z)",
181 f"1D=({props.maximum_texture1d_width}), "
182 f"2D=({props.maximum_texture2d_width}, {props.maximum_texture2d_height}), "
183 f"3D=({props.maximum_texture3d_width}, {props.maximum_texture3d_height}, "
184 f"{props.maximum_texture3d_depth})",
185 )

Callers 1

query_devicesFunction · 0.70

Calls 5

print_propertyFunction · 0.85
fmt_bytesFunction · 0.85
convert_sm_ver_to_coresFunction · 0.85
fmt_hzFunction · 0.85
fmt_yes_noFunction · 0.85

Tested by

no test coverage detected