File tree Expand file tree Collapse file tree
cuda_bindings/examples/4_CUDA_Libraries Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -85,8 +85,6 @@ def print_table():
8585 try :
8686 persistence = nvml .device_get_persistence_mode (handle )
8787 persistence_str = "On" if persistence == nvml .EnableState .FEATURE_ENABLED else "Off"
88- except nvml .NotSupportedError :
89- persistence_str = "Unsupp."
9088 except nvml .NvmlError :
9189 persistence_str = "N/A"
9290
@@ -142,21 +140,26 @@ def print_table():
142140
143141 try :
144142 mem_info = nvml .device_get_memory_info_v2 (handle )
143+ except nvml .NvmlError :
144+ mem_str = "N/A"
145+ else :
145146 mem_used = format_size (mem_info .used )
146147 mem_total = format_size (mem_info .total )
147148 mem_str = f"{ mem_used } / { mem_total } "
148- except nvml .NvmlError :
149- mem_str = "N/A"
150149
151150 try :
152151 util_rates = nvml .device_get_utilization_rates (handle )
153- gpu_util = util_rates .gpu
154- util_str = f"{ gpu_util : >3} %"
155152 except nvml .NvmlError :
156153 util_str = "N/A"
154+ else :
155+ gpu_util = util_rates .gpu
156+ util_str = f"{ gpu_util : >3} %"
157157
158158 try :
159159 compute_mode = nvml .device_get_compute_mode (handle )
160+ except nvml .NvmlError :
161+ comp_str = "N/A"
162+ else :
160163 if compute_mode == nvml .ComputeMode .COMPUTEMODE_DEFAULT :
161164 comp_str = "Default"
162165 elif compute_mode == nvml .ComputeMode .COMPUTEMODE_EXCLUSIVE_PROCESS :
@@ -165,8 +168,6 @@ def print_table():
165168 comp_str = "Prohibited"
166169 else :
167170 comp_str = "Unknown"
168- except nvml .NvmlError :
169- comp_str = "N/A"
170171
171172 formatter .print_values (
172173 str (i ),
You can’t perform that action at this time.
0 commit comments