Hi, I tried to find the equivalent of torch.cuda.memory_reserved() for libtorch but could not find it. I tried torch::cuda::memory_reserved() but it gives error: ‘memory_allocated’ is not a member of ‘torch::cuda’
You could try to use:
const DeviceStats stats =
c10::cuda::CUDACachingAllocator::getDeviceStats(device);
and then access its attributes:
stats.reserved_bytes;
stats.allocated_bytes;
...
Thanks for fast reply.
One can follow this as well: C++ Memory Management API · Issue #85436 · pytorch/pytorch · GitHub
Best,