Not being able to use mutiple gpus even when i use nn.Dataparallel command

You could either run your script with

import os 
os.environ["CUDA_VISIBLE_DEVICES"] = "0,1" # or other GPU ids if you want to 

#your other imports and code

Or setting it in the terminal before executing your script by

export CUDA_VISIBLE_DEVICES=0,1

If you want to keep it permanent you can add the last variant to your .profile or your .bashrc

2 Likes