Installing mxnet on Redhat 7.4

Hi,

  1. I have installed mxnet via pip3 but I’m unable to use the package in test code and throwing core dump while import the mxnet package.

error

Python 3.6.7 (default, Mar 26 2019, 13:14:44)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import mxnet as mx
Illegal instruction (core dumped)

  1. Secondly I have tried installing MXNet from Source. Successfully installed all dependency for mxnet .

Clone the MXNet Project
Clone or fork the MXNet project.
git clone --recursive GitHub - apache/mxnet: Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more mxnet
cd mxnet

Build MXNet with C++
To enable C++ package, just add USE_CPP_PACKAGE=1 when you run make or cmake (see examples).
Usage Examples
For example, you can specify using all cores on Linux as follows:

mkdir build && cd build
cmake -GNinja .
ninja -v

But while excuting ninja -v command its throwing below.

op.cc
In file included from /usr1/emdev/em/OpenBLAS/cblas.h:5:0,
from include/mshadow/./base.h:162,
from include/mshadow/tensor.h:16,
from include/mxnet/base.h:33,
from src/operator/image/crop.cc:26:
/usr1/emdev/em/opencv-2.4.13/include/opencv2/core/core.hpp:4194:9: error: expected identifier before ‘float’
FLOAT=REAL, //!< synonym or REAL

clude -isystem /usr1/emdev/em/opencv-2.4.13/modules/legacy/include -isystem /usr1/emdev/em/opencv-2.4.13/modules/photo/include -isystem /usr1/emdev/em/opencv-2.4.13/modules/stitching/include -isystem /usr1/emdev/em/opencv-2.4.13/modules/superres/include -isystem /usr1/emdev/em/opencv-2.4.13/modules/ts/include -isystem /usr1/emdev/em/opencv-2.4.13/modules/videostab/include -Wall -Wno-unknown-pragmas -Wno-sign-compare -O3 -msse2 -std=c++11 -fopenmp -std=c++0x -fPIC -MD -MT CMakeFiles/mxnet_static.dir/src/executor/infer_graph_attr_pass.cc.o -MF CMakeFiles/mxnet_static.dir/src/executor/infer_graph_attr_pass.cc.o.d -o CMakeFiles/mxnet_static.dir/src/executor/infer_graph_attr_pass.cc.o -c src/executor/infer_graph_attr_pass.cc
ninja: build stopped: subcommand failed.

Kindly help me to resolve the issue.

thanks in dvance

Regards
Stanley

Hi @stanley.jr, welcome to the forum,
Which flavor of mxnet did you install with pip3 ? mxnet-mkl ? Does your machine have a intel CPU ? If not, then it could be an error due to Intel MKLDNN.

Can you try installing on python 2 and let me know if you face the same issue?

For your build error, it seems to come from your opencv install. How did you install it?

Thanks for your quick response.

I have installed mxnet-mkl with pip3.6 (python 3.6.7) .
CPU Details

processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 26
model name : Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz

Below steps I have followed to install openCV

  • To download and extract the OpenCV source code, run the following commands:

wget https://codeload.github.com/opencv/opencv/zip/2.4.13
unzip 2.4.13
cd opencv-2.4.13
mkdir release cd release/

  • Build OpenCV. The following commands build OpenCV with 10 threads. We disabled GPU support, which might significantly slow down an MXNet program running on a GPU processor. It also disables 1394 which might generate a warning. Then install it on /usr/local .

cmake -D BUILD_opencv_gpu=OFF -D WITH_CUDA=OFF -D WITH_1394=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local … make -j10 sudo make install

  • Added the lib path to your configuration such as ~/.bashrc .

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig/

After installing I have check cv2 . Please find below logs

Python 3.6.7 (default, Mar 26 2019, 13:14:44)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import cv2
cv2.version
‘4.0.0’

Even I have tried with python 2.7 . Please find below for more details

Python 2.7.5 (default, May 3 2017, 07:55:04)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-14)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

import mxnet
Illegal instruction (core dumped)

Installed Version : mxnet-mkl 1.4.0.post0

gcc (GCC) 4.8.5
opencv-2.4.13

Other version detetails

Core Details

file core.27158

core.27158: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from ‘python2.7’, real uid: 1004, effective uid: 1004, real gid: 1004, effective gid: 1004, execfn: ‘/usr1/emdev/em/env-mxnet/bin/python2.7’, platform: ‘x86_64’

error

