Detectron2: specify gpu id

Created on 1 Nov 2019  Â·  7Comments  Â·  Source: facebookresearch/detectron2

hi, I have 8 gpus but want to use 4 gpus whose id are 4,5,6,7 to train a model, what should I do?

All 7 comments

You can use the CUDA_VISIBLE_DEVICES environment variable.

@ppwwyyxx sorry, could you please explain more clearly? How can I use CUDA_VISIBLE_DEVICES environment variable?

I trie to set cfg.MODEL.DEVICE = 'cuda:3' but bug arised as follw:
RuntimeError: CUDA out of memory. Tried to allocate 238.00 MiB (GPU 3; 15.90 GiB total capacity; 15.20 GiB already allocated; 1.88 MiB free; 9.25 MiB cached)
I'm sure that GPU 3 is empty.

You can google CUDA_VISIBLE_DEVICES. such as https://stackoverflow.com/questions/39649102/how-do-i-select-which-gpu-to-run-a-job-on

You need to use smaller batch size if running on fewer GPUs, as mentioned in https://github.com/facebookresearch/detectron2/blob/master/GETTING_STARTED.md#train-a-standard-model

good job

You can google CUDA_VISIBLE_DEVICES. such as https://stackoverflow.com/questions/39649102/how-do-i-select-which-gpu-to-run-a-job-on

You need to use smaller batch size if running on fewer GPUs, as mentioned in https://github.com/facebookresearch/detectron2/blob/master/GETTING_STARTED.md#train-a-standard-model

Which file should I add CUDA_VISIBLE_DEVICES when I first try with demo?

Which file should I add CUDA_VISIBLE_DEVICES when I first try with demo?

You could either do
CUDA_VISIBLE_DEVICES=2,3 python xxx.py
or like it's mentioned in the stackoverflow link above first run
export CUDA_VISIBLE_DEVICES=0,2 then run the python script
python xxx.py

How can i set it if I want to use GPU 3,4:
cfg.MODEL.DEVICE = 'cuda:3'

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marcoippolito picture marcoippolito  Â·  4Comments

jinfagang picture jinfagang  Â·  3Comments

joeythegod picture joeythegod  Â·  4Comments

wytcsuch picture wytcsuch  Â·  4Comments

AntonBaumannDE picture AntonBaumannDE  Â·  3Comments