We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
https://pypi.org/project/nvidia-ml-py/
From torch.cuda:
def _raw_device_uuid_nvml() -> Optional[List[str]]: r"""Return list of device UUID as reported by NVML or None if NVM discovery/initialization failed.""" from ctypes import byref, c_int, c_void_p, CDLL, create_string_buffer nvml_h = CDLL("libnvidia-ml.so.1") rc = nvml_h.nvmlInit() if rc != 0: warnings.warn("Can't initialize NVML") return None dev_count = c_int(-1) rc = nvml_h.nvmlDeviceGetCount_v2(byref(dev_count)) if rc != 0: warnings.warn("Can't get nvml device count") return None uuids: List[str] = [] for idx in range(dev_count.value): dev_id = c_void_p() rc = nvml_h.nvmlDeviceGetHandleByIndex_v2(idx, byref(dev_id)) if rc != 0: warnings.warn("Can't get device handle") return None buf_len = 96 buf = create_string_buffer(buf_len) rc = nvml_h.nvmlDeviceGetUUID(dev_id, buf, buf_len) if rc != 0: warnings.warn("Can't get device UUID") return None uuids.append(buf.raw.decode("ascii").strip("\0")) del nvml_h return uuids def _get_nvml_device_index(device: Optional[Union[int, Device]]) -> int: r"""Return the NVML index of the device, taking CUDA_VISIBLE_DEVICES into account.""" idx = _get_device_index(device, optional=True) visible_devices = _parse_visible_devices() if type(visible_devices[0]) is str: uuids = _raw_device_uuid_nvml() if uuids is None: raise RuntimeError("Can't get device UUIDs") visible_devices = _transform_uuid_to_ordinals( cast(List[str], visible_devices), uuids ) visible_devices = cast(List[int], visible_devices) if idx < 0 or idx >= len(visible_devices): raise RuntimeError( f"device {idx} is not visible (CUDA_VISIBLE_DEVICES={visible_devices})" ) return visible_devices[idx]
Sorry, something went wrong.
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: