ibaiGorordo / Ultrafast-Lane-Detection-Inference-Pytorch-

Example scripts for the detection of lanes using the ultra fast lane detection model in Pytorch.
MIT License
71 stars 24 forks source link

Illegal Instruction occurs in Ubuntu 20.04 on Raspberry Pi 4 #1

Closed Yen-Lung-Huang closed 3 years ago

Yen-Lung-Huang commented 3 years ago

Hello, this program can run successfully on Windows and Ubuntu with AMD64 architecture, but I want to do lane detection on Raspberry Pi 4, as a lightweight and real-time lane detection system, easy to install on the car. On Raspberry Pi 4 with Ubuntu 20.04, I installed the following packages in the Python 3.7 virtual environment using pip3 from requirements.txt("pip3 list" output):

Joblib 1.0.1
Numpy 1.21.1
Opencv - python 4.5.3.56
Pafy 0.5.5
Pillow 8.3.1
PIP 21.2.4
Scikit - learn 0.24.2
Scipy 1.7.1
Setuptools 57.1.0
Sklearn 0.0
Threadpoolctl 2.2.0
The torch 1.9.0
Torchvision 0.10.0
Typing - extensions 3.10.0.0
Wheel 0.36.2
Youtube - dl 2021.6.6

When I run imageLaneDetection.py, videoLaneDetection.py and webcamLaneDetection.py to "output = self. model(input_tensor)" in the class function "inference" in the ultrafastLaneDetector.py caused an unexpected program interrupt and showed "Illegal Instruction" in the terminal window. Why this situation occurs and how to deal with it?

My terminal window output: image

ibaiGorordo commented 3 years ago

Hi,

I haven't used Pytorch in the Raspberry Pi, so I am not sure what might be the problem. Have you tested using pytorch in the raspberry pi with other models?

However, I think it will be quite slow in the Raspberry Pi, it would probably better to either convert the model to TFLite and optimize the model or find another model already optimized in TFLite.

Let me know how it goes.

Ibai

Yen-Lung-Huang commented 3 years ago

Currently I only use Torch in Raspberry Pi and use Tusimple model. I will try TFLite and let you know what I get. Thanks!

I use the instructions provided by the Pytorch official website to download Torch: image

ibaiGorordo commented 3 years ago

I have not tested it but I think in that case it will install a Pytorch version that is not suitable for ARM chips. Make sure that Pytorch work with some simple example. And otherwise, try this method to install Pytorch in a Raspberry Pi: https://gist.github.com/akaanirban/621e63237e63bb169126b537d7a1d979

Yen-Lung-Huang commented 3 years ago

Thanks ibaiGorordo for the advice. Yes, the Torch I installed using the commands provided on the PyTorch website is not compatible with ARM. I through pytorch - aarch64 installed the torch 1.9.0 and torchvision 0.10.0. Successfully run the Ultrafast-Lane-Detection-Inference-Pytorch- programs on Raspberry Pi 4. However, execution on Pi is very slow, for example, imageLaneDetection.py takes 31 seconds to get output. Next I'm going to try TFLite and tell you what I get.

Run pip3 list and python3 imageLaneDetection.py on terminal:
image

The output image of imageLaneDetection.py: output

ibaiGorordo commented 3 years ago

I am glad to hear that. About the TFLite model, it might be hard to get it:

https://github.com/cfzd/Ultra-Fast-Lane-Detection/issues/155

But there is probably some lane detector that can run faster in the Raspberry Pi.

Good luck, and let me know how it goes. Ibai

ibaiGorordo commented 3 years ago

Hi,

I have created a repository for performing the inference in TFLite: https://github.com/ibaiGorordo/TfLite-Ultra-Fast-Lane-Detection-Inference

I have not tested it, but it should run faster than the original model in the Raspberry Pi.