Onnxruntime: Alpine Linux support

Created on 25 Jan 2020  路  4Comments  路  Source: microsoft/onnxruntime

Is your feature request related to a problem? Please describe.
onnxruntime-1.1.1-cp36-cp36m-manylinux1_x86_64.whl is not supported on Alpine 3.11

System information

  • ONNX Runtime version (you are using):
    1.1.1

Describe the solution you'd like
Include support for Alpine Linux in manylinux wheel so pip install onnxruntime works

Describe alternatives you've considered
Building from source

Additional context
ERROR: onnxruntime-1.1.1-cp36-cp36m-manylinux1_x86_64.whl is not a supported wheel on this platform.

contributions-welcome

Most helpful comment

Unfortunately, manylinux wheels are not compatible with Alpine Linux. In fact, Alpine Linux and musl based distros are not currently not supported by python wheels:
https://github.com/pypa/manylinux/issues/37

Alpine is based on musl libc, as opposed glibc, the GNU standard C library, which is used by most Linux distros and supported by manylinux. musl is a minimalistic and novel libc implementation, and as such misses many glibc features. In addition, there are subtle functional differences (such as smaller default thread stack size, dynamic linking behavior, locales implementation, etc.).

Detailed musl/glibc comparisons could be found here:

Until Alpine Linux wheel support is added, installing wheels on Alpine will have to fall back to building the wheel from source, which will probably require support in the onnxruntime wheel build script.

FYI, I created a docker image for building onnxruntime from source on Alpine 3.11 (python 3.8.2, gcc 9.2.0) - perhaps it could be useful: Dockerfile. Some minor tweaking was required to overcome some build and dependency issues, but besides that the C++ build itself was very smooth.

All 4 comments

Any hint what we should do?

Sadly I am not sure why manylinux for onnxruntime does not include support for Alpine Linux, but here are steps to quickly reproduce the error and some additional info.

Why Alpine Linux?
I am building a simple and small predictor in Docker, and alpine has much smaller image than Ubuntu
Does installing onnx give the same error?
No, pip install onnx works as intended
Steps to replicate

#Dockerfile
FROM python:3.6.10-alpine3.11

RUN apk --no-cache add wget build-base gcc git cmake gfortran musl-dev bash bash-doc bash-completion freetype-dev &&\
    apk --no-cache add jpeg-dev zlib-dev make && pip --version && pip install --upgrade pip

RUN pip install onnx==1.6.0 onnxruntime==1.1.1

Build Docker image using
docker build -t onnximage -f <Dockerfile path> .

Python version
Python 3.6.10

I am happy to provide/try anything. At the moment I am trying to compile from source.

Unfortunately, manylinux wheels are not compatible with Alpine Linux. In fact, Alpine Linux and musl based distros are not currently not supported by python wheels:
https://github.com/pypa/manylinux/issues/37

Alpine is based on musl libc, as opposed glibc, the GNU standard C library, which is used by most Linux distros and supported by manylinux. musl is a minimalistic and novel libc implementation, and as such misses many glibc features. In addition, there are subtle functional differences (such as smaller default thread stack size, dynamic linking behavior, locales implementation, etc.).

Detailed musl/glibc comparisons could be found here:

Until Alpine Linux wheel support is added, installing wheels on Alpine will have to fall back to building the wheel from source, which will probably require support in the onnxruntime wheel build script.

FYI, I created a docker image for building onnxruntime from source on Alpine 3.11 (python 3.8.2, gcc 9.2.0) - perhaps it could be useful: Dockerfile. Some minor tweaking was required to overcome some build and dependency issues, but besides that the C++ build itself was very smooth.

@shaharv Thanks for the amazing explanation and the Dockerfile! You rock!

Was this page helpful?
0 / 5 - 0 ratings