If you mask the GPUs via CUDA_VISIBLE_DEVICES, the device ids inside the script will be mapped to [0, nb_gpus], which would mean you should use 0, 1, 2 in the script.
Could you change it and see, if it would solve the issue?