if you can give me a script to reproduce this, what I would do is put a printf in https://github.com/pytorch/pytorch/blob/master/torch/lib/THC/THCCachingHostAllocator.cpp#L258 87 and see what the size or ptr values are when the failure occurs. From there, I would backtrack to see why these failure values are being generated.