diff --git a/detectors/Dockerfile.hf.ppc64le b/detectors/Dockerfile.hf.ppc64le new file mode 100644 index 0000000..1f829ba --- /dev/null +++ b/detectors/Dockerfile.hf.ppc64le @@ -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