Import mxnet will cause segmentation fault (core dumped) on jetson nano, Jetpack 4.3, mxnet 1.4

I copied my issue from mxnet github repo: https://github.com/apache/incubator-mxnet/issues/17923

System info

jetson nano Jetpack 4.3
python3
mxnet 1.4
cuda 10.0

Description

Try to install mxnet on jetson nano, according to mxnet jetson_setup guide, during installation, no error raised, but when I import mxnet in python3, “Segmentation fault (core dumped)”

Error Message

root@jetbot:/home/jetbot/Downloads# python3
Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mxnet
Segmentation fault (core dumped)

To Reproduce

My installation procedure:

  1. install dependencies:
sudo apt update
sudo apt -y install \
                        build-essential \
                        git \
                        graphviz \
                        libatlas-base-dev \
                        libopencv-dev \
                        python3-pip

sudo pip3 install --upgrade \
                        pip \
                        setuptools

sudo pip3 install \
                        graphviz==0.8.4 \
                        jupyter \
                        numpy==1.18.2

a little different form official guide, which I use pip3 because I need to use python3, and the numpy version is 1.18.2 rather than 1.15.2 because the later pip install suggested to do so.

  1. clone the repo
git clone --recursive https://github.com/apache/incubator-mxnet.git mxnet
  1. environment
export PATH=/usr/local/cuda/bin:$PATH
export MXNET_HOME=$HOME/mxnet/
export PYTHONPATH=$MXNET_HOME/python:$PYTHONPATH
  1. check cuda version
nvcc --version

we can get:

Copyright (c) 2005-2019 NVIDIA Corporation
Built on Mon_Mar_11_22:13:24_CDT_2019
Cuda compilation tools, release 10.0, V10.0.326
  1. download the whl file and libmxnet.so
wget -c https://s3.us-east-2.amazonaws.com/mxnet-public/install/jetson/1.4.0/mxnet-1.4.0-cp36-cp36m-linux_aarch64.whl  # I'm using python3.6

wget -c https://s3.us-east-2.amazonaws.com/mxnet-public/install/jetson/1.4.1/libmxnet.so
mkdir mxnet/lib
mv libmxnet.so mxnet/lib  # put this file in lib
  1. install the whl
sudo pip install mxnet-1.4.0-cp27-cp27mu-linux_aarch64.whl
  1. try to import
root@jetbot:/home/jetbot/Downloads# python3
Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mxnet
Segmentation fault (core dumped)

What have you tried to solve it?

  1. try to build from source, it took me 2 hours and exited with error (sorry I forget to log the error info)
  2. reinstall the os, reflash the image, and try the jetson_setup guide again.

Hi,

It looks like you install a package for python2.7 rather than python3:

sudo pip install mxnet-1.4.0-cp27-cp27mu-linux_aarch64.whl

A typical segmentation fault is caused by the incompatibility of a package or library.
It is recommended to check if the package provided by the mxnet team was not built on JetPack4.3 or not.

We also have a mxnet package for JetPack4.3.
You can find more information here:

Thanks.

Thanks for your quick reply, it worked!

Here are my pipeline:

sudo pip3 install numpy==1.16
sudo pip3 install mxnet-1.6.0-py3-none-any.whl

and switch to sudo account! that’s import for me:

sudo su
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mxnet
root@jetbot:/home/jetbot# python3
Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mxnet as mx
>>> mx.__version__
'1.6.0'

If I use python3 under jetbot account, will thorw segmentation fault error, seems I forgot change to sudo.

1 Like

Good to know this!

Thank you, I have the same problem and solved by your method.
if use a not root user ,it output :
RuntimeError: Cannot find the MXNet library.
list of candidates:
/usr/local/lib/python3.6/dist-packages/mxnet/libmxnet.so
…something like this

have you try this:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mxnet