I was unable to compile and install MXNET on the jetson nano,Is there an official installation tutorial?

Hi,
AastaLLL

I’ve tried this before.

This mxnet use cuda 9.0, but jetson nano use cuda 10.0.

I have no way to use mxnet.
Is there any other solution?

Thanks.

I had the same issue than Ruis while installing mxnet.

Tried:
1.- Mxnet from source following the documentation steps: Apache MXNet | A flexible and efficient library for deep learning.. Mxnet fails to build unless correctly without if not with the command: make -j $(nproc) NVCC=/usr/local/cuda/bin/nvcc

Build takes about 5h but the GPU mode doesn’t work, when creating a GPU tensor the error:

Device Kernel Image is Invalid

is thrown. I suspect a correct CUDA_ARCH flag may resolve the issue, but since it takes that much time I haven’t been able to try many options.

2.- pip install mxnet-jetson

As pointed by Ruis, this wheel is compiled for cuda 9.0 and the jetpack image provided for the jetson nano is cuda 10.0

Any chance we can fix either of the approaches?

Hi,

We will try to compile mxnet on Nano.
Let us share more information with you later.

Stay tuned.

Hi,
AastaLLL

I really appreciate your help.

Then I will wait for your message.

Thanks.

Thank you very much

Hi,

Confirmed that we can build MXNet on the Jetson Nano:

------------------------------------------
nvidia@nano:~$ python
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) *
[GCC 7.3.0] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import mxnet as mx
>>> a = mx.nd.ones((2,3), mx.gpu())
>>> print((a2).asnumpy())

[[2. 2. 2.]
[2. 2. 2.]]

Here are the building steps for your reference.
We build MXNet on a 16GB USB.

1. Allocate swap

fallocate -l 8G swapfile
sudo chmod 600 swapfile
sudo mkswap swapfile
sudo swapon swapfile

2. Install dependencies

sudo apt-get update
sudo apt-get install -y git build-essential libatlas-base-dev libopencv-dev graphviz python-pip
sudo pip install --upgrade pip
sudo pip install --upgrade setuptools
sudo pip install numpy==1.15.2
sudo pip install graphviz jupyter

3. Build MXNet on Nano

git clone https://github.com/apache/incubator-mxnet.git --branch v1.4.x --recursive
cd incubator-mxnet/
cp make/config.mk .
sed -i 's/USE_CUDA = 0/USE_CUDA = 1/' config.mk
sed -i 's/USE_CUDA_PATH = NONE/USE_CUDA_PATH = \/usr\/local\/cuda/' config.mk
sed -i 's/USE_CUDNN = 0/USE_CUDNN = 1/' config.mk
sed -i '/USE_CUDNN/a CUDA_ARCH := -gencode arch=compute_53,code=sm_53' config.mk
make -j3

4. Install MXNet

cd python
sudo python setup.py install
cd ..
export MXNET_HOME=$(pwd)
echo "export PYTHONPATH=$MXNET_HOME/python:$PYTHONPATH" >> ~/.bashrc
source ~/.bashrc

Thanks.

Hi,
AastaLLL

I will test as soon as possible and reply to you about the progress later.

Thanks.

Hi,
AastaLLL

I could also install mxnet before, but there was a problem when opencv was enabled. The tutorial you provided did not enable opencv. Would you please try to compile mxnet with opencv?

build/src/io/image_io.o: In function `mxnet::io::ImdecodeImpl(int, bool, void*, unsigned long, mxnet::NDArray*)':
image_io.cc:(.text+0x91c): undefined reference to `cv::imdecode(cv::_InputArray const&, int, cv::Mat*)'
image_io.cc:(.text+0xafc): undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
build/src/ndarray/ndarray.o: In function `mxnet::Imdecode(mxnet::NDArray*, mxnet::NDArray, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, char*)':
ndarray.cc:(.text+0xb1f8): undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
collect2: error: ld returned 1 exit status
Makefile:568: recipe for target 'bin/im2rec' failed
make: *** [bin/im2rec] Error 1

Hi, all

Here is a prebuilt file for MXNet on Nano. You can install it with pip directly.

Python2.7
Please download the wheel file here.

sudo apt-get install -y git build-essential libatlas-base-dev libopencv-dev graphviz python-pip
sudo pip install mxnet-1.4.0-cp27-cp27mu-linux_aarch64.whl

Python3.6
Please download the wheel file here.

sudo apt-get install -y git build-essential libatlas-base-dev libopencv-dev graphviz python3-pip
sudo pip3 install mxnet-1.4.0-cp36-cp36m-linux_aarch64.whl

Thanks.

Hi, Ruis

Thanks for your experiment.

I will check the OpenCV enabled case.
It may takes some time since we just reset the system.

Thanks.

Hi, Ruis

Just checking. OpenCV is enabled in the configure file shared in the comment #8.

Based on your error, it looks like that there is no OpenCV package on your environment.
You can find OpenCV in the sdkmanager. Could you get all the package included in the sdkmanager installed first?

Thanks.

Hi,AastaLLL

I confirm that I have started opencv. There may be a problem in the compilation process.

I will try the PIP installation you provided.

I’ll give you a message later.

Thanks.

Hi,AastaLLL
Thank you very much for your help!

I solved all the problems!

Best wishes for you, AastaLLL.

Hi,AastaLLL

I’m sorry.
My project relies on python3.7+ .

Could you please recompile Mxnet with python3.7+ .

I’m so sorry.
I hope to get your help.

Thanks.

Hi,

Sorry that we don’t have enough resource to build MXNet for python3.7.
It’s recommended to build it from source with the instruction shared in comment #8.

Thanks.

Hi
I can’t build Mxnet from resource,such as #10

Is there any other way to run Mxnet with Python3.7+ on nano?

I’m so sorry.
I hope to get your help.

Thank u , AastaLLL

Hi,

So let’s fix the error in comment #10.

It looks like there is something wrong in your OpenCV library.
Do you install or build it from source?

MXNet can work with default OpenCV package.
And the default OpenCV package is installed via sdkmanager with ‘Jetson SDK components’ option.

Thanks.

Hi AastaLLL

I have similar issue like Ruis. But I’m using Jetson TX2.
I want to build from source mxnet 1.4.x (with opencv) but some error still occurred. I already followed your steps in #8 and changed -gencode arch=compute_53,code=sm_53 to -gencode arch=compute_62,code=sm_62.

I got this errors

iter_image_recordio_2.cc:(.text._ZZN5mxnet2io20ImageRecordIOParser2IhE10ParseChunkEPhPfmPN4dmlc10InputSplit4BlobEENKUlvE_clEv[_ZZN5mxnet2io20ImageRecordIOParser2IhE10ParseChunkEPhPfmPN4dmlc10InputSplit4BlobEENKUlvE_clEv]+0xc0c): undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
iter_image_recordio_2.cc:(.text._ZZN5mxnet2io20ImageRecordIOParser2IhE10ParseChunkEPhPfmPN4dmlc10InputSplit4BlobEENKUlvE_clEv[_ZZN5mxnet2io20ImageRecordIOParser2IhE10ParseChunkEPhPfmPN4dmlc10InputSplit4BlobEENKUlvE_clEv]+0xc14): undefined reference to `cv::String::deallocate()'
iter_image_recordio_2.cc:(.text._ZZN5mxnet2io20ImageRecordIOParser2IhE10ParseChunkEPhPfmPN4dmlc10InputSplit4BlobEENKUlvE_clEv[_ZZN5mxnet2io20ImageRecordIOParser2IhE10ParseChunkEPhPfmPN4dmlc10InputSplit4BlobEENKUlvE_clEv]+0x182c): undefined reference to `cv::String::deallocate()'
build/src/ndarray/ndarray.o: In function `mxnet::Imdecode(mxnet::NDArray*, mxnet::NDArray, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, char*)':
ndarray.cc:(.text+0xb4c4): undefined reference to `cv::String::allocate(unsigned long)'
ndarray.cc:(.text+0xb508): undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
ndarray.cc:(.text+0xb510): undefined reference to `cv::String::deallocate()'
ndarray.cc:(.text+0xd4dc): undefined reference to `cv::String::deallocate()'
collect2: error: ld returned 1 exit status
Makefile:525: recipe for target 'bin/im2rec' failed
make: *** [bin/im2rec] Error 1
make: *** Waiting for unfinished jobs....

Here’s my environment:
Nvidia Jetson TX2
Opencv installed version 3.4.0
CUDA version 9.0

Hope you can help me. Thank you.

@stillmen.v

I suggest you submit another topic about MXNET on TX2 forum.

Hi,

It looks weird to me.
Could you check where your OpenCV library installed first?

For me, the libraries is installed at ‘/usr/lib’.

nvidia@nano:~$ ll /usr/lib/libopencv_*
lrwxrwxrwx 1 root root      24  二   6 18:44 /usr/lib/libopencv_calib3d.so -> libopencv_calib3d.so.3.3
lrwxrwxrwx 1 root root      26  二   6 18:44 /usr/lib/libopencv_calib3d.so.3.3 -> libopencv_calib3d.so.3.3.1
-rw-r--r-- 1 root root 1323432  二   6 18:20 /usr/lib/libopencv_calib3d.so.3.3.1
lrwxrwxrwx 1 root root      21  二   6 18:44 /usr/lib/libopencv_core.so -> libopencv_core.so.3.3
lrwxrwxrwx 1 root root      23  二   6 18:44 /usr/lib/libopencv_core.so.3.3 -> libopencv_core.so.3.3.1
....

Thanks.