diff --git a/torchbenchmark/util/experiment/instantiator.py b/torchbenchmark/util/experiment/instantiator.py index 08d13d9cc..f98e1380a 100644 --- a/torchbenchmark/util/experiment/instantiator.py +++ b/torchbenchmark/util/experiment/instantiator.py @@ -122,8 +122,9 @@ def list_devices() -> List[str]: devices = ["cpu"] import torch - if torch.cuda.is_available(): - devices.append("cuda") + device_type = torch._C._get_accelerator().type + if device_type != "cpu": + devices.append(device_type) return devices diff --git a/torchbenchmark/util/experiment/metrics.py b/torchbenchmark/util/experiment/metrics.py index fd206b22a..c27d3f66f 100644 --- a/torchbenchmark/util/experiment/metrics.py +++ b/torchbenchmark/util/experiment/metrics.py @@ -82,7 +82,7 @@ def get_peak_memory( raise ValueError( f"Expected metrics_needed to be non-empty, get: {metrics_needed}" ) - if metrics_gpu_backend in ["dcgm", "nvml"]: + if device == "cuda" and metrics_gpu_backend in ["dcgm", "nvml"]: from torchbenchmark._components.model_analyzer.TorchBenchAnalyzer import ( ModelAnalyzer, )