Spaces:
Paused
Paused
| FROM nvidia/cuda:12.2.0-devel-ubuntu22.04 | |
| ARG PYTORCH_VERSION=2.4.0 | |
| ARG PYTHON_VERSION=3.9 | |
| ARG CUDA_VERSION=12.1 | |
| ARG MAMBA_VERSION=24.3.0-0 | |
| ARG CUDA_CHANNEL=nvidia | |
| ARG INSTALL_CHANNEL=pytorch | |
| # Automatically set by buildx | |
| ARG TARGETPLATFORM | |
| # Using a 'user' seems to give permission errors for writing to txt files, | |
| # unless files are made world-read/write-able. | |
| RUN useradd -m -u 1000 user | |
| #ENV HOME=/home/user \ | |
| # PATH=/home/user/.local/bin:/opt/conda/bin:$PATH | |
| ENV PATH=/opt/conda/bin:$PATH | |
| RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| ca-certificates \ | |
| ccache \ | |
| curl \ | |
| python3 \ | |
| python3-pip \ | |
| git && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Install conda | |
| # translating Docker's TARGETPLATFORM into mamba arches | |
| RUN case ${TARGETPLATFORM} in \ | |
| "linux/arm64") MAMBA_ARCH=aarch64 ;; \ | |
| *) MAMBA_ARCH=x86_64 ;; \ | |
| esac && \ | |
| curl -fsSL -v -o ~/mambaforge.sh -O "https://github.com/conda-forge/miniforge/releases/download/${MAMBA_VERSION}/Mambaforge-${MAMBA_VERSION}-Linux-${MAMBA_ARCH}.sh" | |
| RUN chmod +x ~/mambaforge.sh && \ | |
| bash ~/mambaforge.sh -b -p /opt/conda && \ | |
| rm ~/mambaforge.sh | |
| # Install pytorch | |
| # On arm64 we exit with an error code | |
| RUN case ${TARGETPLATFORM} in \ | |
| "linux/arm64") exit 1 ;; \ | |
| *) /opt/conda/bin/conda update -y conda && \ | |
| /opt/conda/bin/conda install -c "${INSTALL_CHANNEL}" -c "${CUDA_CHANNEL}" -y "python=${PYTHON_VERSION}" "pytorch=$PYTORCH_VERSION" "pytorch-cuda=$(echo $CUDA_VERSION | cut -d'.' -f 1-2)" ;; \ | |
| esac && \ | |
| /opt/conda/bin/conda clean -ya | |
| COPY ./requirements.txt requirements.txt | |
| RUN pip install -r requirements.txt | |
| RUN git clone -b energy_star_dev https://github.com/huggingface/optimum-benchmark.git /optimum-benchmark && cd optimum-benchmark && pip install -e . | |
| # Expose the secret token at buildtime and use its value as git remote URL | |
| RUN --mount=type=secret,id=BULK_ENERGY_TOKEN,mode=0444,required=true \ | |
| git init && \ | |
| git remote add origin $(cat /run/secrets/BULK_ENERGY_TOKEN) | |
| COPY --chown=user . /app | |
| USER user | |
| WORKDIR /app | |
| #RUN chmod 777 /app/*.py | |
| RUN chmod 777 /app/attempts.txt | |
| RUN chmod 777 /app/failed_attempts.txt | |
| RUN chmod +x /app/entrypoint.sh | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |