When a computer has multiple CUDA-capable GPUs, each GPU is assigned a device ID. By default, CUDA kernels execute on device ID 0. You can use
device ID
device ID 0
Set the environment variable CUDA_DEVICE_ORDER as:
CUDA_DEVICE_ORDER
export CUDA_DEVICE_ORDER=PCI_BUS_ID
Then the GPU IDs will be ordered by pci bus IDs.