deepinsight / deepinsight/insightface
Limit GPU Memory Usage
- Dominant language
- Python
- Stars
- 29.7k
- Forks
- 6.1k
- PR merge metrics
- No merged PRs in 30d
Description
**Is there a way that we can limit the Memory Allocation used by this Model to allow for Concurrent Models to Run?**
After loading the first model the GPU Mem stats reflect:
`utilization.gpu 74 utilization.memory 0 memory.free 13353 memory.used 2777 memory.total 16130`
After running the first inference through, it balloons, but the `GPU Utilization` is still very low at `3`:
`utilization.gpu 3 utilization.memory 0 memory.free 9789 memory.used 6341 memory.total 16130`
This makes me think that we should be able to load more models onto the same GPU, but unfortunately the memory is already allocated to MXNet.
---
**Solutions Tried:**
1. Trying `ctx.empty_cache()` between calls to the model - https://mxnet.apache.org/api/python/docs/api/mxnet/context/index.html#mxnet.context.Context.empty_cache
2. Trying `MXNET_GPU_MEM_POOL_RESERVE:60` - https://discuss.mxnet.io/t/how-to-limit-gpu-memory-usage/6304/3
2. Using `gc.collect()` https://stackoverflow.com/questions/47661254/reset-gpu-memory-using-keras-1-2-2-with-mxnet-backend/48939575#48939575
But none of these worked. Any thoughts?
[1]: https://github.com/deepinsight/insightface
[2]: https://i.stack.imgur.com/yTcXN.png
[3]: https://i.stack.imgur.com/j2cYW.png
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.