Okay, let's refine the forum post to include the information about how you installed onnxruntime. Here's an updated draft:
Subject: "Illegal instruction" error when running rembg on Raspberry Pi 4 (aarch64)
Body:
Hi everyone,
I'm encountering an "Illegal instruction" error when trying to run a simple Python script that uses the rembg library on my Raspberry Pi 4 (8GB, aarch64) running Debian Bookworm. The script is as follows:
The error occurs specifically on the line where rembg.remove(input) is called.
Here's my environment information:
OS: Debian Bookworm (aarch64)
Python Version: 3.11.2
onnxruntime Version: 1.21.0 (I've also tried 1.20.1 and 1.15.0 with the same result)
rembg Version: 2.0.65
Hardware: Raspberry Pi 4 (8GB)
I've tried installing onnxruntime using both standard pip install onnxruntime and by downloading a .whl file and installing it using pip install <wheel_file_name>.whl. Neither method has resolved the "Illegal instruction" error.
Has anyone else encountered this issue when using rembg (or potentially onnxruntime) on a Raspberry Pi 4 or similar aarch64 architecture? Any insights or suggestions on how to resolve this would be greatly appreciated.
Things I've considered (but haven't solved the issue):
Potentially an incompatibility between onnxruntime and the Raspberry Pi 4's processor.
Missing dependencies or libraries.
Issues with the specific onnxruntime builds available for aarch64.
Subject: "Illegal instruction" error when running rembg on Raspberry Pi 4 (aarch64)
Body:
Hi everyone,
I'm encountering an "Illegal instruction" error when trying to run a simple Python script that uses the rembg library on my Raspberry Pi 4 (8GB, aarch64) running Debian Bookworm. The script is as follows:
Code:
from rembg import removeimport cv2import osscript_directory = os.path.dirname(os.path.abspath(__file__))capture_directory = os.path.join(script_directory, "capture")rembg_out_directory = os.path.join(capture_directory, "removed_background")input_filename = 'capture.jpg'input_path = os.path.join(capture_directory, input_filename)output_filename = 'output.png'output_path = os.path.join(rembg_out_directory, output_filename)input = cv2.imread(input_path)output = remove(input) #<------ This line causes the "Illegal instruction" errorcv2.imwrite(output_path, output)Here's my environment information:
OS: Debian Bookworm (aarch64)
Python Version: 3.11.2
onnxruntime Version: 1.21.0 (I've also tried 1.20.1 and 1.15.0 with the same result)
rembg Version: 2.0.65
Hardware: Raspberry Pi 4 (8GB)
I've tried installing onnxruntime using both standard pip install onnxruntime and by downloading a .whl file and installing it using pip install <wheel_file_name>.whl. Neither method has resolved the "Illegal instruction" error.
Has anyone else encountered this issue when using rembg (or potentially onnxruntime) on a Raspberry Pi 4 or similar aarch64 architecture? Any insights or suggestions on how to resolve this would be greatly appreciated.
Things I've considered (but haven't solved the issue):
Potentially an incompatibility between onnxruntime and the Raspberry Pi 4's processor.
Missing dependencies or libraries.
Issues with the specific onnxruntime builds available for aarch64.
Statistics: Posted by Mohab Elkhayat — Thu Apr 17, 2025 1:56 pm — Replies 0 — Views 36