mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

GPU out of memory error on `nce-loss/wordvec.py` example

Open philipskokoh opened this issue 9 years ago • 2 comments

I run example/nce-loss/wordvec.py using gpu, and it causes out of memory error. It works fine on cpu. I tried to reduce the batch_size until 8, but it didn't solve the problem.

Any suggestion on how to solve this problem? Thanks!

For bugs or installation issues, please provide the following information. The more information you provide, the more likely people will be able to help you.

Environment info

Operating System: Ubuntu 14.04 (DGX-1)

Compiler: Docker image (mxnet/python:gpu)

Package used (Python/R/Scala/Julia): Python

MXNet version: 0.10

Python version and distribution: Python 3.6.1 (Anaconda)

Error Message:

Please paste the full error message, including stack trace.

root@ff598b664d63:/mxnet/example/nce-loss# python wordvec.py --gpu
253855
wordvec.py:144: DeprecationWarning: mxnet.model.FeedForward has been deprecated. Please use mxnet.mod.Module instead.
  initializer=mx.init.Xavier(factor_type="in", magnitude=2.34))
../../python/mxnet/model.py:526: DeprecationWarning: Calling initializer with init(str, NDArray) has been deprecated.please use init(mx.init.InitDesc(...), NDArray) instead.
  self.initializer(k, v)
2017-06-23 12:44:32,581 Start training with [gpu(0)]
begin
[12:44:34] /mxnet/dmlc-core/include/dmlc/./logging.h:304: [12:44:34] src/storage/./pooled_storage_manager.h:84: cudaMalloc failed: out of memory

Stack trace returned 9 entries:
[bt] (0) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZN5mxnet7storage23GPUPooledStorageManager5AllocEm+0x3ec) [0x7f00e7b7c5fc]
[bt] (1) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZN5mxnet11StorageImpl5AllocEmNS_7ContextE+0x57) [0x7f00e7b80037]
[bt] (2) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZNK5mxnet7NDArray4dataEv+0x9b) [0x7f00e776569b]
[bt] (3) /mxnet/python/mxnet/../../lib/libmxnet.so(+0x135ed39) [0x7f00e7ba7d39]
[bt] (4) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZN5mxnet6engine14ThreadedEngine15ExecuteOprBlockENS_10RunContextEPNS0_8OprBlockE+0x87) [0x7f00e7b6eba7]
[bt] (5) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZNSt17_Function_handlerIFvvEZZN5mxnet6engine23ThreadedEnginePerDevice13PushToExecuteEPNS2_8OprBlockEbENKUlvE1_clEvEUlvE_E9_M_invokeERKSt9_Any_data+0x78) [0x7f00e7b76528]
[bt] (6) /root/anaconda3/bin/../lib/libstdc++.so.6(+0xb7260) [0x7f00d056f260]
[bt] (7) /lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba) [0x7f00f9a866ba]
[bt] (8) /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f00f8ea482d]

[12:44:34] /mxnet/dmlc-core/include/dmlc/./logging.h:304: [12:44:34] src/engine/./threaded_engine.h:329: [12:44:34] src/storage/./pooled_storage_manager.h:84: cudaMalloc failed: out of memory

Stack trace returned 9 entries:
[bt] (0) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZN5mxnet7storage23GPUPooledStorageManager5AllocEm+0x3ec) [0x7f00e7b7c5fc]
[bt] (1) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZN5mxnet11StorageImpl5AllocEmNS_7ContextE+0x57) [0x7f00e7b80037]
[bt] (2) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZNK5mxnet7NDArray4dataEv+0x9b) [0x7f00e776569b]
[bt] (3) /mxnet/python/mxnet/../../lib/libmxnet.so(+0x135ed39) [0x7f00e7ba7d39]
[bt] (4) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZN5mxnet6engine14ThreadedEngine15ExecuteOprBlockENS_10RunContextEPNS0_8OprBlockE+0x87) [0x7f00e7b6eba7]
[bt] (5) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZNSt17_Function_handlerIFvvEZZN5mxnet6engine23ThreadedEnginePerDevice13PushToExecuteEPNS2_8OprBlockEbENKUlvE1_clEvEUlvE_E9_M_invokeERKSt9_Any_data+0x78) [0x7f00e7b76528]
[bt] (6) /root/anaconda3/bin/../lib/libstdc++.so.6(+0xb7260) [0x7f00d056f260]
[bt] (7) /lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba) [0x7f00f9a866ba]
[bt] (8) /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f00f8ea482d]

