MCPcopy Create free account
hub / github.com/pytorch/executorch / get_gpu_info

Function get_gpu_info

util/collect_env.py:184–207  ·  view source on GitHub ↗
(run_lambda)

Source from the content-addressed store, hash-verified

182
183
184def get_gpu_info(run_lambda):
185 if get_platform() == "darwin" or (
186 TORCH_AVAILABLE
187 and hasattr(torch.version, "hip")
188 and torch.version.hip is not None
189 ):
190 if TORCH_AVAILABLE and torch.cuda.is_available():
191 if torch.version.hip is not None:
192 prop = torch.cuda.get_device_properties(0)
193 if hasattr(prop, "gcnArchName"):
194 gcnArch = " ({})".format(prop.gcnArchName)
195 else:
196 gcnArch = "NoGCNArchNameOnOldPyTorch"
197 else:
198 gcnArch = ""
199 return torch.cuda.get_device_name(None) + gcnArch
200 return None
201 smi = get_nvidia_smi()
202 uuid_regex = re.compile(r" \(UUID: .+?\)")
203 rc, out, _ = run_lambda(smi + " -L")
204 if rc != 0:
205 return None
206 # Anonymize GPUs by removing their UUID
207 return re.sub(uuid_regex, "", out)
208
209
210def get_running_cuda_version(run_lambda):

Callers 1

get_env_infoFunction · 0.85

Calls 5

get_platformFunction · 0.85
get_nvidia_smiFunction · 0.85
is_availableMethod · 0.80
get_device_nameMethod · 0.45
compileMethod · 0.45

Tested by

no test coverage detected