#0 0x00007ff29d8d1cf6 in ?? () from /usr1/emdev/em/env-mxnet/lib/python2.7/site-packages/mxnet/libmxnet.so
#1 0x00007ff29d8d911a in ?? () from /usr1/emdev/em/env-mxnet/lib/python2.7/site-packages/mxnet/libmxnet.so
#2 0x00007ff29d8cfec9 in ?? () from /usr1/emdev/em/env-mxnet/lib/python2.7/site-packages/mxnet/libmxnet.so
#3 0x00007ff29d73a29a in ?? () from /usr1/emdev/em/env-mxnet/lib/python2.7/site-packages/mxnet/libmxnet.so
#4 0x00007ff2b4046503 in _dl_init_internal () from /lib64/ld-linux-x86-64.so.2
#5 0x00007ff2b404ac16 in dl_open_worker () from /lib64/ld-linux-x86-64.so.2
#6 0x00007ff2b4046314 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#7 0x00007ff2b404a30b in _dl_open () from /lib64/ld-linux-x86-64.so.2
#8 0x00007ff2b384bfbb in dlopen_doit () from /lib64/libdl.so.2
#9 0x00007ff2b4046314 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#10 0x00007ff2b384c5bd in dlerror_run () from /lib64/libdl.so.2
#11 0x00007ff2b384c051 in dlopen@@GLIBC_2.2.5 () from /lib64/libdl.so.2
#12 0x00007ff2ab7a81f1 in py_dl_open () from /usr1/emdev/em/env-mxnet/lib64/python2.7/lib-dynload/ctypes.so
#13 0x00007ff2b3d4fbb0 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#14 0x00007ff2b3d51efd in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#15 0x00007ff2b3cdb858 in function_call () from /lib64/libpython2.7.so.1.0
#16 0x00007ff2b3cb69a3 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#17 0x00007ff2b3cc5995 in instancemethod_call () from /lib64/libpython2.7.so.1.0
#18 0x00007ff2b3cb69a3 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#19 0x00007ff2b3d0d947 in slot_tp_init () from /lib64/libpython2.7.so.1.0
#20 0x00007ff2b3d0c65f in type_call () from /lib64/libpython2.7.so.1.0
#21 0x00007ff2b3cb69a3 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#22 0x00007ff2b3d4b0f6 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#23 0x00007ff2b3d51efd in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#24 0x00007ff2b3d4f3fc in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#25 0x00007ff2b3d51efd in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#26 0x00007ff2b3d52002 in PyEval_EvalCode () from /lib64/libpython2.7.so.1.0
#27 0x00007ff2b3d61dec in PyImport_ExecCodeModuleEx () from /lib64/libpython2.7.so.1.0
#28 0x00007ff2b3d62068 in load_source_module () from /lib64/libpython2.7.so.1.0
#29 0x00007ff2b3d62d01 in import_submodule () from /lib64/libpython2.7.so.1.0
#30 0x00007ff2b3d62f4d in load_next () from /lib64/libpython2.7.so.1.0
#31 0x00007ff2b3d6392e in PyImport_ImportModuleLevel () from /lib64/libpython2.7.so.1.0
#32 0x00007ff2b3d46bdf in builtin___import
() from /lib64/libpython2.7.so.1.0
#33 0x00007ff2b3cb69a3 in PyObject_Call () from /lib64/libpython2.7.so.1.0
#34 0x00007ff2b3d487b7 in PyEval_CallObjectWithKeywords () from /lib64/libpython2.7.so.1.0
#35 0x00007ff2b3d4d475 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
#36 0x00007ff2b3d51efd in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
#37 0x00007ff2b3d52002 in PyEval_EvalCode () from /lib64/libpython2.7.so.1.0
#38 0x00007ff2b3d61dec in PyImport_ExecCodeModuleEx () from /lib64/libpython2.7.so.1.0
#39 0x00007ff2b3d62068 in load_source_module () from /lib64/libpython2.7.so.1.0
#40 0x00007ff2b3d62d01 in import_submodule () from /lib64/libpython2.7.so.1.0
#41 0x00007ff2b3d62f4d in load_next () from /lib64/libpython2.7.so.1.0
#42 0x00007ff2b3d6392e in PyImport_ImportModuleLevel () from /lib64/libpython2.7.so.1.0

@stanley.jr, that is strange, are you able to try to:

pip uninstall mxnet-mkl -y && pip install mxnet ?

I tried to install mxnet-mkl on a aws m4.2xl, CPU is E5-2686, with RHEL 7.4, and I had no issues.

@ThomasDelteil

As suggested by I have tried with pip uninstall mxnet-mkl -y && pip install mxnet
still we are facing same issue.

I have created RHEL instance in GCP and able to run mxnet without problem.

GCP log

[stanley1feb@mxnet ~] cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.6 (Maipo) [stanley1feb@mxnet ~] pythonPython 3.6.7 (default, Apr 10 2019, 16:47:33) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linuxType “help”, “copyright”, “credits” or “license” for more information.

>>> import mxnet

Regards,
Stanley

1 Like

One last thing you can try is to run mxnet in a docker container on your local machine:

docker run -it mxnet/python:1.4.0_cpu_mkl_py3 bash