0

I want to use the ydf package in a docker image, but every time I try to build Docker Image of Python with ydf package I get this error:

1.699 ERROR: Could not find a version that satisfies the requirement ydf (from versions: 0.0.0)
1.700 ERROR: No matching distribution found for ydf

But I use compatible version of Python, because YDF is available on Python 3.8, 3.9, 3.10, 3.11 and 3.12, on Windows x86-64 Linux x86-64, and macOS ARM64.(from text

For more context I'm on Mac M3 and when I install ydf on Python 3.11 locally, that's work and I can use it.

Here is my Dockerfile:

FROM python:3.11.0

WORKDIR /app

COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 8000

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

And here is my requirements.txt :

fastapi
uvicorn
pandas
ydf

I have already tried lot of solutions:

  • Install ydf directly on the Dockerfile RUN pip install --dry-run ydf

  • Install ydf directly on the Dockerfile from file: RUN pip install --no-cache-dir ydf-0.10.0-cp312-cp312-macosx_12_0_arm64.whl

  • I also followed the official ydf documentation to dockerize a model: text And I have the same error when I try to build image.

  • I have tried with lot of python official image (3.9-slim, 3.10 ...)

Have you already solve this problem, or do you have any solutions to solve it ? Thank's in advance

1
  • I have recently show that, ydf can be installed when I used --platform=linux/amd64 argument on the Python image on the Dockerfile. But if I use, --platform=linux/arm64 That's doesn't work, do you how I can build image of python on Mac ARM64 with Docker ? Commented Feb 25 at 21:56

1 Answer 1

0

Here, pip is telling you there is no ydf package for your platform (Linux + Python 3.11 + arm64) on PyPI.

Note that even though you are on a Mac, the python:3.11.0 container image uses Linux, so you need a Linux ydf package (this is why installing the *macosx_12_0_arm64.whl wheel did not work for you).

Look at the releases on PyPI for the most recent version as of this writing (v0.11.0).

A list of the available files on the PyPI.org page for 'ydf', showing 0 'aarch64' linux files.

There are:

  • no source distributions (*.tar.gz)
  • no aarch64 Linux wheels (manylinux*_aarch64.whl)

Until then, your options are:

I was not able build ydf aarch64 wheels from source, but here's what I tried in case it's helpful

I was not able to get that working, but here are some notes.

Here's as far as I got, based on ydf's docs (yggdrasil_decision_forests/port/python/INSTALLATION.md)

# clone the repo
git clone [email protected]:google/yggdrasil-decision-forests.git
cd ./yggdrasil-decision-forests
git checkout /pydf_0.11.0

# create an image to build aarch64 Linux wheels in
# (adopted from the Dockerfile in that repo)
docker build -t ydf-builder:local -f- . <<EOF
FROM quay.io/pypa/manylinux2014_aarch64
WORKDIR /build_tools
ENV PATH="\$PATH:/build_tools"
ADD https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-linux-arm64 bazel
RUN chmod +x bazel
# install a rust compiler for 'polars' (has to be built from source on Linux aarch64 as of March 2025)
RUN yum install -y epel-release && yum update -y && yum install -y cargo rust && rustup update
ENV CC=gcc
EOF

# build wheel for a specific Python version
cd ./yggdrasil_decision_forests/port/python
PYTHON_VERSION="3.11"
docker run \
    --rm \
    --env CARGO_HOME=/root/.cargo/bin \
    -v pydf_venv_cache_${PYTHON_VERSION}:/tmp/venv \
    -v pydf_bazel_cache_${PYTHON_VERSION}:/root/.cache \
    -v $(pwd)/../../../:/src \
    -w /src/yggdrasil_decision_forests/port/python \
    -it ydf-builder:local \
    /bin/bash -c "python${PYTHON_VERSION} -m venv /tmp/venv; source /tmp/venv/bin/activate; RUN_TESTS=0 ./tools/build_test_linux.sh; ./tools/package_linux.sh;"

That should leave being a wheel in the dist/ folder, which you could then copy into your Docker image and pip install.

However, for me, compilation of ydf failed with errors like this:

/opt/rh/devtoolset-10/root/usr/lib/gcc/aarch64-redhat-linux/10/include/arm_acle.h:110:1: error: inlining failed in call to 'always_inline' 'uint32_t __crc32cb(uint32_t, uint8_t)': target specific option mismatch 110 | __crc32cb (uint32_t __a, uint8_t __b)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.