Illegal instruction(core dumped) error on Jetson Nano

Question:

Sorry if my description is long and boring but I want to give you most important details to solve my problem.
Recently I bought a Jetson Nano Developer Kit with 4Gb of RAM, finally!, and in order to get, which I consider, the best configuration for object detection I am following this guide made by Adrian Rosebrock from Pyimagesearch:

https://www.pyimagesearch.com/2020/03/25/how-to-configure-your-nvidia-jetson-nano-for-computer-vision-and-deep-learning/ Date:March, 2020.
A summary of this guide is the following:

  • 1: Flash Jetson Pack 4.2 .img inside a microSD for Jetson Nano(mine is 32GB ‘A’ Class)
  • 2: Once inserted on the Nano board, configure Ubuntu 18.04 and get rid of Libreoffice entirely to get more available space
  • 3: Step #5: Install system-level dependencies( Including cmake, python3, and nano editor)
  • 4: Update CMake (without any errors)
  • 5: Install OpenCV system-level dependencies and other development dependencies
  • 6: Set up Python virtual environments on your Jetson Nano( succesfully installed virtualenv and virtualenvwrapper without errors including the bash file edition with nano)
  • 7: Create virtaul env with python 3 and install protobuf and libprotobuf to get an more efficient Tensorflow. Succesfully installed. It took an hour to finish, that’s normal
  • 8: Here comes the headbreaker: install numpy and cython inside this env and check it importing numpy library
    When I try to do this step I get:
    Illegal instruction(core dumped) as you can see in the image:
    [Error with Python3.6.9]: https://i.stack.imgur.com/rAZhm.png

I said, well let’s continue with this tutorial anyway:

  • 9: Install Scipy v1.3.3: everything is ok with first three lines, but when I have to use python to execute the stup.py file, IT shows up again(not the clown).
    [Can’t execute this line either]: https://i.stack.imgur.com/wFmnt.jpg

Then I ran an experiment, I have created this "p2cv4" env with Python 2, installed numpy and tested it:
[With Python 2]: https://i.stack.imgur.com/zCWif.png

I can exit() whenever I want and execute other lines that use python
So I concluded that is a python version issue. When I want to execute any python code, terminal ends the program with core dumping, apt-get or pip DO NOT show any errors. And I want to use python 3 because someday in the future a package or library will require python 3.

For python 3 last version for the Jetson Nano is 3.6.9, and idk which version was currently active in March, 2020, like the one Adrian used at that time

In other posts I read that this SIGILL appears when a package or library version like Numpy of TF is not friendly anymore with a specific old or low power CPU, like in this posts:
Illegal hardware instruction when trying to import tensorflow, https://github.com/numpy/numpy/issues/9532

So I want to downgrade to a older python version like 3.6.5 or 3.5 but I can’t find clear steps to do so in Ubuntu. I thinks this will fix this error and let me continue with configurations on the Jetson Nano.

The pyimageseach guide uses Python 3.6 but it do not specifies if is last 3.6.9 or another. If is not python causing this error let me know. HELP please!

Asked By: RedEye

||

Answers:

I had this very same problem following the same guide. BTW, in this scenario, numpy worked just fine in python when NOT in a virtualenv. GDB pointed to a problem in libopenblas.

My solution was to start from scratch with a fresh image of jetson-nano-4gb-jp441-sd-card-image.zip and repeat that guide without using virtualenv. More than likely you are the sole developer on that Nano and can live without virtualenv.

I have followed these guides with success:
https://qengineering.eu/install-opencv-4.5-on-jetson-nano.html

Skip the virtualenv portions
https://www.pyimagesearch.com/2019/05/06/getting-started-with-the-nvidia-jetson-nano/

I found this to also be required at this point: "..install the official Jetson Nano TensorFlow by.."

ln -s /usr/include/locale.h /usr/include/xlocale.h

Once I made that symbolic link I was able to proceed with the rest of the guide (minus virtualenv) and I managed to not break numpy.

This is not ideal, but I hope it helps.

Answered By: doommonkey

