If you are using the terminal you can tell it which cuda devices it can access with the device number from nvidia-smi. The first gpu is named indexed with 0. For eg to run on your second gpu: CUDA_VISIBLE_DEVICES=1 python densenet161.py