Skip to content

Add support for ppc64le compatible Hugging Face detector #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions detectors/Dockerfile.hf.ppc64le
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
FROM registry.access.redhat.com/ubi9/ubi-minimal as base

ENV OPENBLAS_VERSION=0.3.30
ENV PATH="$HOME/.cargo/bin:$PATH"
ENV TORCH_VERSION=2.6.0
ENV LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib

RUN microdnf update -y && \
microdnf install -y --nodocs \
python-pip python-devel git gcc-toolset-13 rust cargo wget unzip && \
pip install --upgrade --no-cache-dir 'cmake<4' pip wheel && \
microdnf clean all

FROM base as torch-builder
USER root

ARG MAX_JOBS
ARG _GLIBCXX_USE_CXX11_ABI=1

RUN source /opt/rh/gcc-toolset-13/enable && \
git clone --recursive https://github.com/pytorch/pytorch.git -b v${TORCH_VERSION} && \
cd pytorch && pip install -r requirements.txt && \
python setup.py develop && \
rm -f dist/torch*+git*whl && \
MAX_JOBS=${MAX_JOBS:-$(nproc)} \
PYTORCH_BUILD_VERSION=${TORCH_VERSION} PYTORCH_BUILD_NUMBER=1 pip wheel . --wheel-dir /torchwheels/

FROM base AS openblas-builder
WORKDIR /root
RUN source /opt/rh/gcc-toolset-13/enable && \
wget https://github.com/OpenMathLib/OpenBLAS/releases/download/v${OPENBLAS_VERSION}/OpenBLAS-${OPENBLAS_VERSION}.zip && \
unzip OpenBLAS-${OPENBLAS_VERSION}.zip && cd OpenBLAS-${OPENBLAS_VERSION} && \
make -j$(nproc) TARGET=POWER9 BINARY=64 USE_OPENMP=1 USE_THREAD=1 NUM_THREADS=120 DYNAMIC_ARCH=1 INTERFACE64=0

# FROM icr.io/fm-stack/ubi9-minimal-py39-torch as builder
FROM base as builder

# Install PyTorch
RUN --mount=type=bind,from=torch-builder,source=/torchwheels/,target=/torchwheels/,ro \
HOME=/root pip install /torchwheels/*.whl

COPY --from=openblas-builder /root/OpenBLAS-${OPENBLAS_VERSION} /openblas
RUN PREFIX=/usr/local make -C /openblas install && rm -rf /openblas

COPY ./common/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY ./huggingface/requirements.txt .

RUN source /opt/rh/gcc-toolset-13/enable && \
pip install --no-cache-dir -r requirements.txt

FROM builder

WORKDIR /app
ARG CACHEBUST=1
RUN echo "$CACHEBUST"
COPY ./common /common
COPY ./huggingface/app.py /app
COPY ./huggingface/detector.py /app
COPY ./huggingface/scheme.py /app

EXPOSE 8000
CMD ["uvicorn", "app:app" "--workers", "4", "--host", "0.0.0.0", "--port", "8000", "--log-config", "/common/log_conf.yaml"]

# gunicorn main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000