Skip to content

Commit

Permalink
Add compute capability resolver
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Baczek <[email protected]>
  • Loading branch information
jbaczek committed Aug 10, 2023
1 parent 00fb374 commit 981a9a7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions nemo/core/config/hydra_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@
from hydra.types import TaskFunction
from omegaconf import DictConfig, OmegaConf

def _get_gpu_name():
import pynvml
pynvml.nvmlInit()
handle = pynvml.nvmlDeviceGetHandleByIndex(0)
cuda_capability, _ = pynvml.nvmlDeviceGetCudaComputeCapability(handle)
pynvml.nvmlShutdown()
if cuda_capability == 8:
return "a100"
elif cuda_capability == 9:
return "h100"
else:
return None

omegaconf.OmegaConf.register_new_resolver("gpu_name", _get_gpu_name)

# multiple interpolated values in the config
OmegaConf.register_new_resolver("multiply", lambda x, y: x * y)

Expand Down

0 comments on commit 981a9a7

Please sign in to comment.