An fatal error occurred in asynchronous engine operation. If you do not know what caused this error, you can try set environment variable MXNET_ENGINE_TYPE to NaiveEngine and run with debugger (i.e. gdb). This will force all operations to be synchronous and backtrace will give you the series of calls that lead to this error. Remember to set MXNET_ENGINE_TYPE back to empty after debugging.

Stack trace returned 6 entries:
[bt] (0) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZN4dmlc15LogMessageFatalD1Ev+0x3c) [0x7f00e6ddb9cc]
[bt] (1) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZN5mxnet6engine14ThreadedEngine15ExecuteOprBlockENS_10RunContextEPNS0_8OprBlockE+0x31c) [0x7f00e7b6ee3c]
[bt] (2) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZNSt17_Function_handlerIFvvEZZN5mxnet6engine23ThreadedEnginePerDevice13PushToExecuteEPNS2_8OprBlockEbENKUlvE1_clEvEUlvE_E9_M_invokeERKSt9_Any_data+0x78) [0x7f00e7b76528]
[bt] (3) /root/anaconda3/bin/../lib/libstdc++.so.6(+0xb7260) [0x7f00d056f260]
[bt] (4) /lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba) [0x7f00f9a866ba]
[bt] (5) /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f00f8ea482d]

terminate called after throwing an instance of 'dmlc::Error'
  what():  [12:44:34] src/engine/./threaded_engine.h:329: [12:44:34] src/storage/./pooled_storage_manager.h:84: cudaMalloc failed: out of memory

Stack trace returned 9 entries:
[bt] (0) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZN5mxnet7storage23GPUPooledStorageManager5AllocEm+0x3ec) [0x7f00e7b7c5fc]
[bt] (1) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZN5mxnet11StorageImpl5AllocEmNS_7ContextE+0x57) [0x7f00e7b80037]
[bt] (2) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZNK5mxnet7NDArray4dataEv+0x9b) [0x7f00e776569b]
[bt] (3) /mxnet/python/mxnet/../../lib/libmxnet.so(+0x135ed39) [0x7f00e7ba7d39]
[bt] (4) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZN5mxnet6engine14ThreadedEngine15ExecuteOprBlockENS_10RunContextEPNS0_8OprBlockE+0x87) [0x7f00e7b6eba7]
[bt] (5) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZNSt17_Function_handlerIFvvEZZN5mxnet6engine23ThreadedEnginePerDevice13PushToExecuteEPNS2_8OprBlockEbENKUlvE1_clEvEUlvE_E9_M_invokeERKSt9_Any_data+0x78) [0x7f00e7b76528]
[bt] (6) /root/anaconda3/bin/../lib/libstdc++.so.6(+0xb7260) [0x7f00d056f260]
[bt] (7) /lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba) [0x7f00f9a866ba]
[bt] (8) /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f00f8ea482d]

An fatal error occurred in asynchronous engine operation. If you do not know what caused this error, you can try set environment variable MXNET_ENGINE_TYPE to NaiveEngine and run with debugger (i.e. gdb). This will force all operations to be synchronous and backtrace will give you the series of calls that lead to this error. Remember to set MXNET_ENGINE_TYPE back to empty after debugging.

Stack trace returned 6 entries:
[bt] (0) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZN4dmlc15LogMessageFatalD1Ev+0x3c) [0x7f00e6ddb9cc]
[bt] (1) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZN5mxnet6engine14ThreadedEngine15ExecuteOprBlockENS_10RunContextEPNS0_8OprBlockE+0x31c) [0x7f00e7b6ee3c]
[bt] (2) /mxnet/python/mxnet/../../lib/libmxnet.so(_ZNSt17_Function_handlerIFvvEZZN5mxnet6engine23ThreadedEnginePerDevice13PushToExecuteEPNS2_8OprBlockEbENKUlvE1_clEvEUlvE_E9_M_invokeERKSt9_Any_data+0x78) [0x7f00e7b76528]
[bt] (3) /root/anaconda3/bin/../lib/libstdc++.so.6(+0xb7260) [0x7f00d056f260]
[bt] (4) /lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba) [0x7f00f9a866ba]
[bt] (5) /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f00f8ea482d]

Aborted

Steps to reproduce

or if you are running standard examples, please provide the commands you have run that lead to the error.

  1. Goto mxnet/example/nce-loss
  2. python wordvec.py --gpu

philipskokoh avatar Jun 23 '17 13:06 philipskokoh

try nvidia-smi to see the status of GPU, are there other program running on GPU and used most of memory?

hanpum avatar Jun 27 '17 12:06 hanpum

Ah, you are right. There's another program used a lot of GPU memory. Thanks for the insight about this case!

philipskokoh avatar Jun 28 '17 09:06 philipskokoh