mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

Lots of unnecessary output on caught exceptions

Open iFreilicht opened this issue 9 years ago • 1 comments

Description

Some functions will write to stderr when an exception occurs, even if that exception is caught.

Environment info (Required)

----------Python Info----------
Version      : 3.4.3
Compiler     : GCC 4.8.4
Build        : ('default', 'Nov 17 2016 01:08:31')
Arch         : ('64bit', 'ELF')
------------Pip Info-----------
Version      : 9.0.1
Directory    : /usr/local/lib/python3.4/dist-packages/pip
----------MXNet Info-----------
Version      : 0.12.1
Directory    : /usr/local/lib/python3.4/dist-packages/mxnet
Commit Hash   : e0c7906693f0c79b0ce34a4d777c26a6bf1903c1
----------System Info----------
Platform     : Linux-3.13.0-49-generic-x86_64-with-Ubuntu-14.04-trusty
system       : Linux
node         : felix-XPS-12-Ubuntu
release      : 3.13.0-49-generic
version      : #83-Ubuntu SMP Fri Apr 10 20:11:33 UTC 2015
----------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):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    2
Core(s) per socket:    2
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 69
Stepping:              1
CPU MHz:               768.000
BogoMIPS:              4789.25
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              4096K
NUMA node0 CPU(s):     0-3
----------Network Test----------
Setting timeout: 10
Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.0009 sec, LOAD: 0.0417 sec.
Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0005 sec, LOAD: 0.7818 sec.
Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.0010 sec, LOAD: 0.7462 sec.
Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0007 sec, LOAD: 0.0353 sec.
Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0005 sec, LOAD: 0.7448 sec.
Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0181 sec, LOAD: 0.0541 sec.

Package used (Python):

$ pip show mxnet
Name: mxnet
Version: 0.12.1
Summary: MXNet is an ultra-scalable deep learning framework. This version uses openblas.
Home-page: https://github.com/dmlc/mxnet
Author: UNKNOWN
Author-email: UNKNOWN
License: Apache 2.0
Location: /usr/local/lib/python3.4/dist-packages
Requires: graphviz, numpy, requests

Error Message:

[17:27:51] src/imperative/./imperative_utils.h:74: GPU support is disabled. Compile MXNet with USE_CUDA=1 to enable GPU support.
[17:27:51] /home/travis/build/dmlc/mxnet-distro/mxnet-build/dmlc-core/include/dmlc/logging.h:308: [17:27:51] src/imperative/imperative.cc:78: Operator _ones is not implemented for GPU.

Stack trace returned 10 entries:
[bt] (0) /usr/local/lib/python3.4/dist-packages/mxnet/libmxnet.so(+0x16d89c) [0x7fdea5c6489c]
[bt] (1) /usr/local/lib/python3.4/dist-packages/mxnet/libmxnet.so(+0x203c644) [0x7fdea7b33644]
[bt] (2) /usr/local/lib/python3.4/dist-packages/mxnet/libmxnet.so(+0x2041138) [0x7fdea7b38138]
[bt] (3) /usr/local/lib/python3.4/dist-packages/mxnet/libmxnet.so(+0x1f9f6b1) [0x7fdea7a966b1]
[bt] (4) /usr/local/lib/python3.4/dist-packages/mxnet/libmxnet.so(MXImperativeInvokeEx+0x63) [0x7fdea7a96a53]
[bt] (5) /usr/lib/x86_64-linux-gnu/libffi.so.6(ffi_call_unix64+0x4c) [0x7fdeb6a21c7c]
[bt] (6) /usr/lib/x86_64-linux-gnu/libffi.so.6(ffi_call+0x1fc) [0x7fdeb6a215ac]
[bt] (7) /usr/lib/python3.4/lib-dynload/_ctypes.cpython-34m-x86_64-linux-gnu.so(_ctypes_callproc+0x21d) [0x7fdeb6c3312d]
[bt] (8) /usr/lib/python3.4/lib-dynload/_ctypes.cpython-34m-x86_64-linux-gnu.so(+0xf6a3) [0x7fdeb6c336a3]
[bt] (9) python3(PyEval_EvalFrameEx+0x41d7) [0x48a487]

No problem.

Minimum reproducible example

import mxnet as mx
try:
   mx.nd.ones(1, mx.gpu())
except mx.MXNetError:
   print('No problem.')

Steps to reproduce

  1. Run any function that can fail with an exception and catch it
  2. You will notice that output is being written, including the stacktrace

What have you tried to solve it?

I tried to redirect stderr in python while calling the function like so:

sys.stderr = open(os.devnull)

I also tried redirecting stderr on commandline level:

$ ./my_script.py 2> /dev/null

This works, but also silences all other output onto stderr, including uncaught exceptions and the helptext from pythons argument parser.

This is extremely annoying when trying to write a command-line tool based on mxnet, as it drowns out relevant ouput.

iFreilicht avatar Nov 29 '17 16:11 iFreilicht

Proposed Labels : "Call for Contribution", "Exception Handling", "Python"

harshitajain1994 avatar Mar 10 '18 00:03 harshitajain1994