Add function to get the amount of memory used by torch tensors#676
Add function to get the amount of memory used by torch tensors#676fmassa wants to merge 1 commit intotorch:masterfrom
Conversation
| {"pointer", luaT_lua_pointer}, | ||
| {"setheaptracking", torch_setheaptracking}, | ||
| {"updateerrorhandlers", torch_updateerrorhandlers}, | ||
| {"getmemory", torch_getmemory}, |
There was a problem hiding this comment.
How about memoryused? It might be more self-explanatory.
There was a problem hiding this comment.
I agree that simply getmemory is not a good name.
memoryused is indeed better.
Any other opinions ? cutorch has a getMemoryUsage (which prints the total memory available and the memory used for the GPU). Maybe it would be good to have some uniformity in there.
There was a problem hiding this comment.
getMemoryUsage sounds good to me as well 😄 I agree that it might be better to keep it similar.
There was a problem hiding this comment.
but there is a difference between getMemoryUsage and this PR in the sense that this PR aims at showing the memory used by torch, and not the total memory used. BTW, the same PR could be done in cutorch, in which case we would have different functions which behave differently but with a similar purpose.
There was a problem hiding this comment.
Hm, ok, you're right. Do you have any suggestions for the name? getTorchMemory[Usage]?
There was a problem hiding this comment.
Sounds a bit as if it would return Lua's heap size as well, but I like it.
There was a problem hiding this comment.
torch.tensormemoryusage_if_youre_not_using_too_many_threads_plusOrMinus100MB()
|
Also, I could add |
Allows to get the amount of memory used by torch tensors.
In conjunction with
collectgarbage('count'), we can have some good estimates of the total amount of memory used (except if other data structures are used, liketds).Note: as
heapSizeis only updated by batches of ~ 1MB, so creating really small tensors won't show any immediate difference.I will add docs if we agree to merge this.