[Help] RuntimeError: CUDA error: device-side assert triggered

I meet cuda Error when I tried to do slice operation.

                sub_x = [xx[sub_valid_indices, ...] for xx in x]
            except Exception as e:
                print("### x.shape={}, sub_valid_indices={}".format([xx.shape for xx in x], sub_valid_indices))

The output log is “x.shape=[torch.Size([2, 3, 32, 32])], sub_valid_indices=[0, 1]”
It seems that the indice is not output of range.

Is your code running fine on the CPU? Generally, it should give you a better error message.
If so, could you rerun the code with CUDA_LAUNCH_BLOCKING=1 python script.py args and post the complete error message here?