Closed FamousDirector closed 1 month ago
Could you please run "make VERBOSE=1" in /home/pi/onnxruntime/build/Linux/MinSizeRel and post the log here?
If build time is a concern, please try cross-compiling, which will only take a few minutes(vs 10+ hours).
As a quick fix, you may open cmake/CMakeLists.txt, Find https://github.com/microsoft/onnxruntime/blob/master/cmake/CMakeLists.txt#L1613
list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${CMAKE_DL_LIBS} Threads::Threads)
And change it to
list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${CMAKE_DL_LIBS} pthread)
I'm a bit of a noob at cross compiling. How would I do this for an armv6 architecture?
Okay so I followed those instructions and cross compiled the library with the following Dockerfile:
FROM balenalib/raspberry-pi-python:3.7-stretch-build
ARG ONNXRUNTIME_REPO=https://github.com/Microsoft/onnxruntime
ARG ONNXRUNTIME_SERVER_BRANCH=v1.8.0
# Enforces cross-compilation through Qemu.
RUN [ "cross-build-start" ]
RUN install_packages \
sudo \
build-essential \
curl \
libcurl4-openssl-dev \
libssl-dev \
wget \
python3 \
python3-dev \
git \
tar \
libatlas-base-dev
# Carefully install the latest version of pip
WORKDIR /pip
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python3 get-pip.py
RUN pip3 install --upgrade setuptools
RUN pip3 install --upgrade wheel
RUN pip3 install numpy
# Build the latest cmake
WORKDIR /code
RUN wget https://github.com/Kitware/CMake/releases/download/v3.20.3/cmake-3.20.3.tar.gz
RUN tar zxf cmake-3.20.3.tar.gz
WORKDIR /code/cmake-3.20.3
RUN ./configure --system-curl
RUN make
RUN sudo make install
# Set up build args
ARG BUILDTYPE=MinSizeRel
# if doing a 64-bit build change '--arm' to '--arm64'
ARG BUILDARGS="--config ${BUILDTYPE} --arm"
# Prepare onnxruntime Repo
WORKDIR /code
RUN git clone --single-branch --branch ${ONNXRUNTIME_SERVER_BRANCH} --recursive ${ONNXRUNTIME_REPO} onnxruntime
# Build ORT including the shared lib and python bindings
WORKDIR /code/onnxruntime
RUN ./build.sh ${BUILDARGS} --update --build --build_shared_lib --build_wheel --parallel
# Build Output
RUN ls -l /code/onnxruntime/build/Linux/${BUILDTYPE}/*.so
RUN ls -l /code/onnxruntime/build/Linux/${BUILDTYPE}/dist/*.whl
RUN [ "cross-build-end" ]
However after copying the wheel file (onnxruntime-1.8.0-cp37-cp37m-linux_armv6l.whl
) to the RPi Zero and running python3 -c "import onnxruntime"
I get the error:
Illegal instruction
Sorry I don't understand the docker file. It was not written by me. I can't provider further help on it. It is not relevant to the build document I showed you.
As a quick fix, you may open cmake/CMakeLists.txt, Find https://github.com/microsoft/onnxruntime/blob/master/cmake/CMakeLists.txt#L1613
list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${CMAKE_DL_LIBS} Threads::Threads)
And change it to
list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${CMAKE_DL_LIBS} pthread)
As it turns out, it's important to also add -pthread
to compile options of all external libs as well. Below
function(onnxruntime_set_compile_flags target_name)
add
target_compile_options(${target_name} PRIVATE -pthread)
20413
So, is it possible to install onnxruntime on raspberrypi zero or not? If yes, could you advice the steps to install? Please confirm!
20413
So, is it possible to install onnxruntime on raspberrypi zero or not? If yes, could you advice the steps to install? Please confirm!
Bump
nsync is removed. If you still see
undefined reference to `pthread_rwlock_wrlock'
Please go to the build folder and run
make VERBOSE=1 >& build.log
Then find the failed build command in the log file and post the full command here.
Describe the bug I am trying to build ONNXRuntime v1.8.0 on RPi Zero. During building I get a pthread linking error. Here is the full stack trace
Urgency None
System information
To Reproduce
bash build.sh --config MinSizeRel --arm --update --build --build_shared_lib --build_wheel
Expected behavior The library to build...
Screenshots None
Additional context I am not picky on version either. If an older version of ONNX works then I will revert and build from source.
PS. I'd estimate the complete build time of this to be 14 hours on this device.