Automated adaption of batch_size to available GPU memory
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- julia
- Domain
- machine-learning
Research direction
Start with the Julia prototype's memoryPerBatch and guessBatchSize functions, then trace the corresponding mx.simple_bind, mx.gpu, and mx.debug_str entry points. Define how automatic batch sizing should use available GPU memory and what result the library should return for varying models and input sizes.
Written by the indexing model from the issue text.
Description
I am running a different set of models upon different input sizes and so it is not very straightforward to choose an optimal batch-size for each model/input combination.
I came up with the following solution I maybe MXNet should provide something similar.
global const GPU_MEM_MAX = 11000 # M6000 has 12000 MiB
"""
size dim1...dim3 example (256, 256, 1)
"""
function memoryPerBatch(net, size)
exec = mx.simple_bind(net, mx.gpu(), data=(size..., 1))
dbg_str = mx.debug_str(exec)
mem_str = split(dbg_str, ['\n'])[end-2]
m = match(r"Total (\d+) MB allocated", mem_str)
finalize(exec.handle)
exec = nothing
parse(Int, m.captures[1])
end
function guessBatchSize(net, size, max = GPU_MEM_MAX)
mem = memoryPerBatch(net, size)
info("Memory required per batch: $mem MB")
nbatch = max ÷ mem
nbatch = ispow2(nbatch) ? nbatch : prevpow2(nbatch)
info("Using a batch_size of $nbatch. Total memory ≈ $(nbatch*mem) MB")
return nbatch
end
- Dominant language
- No language data
- Stars
- 370
- Forks
- 63
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dmlc/MXNet.jl
-
Import fail MXNET.jlOpen
Difficulty 3/5 1-2 days Newbie friendliness 28/100
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ScrollPrize/villa#2299 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 83/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
good first issue neural P2
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 2 days