How to restrict Trainer to use certain GPUs?
I have 8 gpus on my machine, I only want to train the model with for first 4 gpus. How can I achieve that?
2022-04-26T06:56:39Z
Try again, but add the os.environ call before you import anything else. Soimport os
os.environ["CUDA_VISIBLE_DEVICES"] = "0,1,2,3"

from transformers import Trainer
...If you’re using Jupyter, you can also use magic commands (again, at the top, before importing anything else):%env CUDA_VISIBLE_DEVICES=0,1,2,3

from transformers import Trainer
...
2024-02-25T08:48:48Z
How about in cases where you would want to have additional training steps, and increase the number of devices each time? It looks like this method would need a new instance of each script