I thinks this a bug with Jetson Nano B01 model.

Yesterday I realized that my Nano is a different model than the one Adrian is showing in his guide(A02).

Thank you doommonkey to lead me to a different guide that looks pretty much to the pyimagesearch tutorial and more recent one (Dec, 2020), I really appreciate that.

I will test it today and if I can build my opencv to functional including Tensorflow. I think this is a half solved problem.

It’s a shame that virtualenv is giving this awful error for python 3.6.9. In th is particular model. I tried with venv module too and it can’t even install numpy so no virtual env for now

Answered By: RedEye

Try this, It worked for me.
I tested it with pyenv environment with python 3.7.9 and gcc-8.4 on Jetson nano (the very first version). Just remember because it compiles everything, it’s gonna take a lot longer than just downloading the binaries. (because of --no-binary)

python3 -m pip install -U numpy --no-cache-dir --no-binary numpy

You can update your gcc, because default gcc is 7. I am not sure if it does not work with gcc-7.

sudo apt install gcc-8 g++-8
sudo rm /usr/bin/gcc
sudo ln -s /usr/bin/gcc-8 /usr/bin/gcc

sudo rm /usr/bin/g++
sudo ln -s /usr/bin/g++-8 /usr/bin/g++

Now to confirm, you can check the version with

gcc --version
g++ --version
Answered By: Yousof

No you can do with the virtualenv:

  1. remove all numpy ref in the site packages of the virtual environement.
  2. upgrade numpy
  3. link numpy folder to venv numpy.

Assuming your virtualenv is called ML:

  1. cd ~/.virtualenvs/ML/lib/python3.6/site-packages 
    sudo rm -r numpy*
    
  2. #outside VE:
    deactivate
    sudo pip install --upgrade numpy
    
  3. #find path to numpy usig pysearchmethod :
    #use pip uninstall numpy, and answer NO, but note. path
    sudo pip uninstall numpy
    #gives me /home/pierre/.local/lib/python3.6/site-packages/numpy
    cd ~/.virtualenvs/ML/lib/python3.6/site-packages
    ln -s /home/pierre/.local/lib/python3.6/site-packages/numpy numpy
    

Then you can test it:

workon ML
python -c 'import numpy'

If you get stuff related to permission on /.cache/pip, you can try to change permission of the folder:

sudo chown -R $USER ~/.cache/pip

If this still doesn’t work, try uninstalling numpy on the machine, then re installing it:

sudo pip uninstall numpy
#Yousof
pip install -U numpy --no-cache-dir --no-binary numpy

then go back to steps 1->3.

Answered By: pierre tardif

The ‘illegal instruction’ could be due to an recent change in the getauxval(AT_HWCAP).

An attempt to read cpuid information from /sys/devices in the event that getauxval did not succeed. (OpenBLAS PRs 2952 and 3004)

export OPENBLAS_CORETYPE=ARMV8 (or whatever the actual hardware is) before launching python should hopefully get around this. For example:

OPENBLAS_CORETYPE=ARMV8 python

If you would like to make this export permanent, you should open your .bashrc file by typing on the terminal:

nano ~/.bashrc

Afterwards, just add "export OPENBLAS_CORETYPE=ARMV8" to the bottom of your .bashrc file, save/exit and reboot your system:

export OPENBLAS_CORETYPE=ARMV8

for more details look at:

https://github.com/numpy/numpy/issues/18131
https://www.reddit.com/r/JetsonNano/comments/ktcyoh/illegal_instructioncore_dumped_error_on_jetson/

Installing the correct numpy version helped me resolve this issue. Whenever i imported torch, cv2 or torchvision, I got the error saying Illegal instruction(core dumped).
Use the command pip install numpy==1.19.4 and I hope the error goes.

Answered By: Aishwarya Patil

Didn’t work for me , but i tried this :
Miniconda3-py39_4.9.2-Linux-aarch64.sh. The link to download: https://repo.anaconda.com/miniconda/ ANSWER FROM Conda Init Illegal instruction (core dumped)

Answered By: Madi
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.