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

Memory should be completely released after an OOM happens #17126

@lorenzob

Description

@lorenzob

Description

After a cudaMalloc failed: out of memory error is raised everything becomes unusable with more out of memory errors (even if a smaller batch is provided).

If I load two models both become unusable after the OOM.

Error Message

Traceback (most recent call last):
  File "core/facerec.py", line 673, in <module>
    img_result, distances = compare(list(images_data), "work/")
  File "core/facerec.py", line 183, in compare
    embedding = model.model.get_outputs()[0].asnumpy()
  File "/home/trz/miniconda3/envs/facerec/lib/python3.6/site-packages/mxnet/ndarray/ndarray.py", line 1996, in asnumpy
    ctypes.c_size_t(data.size)))
  File "/home/trz/miniconda3/envs/facerec/lib/python3.6/site-packages/mxnet/base.py", line 253, in check_call
    raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: [18:53:03] src/storage/./pooled_storage_manager.h:157: cudaMalloc failed: out of memory
Stack trace:
  [bt] (0) /home/trz/miniconda3/envs/facerec/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x4b04cb) [0x7f1c3a28f4cb]
  [bt] (1) /home/trz/miniconda3/envs/facerec/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x2e653eb) [0x7f1c3cc443eb]
  [bt] (2) /home/trz/miniconda3/envs/facerec/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x2e6af0f) [0x7f1c3cc49f0f]
  [bt] (3) /home/trz/miniconda3/envs/facerec/lib/python3.6/site-packages/mxnet/libmxnet.so(mxnet::NDArray::CheckAndAlloc() const+0x1cc) [0x7f1c3a307aac]
  [bt] (4) /home/trz/miniconda3/envs/facerec/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x25db3b8) [0x7f1c3c3ba3b8]
  [bt] (5) /home/trz/miniconda3/envs/facerec/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x25db777) [0x7f1c3c3ba777]
  [bt] (6) /home/trz/miniconda3/envs/facerec/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x25e1b6d) [0x7f1c3c3c0b6d]
  [bt] (7) /home/trz/miniconda3/envs/facerec/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x25c1cd1) [0x7f1c3c3a0cd1]
  [bt] (8) /home/trz/miniconda3/envs/facerec/lib/python3.6/site-packages/mxnet/libmxnet.so(+0x25c51e0) [0x7f1c3c3a41e0]

To Reproduce

Invoke the model with a large enough batch to get an OOM. Now call it again with a small batch that would not throw as OOM if called on its own. This small batch throws an OOM too.

It looks like the memory from the previous call is not completely released.

What have you tried to solve it?

mxnet.context.current_context().empty_cache()
mxnet.gpu(0).empty_cache()

Environment

We recommend using our script for collecting the diagnositc information. Run the following command and paste the outputs below:

----------Python Info----------
Version      : 3.6.7
Compiler     : GCC 7.3.0
Build        : ('default', 'Oct 23 2018 19:16:44')
Arch         : ('64bit', '')
------------Pip Info-----------
Version      : 19.1
Directory    : /home/trz/miniconda3/envs/CenterNet/lib/python3.6/site-packages/pip
----------MXNet Info-----------
Version      : 1.5.1
Directory    : /home/trz/miniconda3/envs/facerec/lib/python3.6/site-packages/mxnet
Num GPUs     : 1
Commit Hash   : c9818480680f84daa6e281a974ab263691302ba8
----------System Info----------
Platform     : Linux-4.15.0-72-generic-x86_64-with-debian-buster-sid
system       : Linux
node         : acqua
release      : 4.15.0-72-generic
version      : #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019
----------Hardware Info----------
machine      : x86_64
processor    : x86_64
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              12
On-line CPU(s) list: 0-11
Thread(s) per core:  2
Core(s) per socket:  6
Socket(s):           1
NUMA node(s):        1
Vendor ID:           GenuineIntel
CPU family:          6
Model:               158
Model name:          Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Stepping:            10
CPU MHz:             3790.389
CPU max MHz:         4100,0000
CPU min MHz:         800,0000
BogoMIPS:            4416.00
Virtualization:      VT-x
L1d cache:           32K
L1i cache:           32K
L2 cache:            256K
L3 cache:            9216K
NUMA node0 CPU(s):   0-11
Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d
----------Network Test----------
Setting timeout: 10
Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0279 sec, LOAD: 0.5680 sec.
Timing for GluonNLP GitHub: https://github.com/dmlc/gluon-nlp, DNS: 0.0017 sec, LOAD: 0.5182 sec.
Timing for GluonNLP: http://gluon-nlp.mxnet.io, DNS: 0.0592 sec, LOAD: 0.5766 sec.
Timing for D2L: http://d2l.ai, DNS: 0.0408 sec, LOAD: 0.0685 sec.
Timing for D2L (zh-cn): http://zh.d2l.ai, DNS: 0.0288 sec, LOAD: 0.2421 sec.
Timing for FashionMNIST: https://repo.mxnet.io/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0983 sec, LOAD: 0.8585 sec.
Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0438 sec, LOAD: 0.5219 sec.
Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0302 sec, LOAD: 0.1939 sec.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions