Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Illegal instruction(core dumped) error on Jetson Nano

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!

like image 468
RedEye Avatar asked Jan 08 '21 15:01

RedEye


2 Answers

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/

like image 195
Vladimir Simoes da Luz Junior Avatar answered Oct 03 '22 03:10

Vladimir Simoes da Luz Junior


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.

like image 28
Aishwarya Patil Avatar answered Oct 03 '22 04:10

Aishwarya Patil