I had the same error message as @MCvin with pytorch 1.8.1 running faster r-cnn code. I tried a few things to reproduce it. It seems to work fine for small value of n. I tried this while running FRCNN code through vscode debugging. Yet, I was not able to reproduce it outside like @oo_o did.

It was fixed by updating with nightly build  ‘1.9.0.dev20210502’.
OS: Ubuntu 20.04
GPU: RTX 3090
Pytorch 1.8.1 / Cuda 11.1