I had the same problem with the same error message.
It occurs when I use GPU2 and GPU3 of the system.
The batch size is 32 so certainly larger than the number of GPUs.
To solve this problem I used the CUDA_VISIBLE_DEVICES flag:
CUDA_VISIBLE_DEVICES=2,3 python3 train.py 17 --gpu_ids 0,1