ContinualAI / ContinualAI/avalanche

avalanche.evaluation.metrics.gpu_usage on Mac's MPS

Open
#1,347 1 comment 0 reactions 0 assignees View on GitHub
bug
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.

![image](https://user-images.githubusercontent.com/43968173/233664145-4923a98b-f19e-42c9-a6f6-f31658554197.png)

🐜 **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**
![image](https://user-images.githubusercontent.com/43968173/233663572-30e4377c-bc5b-4dba-a832-cd3976f1d587.png)

![image](https://user-images.githubusercontent.com/43968173/233663964-632ae78a-06bf-4331-bcc2-a7f40d4145f7.png)

![image](https://user-images.githubusercontent.com/43968173/233664323-cb70718e-6ff9-44ad-b62f-e4656e5297d8.png)

🦋 **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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.