avalanche
avalanche copied to clipboard
avalanche.evaluation.metrics.gpu_usage on Mac's MPS
🐛 Describe the bug The gpu usage metrics does not see GPU for Mac's MPS.
🐜 To Reproduce Having run this code:
import GPUtil
gpus = GPUtil.getGPUs()
n_gpus = len(GPUtil.getGPUs())
print(f'The MPS GPUs: {gpus}')
print(f'The MPS number of GPUs {n_gpus}')
That is the output The MPS GPUs: [] The MPS number of GPUs 0
Although clearly the GPU is available:
if torch.cuda.is_available():
device = 'cuda:0'
torch.backends.cudnn.benchmark = True
device_count = torch.cuda.device_count()
print(f"Found {device_count} CUDA GPU devices.")
elif torch.backends.mps.is_available():
device = 'mps'
else:
device = 'cpu'
print(f'Using {device} device')
Output: Using mps device
🐝 Expected behavior The GPU metric would be correctly measured for Mac's GPU. Right now it is always 0.
🐞 Screenshots
🦋 Additional context
Having a look on the https://avalanche-api.continualai.org/en/v0.2.0/_modules/avalanche/evaluation/metrics/gpu_usage.html
I see that there is GPUtil
library responsible for detecting the GPU. Most likely it works only for CUDA.
Hi @Bard2803
I see that there is GPUtil library responsible for detecting the GPU. Most likely it works only for CUDA
That's correct. Unfortunately the GPUtils
package only works with CUDA-compatible GPUs. I've also been using avalanche with MPS for a while, but I haven't been able to find a (stable) python package that retrieves the GPU utilization for the Apple silicon GPUs. There are ways to get the GPU utilization using powermetrics
but that requires sudo access. Do you know any package that works without sudo access?