Look up tensor device member inside Tensor is_pinned() implementation instead of accepting an outside input #128988
Labels
module: cuda
Related to torch.cuda, and CUDA support in general
triaged
This issue has been looked at a team member, and triaged and prioritized into an appropriate module
🚀 The feature, motivation and pitch
Background: We recently found a bug where our cpu_test_tensor.is_pinned() call unexpectedly consumed considerable memory. The original cpu_test_tensor was on the device="cpu". It turned out, however, that is_pinned accepts an optional device input param and by default the internal implementation assumes device="cuda", so possibly Cuda context was created consuming additional memory. We are fixing the immediate problem with PR 128896 by passing device=cpu_tensor.device to is_pinned call.
Proposal: Drop the optional device input to is_pinned() and instead just have it automatically look up the device member field from the self Tensor object itself. This should make for a more robust API where user avoids being defaulted to a possibly incorrect device value.
Alternatives
No response
Additional context
See D58687049 for a repro of the original memory problem.
cc @ptrblck @msaroufim
The text was updated successfully, but these errors were encountered: