Ugh, nice finding! That should probably do it. Note that PyTorch tensors also keep the data packed, so you can use them instead of numpy indices too.
Just be careful with pinned memory when it’s already under a high pressure. Pinned memory is never swapped out, so it can possibly freeze or crash the system if there’s too much of it.
Thanks!