Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[MXNET-1430] julia: implement context.gpu_memory_info #16324

Merged
merged 3 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions julia/NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
* Add an abstract type `AbstractMXError` as the parent type for all MXNet-related
API errors. (#16235)

* Porting more `context` functions from Python.
* `num_gpus()` (#16236)
* `gpu_memory_info()` (#16324)


# v1.5.0

Expand Down
3 changes: 2 additions & 1 deletion julia/src/MXNet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export Executor,
export Context,
cpu,
gpu,
num_gpus
num_gpus,
gpu_memory_info

# model.jl
export AbstractModel,
Expand Down
18 changes: 18 additions & 0 deletions julia/src/context.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,21 @@ function num_gpus()
@mxcall :MXGetGPUCount (Ref{Cint},) n
n[]
end

"""
gpu_memory_info(dev_id = 0)::Tuple{UInt64,UInt64}

Query CUDA for the free and total bytes of GPU global memory.
It returns a tuple of `(free memory, total memory)`.

```julia-repl
julia> mx.gpu_memory_info()
(0x00000003af240000, 0x00000003f9440000)
```
"""
function gpu_memory_info(dev_id = 0)
free = Ref{UInt64}()
n = Ref{UInt64}()
@mxcall :MXGetGPUMemoryInformation64 (Cint, Ref{UInt64}, Ref{UInt64}) dev_id free n
free[], n[]
end
2 changes: 0 additions & 2 deletions python/mxnet/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,6 @@ def gpu_memory_info(device_id=0):
Returns
-------
(free, total) : (int, int)
The number of GPUs.

"""
free = ctypes.c_uint64()
total = ctypes.c_uint64()
Expand Down