ContinualAI / ContinualAI/avalanche
avalanche.evaluation.metrics.gpu_usage on Mac's MPS
- Dominant language
- Python
- Stars
- 2.1k
- Forks
- 321
- PR merge metrics
- No merged PRs in 30d
Description
🐛 **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.
Contributor guide
Assessment
This issue has not been assessed yet.