geowatch.utils.util_nvidia module¶
Ported from netharn.device, previously called gpu_infos
- geowatch.utils.util_nvidia.nvidia_smi(ignore_environ=False)[source]¶
Run nvidia-smi and parse output
- Parameters:
new_mode – internal argument that changes the underlying implementation
ignore_environ (bool) – if True respects CUDA_VISIBLE_DEVICES environment variable, otherwise returns data corresponding to physical GPU indexes. Defaults to False.
- Returns:
info about each nvidia GPU indexed by gpu number
- Return type:
Note
Not gaurenteed to work if CUDA is not installed.
Warning
if nvidia-smi is not found
Example
>>> # xdoctest: +REQUIRES(env:HAS_CUDA) >>> from geowatch.utils.util_nvidia import * # NOQA >>> gpus = nvidia_smi() >>> # xdoctest: +IGNORE_WANT >>> import torch >>> print('gpus = {}'.format(ub.repr2(gpus, nl=4))) >>> assert len(gpus) == torch.cuda.device_count() gpus = { 0: { 'gpu_uuid': 'GPU-348ebe36-252b-46fa-8a97-477ae331f6f4', 'index': '0', 'mem_avail': 10013.0, 'mem_total': 11170.0, 'mem_used': 1157.0, 'memory.free': '10013 MiB', 'memory.total': '11170 MiB', 'memory.used': '1157 MiB', 'name': 'GeForce GTX 1080 Ti', 'num': 0, 'num_compute_procs': 1, 'procs': [ { 'gpu_num': 0, 'gpu_uuid': 'GPU-348ebe36-252b-46fa-8a97-477ae331f6f4', 'name': '/usr/bin/python', 'pid': '19912', 'type': 'C', 'used_memory': '567 MiB', }, ], }, }