-
Notifications
You must be signed in to change notification settings - Fork 33
Add get_memory_allocated() and get_memory_allocated_gb() functions
#515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
get_memory_allocated() and get_memory_allocated_gc() functionsget_memory_allocated() and get_memory_allocated_gb() functions
|
If xla allocates memory from the start, then this count will be off? Maybe we could leverage the xla APIs for this: It seems we can get allocation stats per device. |
|
I apologize, but I'm actually not very familiar with Julia and XLA, and I'm not sure how to proceed with improvements. I'm basically clueless when it comes to Julia and C++. |
|
usage: julia> using Reactant
julia> v = []
Any[]
julia> vr = []
Any[]
julia> for i=1:10
push!(v,rand(1,1000000*2^i))
end
julia> for i=1:10
r = Reactant.to_rarray(v[i])
push!(vr,r)
end
julia> get_memory_allocated()
16368000000
julia> print_largest_arrays()
Top 5 arrays by memory usage:
1. Type: Float64, Shape: (1, 1024000000), Size: 7812.5 MB, Client: Reactant.XLA.Client(Ptr{Nothing} @0x0000000000ea8a80)
2. Type: Float64, Shape: (1, 512000000), Size: 3906.25 MB, Client: Reactant.XLA.Client(Ptr{Nothing} @0x0000000000ea8a80)
3. Type: Float64, Shape: (1, 256000000), Size: 1953.12 MB, Client: Reactant.XLA.Client(Ptr{Nothing} @0x0000000000ea8a80)
4. Type: Float64, Shape: (1, 128000000), Size: 976.56 MB, Client: Reactant.XLA.Client(Ptr{Nothing} @0x0000000000ea8a80)
5. Type: Float64, Shape: (1, 64000000), Size: 488.28 MB, Client: Reactant.XLA.Client(Ptr{Nothing} @0x0000000000ea8a80)
julia> get_memory_allocated_gb()
15.243887901306152
julia> print_largest_arrays(3)
Top 3 arrays by memory usage:
1. Type: Float64, Shape: (1, 1024000000), Size: 7812.5 MB, Client: Reactant.XLA.Client(Ptr{Nothing} @0x0000000000ea8a80)
2. Type: Float64, Shape: (1, 512000000), Size: 3906.25 MB, Client: Reactant.XLA.Client(Ptr{Nothing} @0x0000000000ea8a80)
3. Type: Float64, Shape: (1, 256000000), Size: 1953.12 MB, Client: Reactant.XLA.Client(Ptr{Nothing} @0x0000000000ea8a80)
|
No problems, I was just suggesting another possible option. I tried to kickstart the needed c++ in #517 but this might be of limited use since for example the stats are not implemented for the CPU device (I have yet to try on GPU). |
not sure about this, but i checked out the internals a couple of weeks ago. could it be that it works for GPU because it uses a memory pool for that, while for CPU it just allocates as requested? |
|
closed in favor of #517 |
This PR will solve #503
You can use the functions like this to see how much memory is used by
Reactant.jl!