Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardcoded GPU 0? #9

Open
mfelice opened this issue Mar 24, 2021 · 2 comments · May be fixed by #23
Open

Hardcoded GPU 0? #9

mfelice opened this issue Mar 24, 2021 · 2 comments · May be fixed by #23

Comments

@mfelice
Copy link

mfelice commented Mar 24, 2021

Hi there,

I'm facing an issue with your PyTorch implementation and some input sentences. E.g.

s = 'RT @HISPANlCPROBS : When u walk straight into the kitchen to eat & ur mom hits u with the " ya saludaste " #ThanksgivingWithHispanics https://…'
print(scorer.score_sentences([s]))

gives the following error:

RuntimeError: CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 11.91 GiB total capacity; 451.65 MiB already allocated; 12.12 MiB free; 40.35 MiB cached)

I'm working on a server with three GPUs and tried setting ctxs = [mx.gpu(0)], ctxs = [mx.gpu(1)], ctxs = [mx.gpu(2)] and ctxs = [mx.cpu()] but I always get the same error about GPU 0. I'm wondering if this is hardcoded somewhere in your code? Changing the ctxs variable seems to have no effect.

Thanks.

@DarrenAbramson
Copy link

From the fourth line of the readme:

ctxs = [mx.cpu()] # or, e.g., [mx.gpu(0), mx.gpu(1)]

Did you happen to try ctxs = [mx.gpu(0), mx.gpu(1), mx.gpu(2)]?

As for finding things that are hard-coded, are you aware that you can search the repository?

@mfelice
Copy link
Author

mfelice commented Mar 24, 2021

Thanks! The values in ctxs seem to be ignored. However, I've been able to circumvent the issue by setting CUDA_VISIBLE_DEVICES. I believe the culprit is cuda:0 and/or device_ids=[0] in the following block:

self._device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
torch.manual_seed(0)
torch.cuda.manual_seed_all(0)
# TODO: This does not restrict to specific GPUs however, use CUDA_VISIBLE_DEVICES?
# TODO: It also unnecessarily locks the GPUs to each other
self._model.to(self._device)
self._model = torch.nn.DataParallel(self._model, device_ids=[0])
self._model.eval()

Maybe that should be set to whatever is specified by ctxs?

@zolastro zolastro linked a pull request Dec 20, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants