-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,68 @@ | ||
FROM registry.access.redhat.com/ubi9/ubi:latest as base | ||
|
||
ENV CUDA_VERSION=11.8.0 \ | ||
NV_CUDA_LIB_VERSION=11.8.0-1 \ | ||
NVIDIA_VISIBLE_DEVICES=all \ | ||
NVIDIA_DRIVER_CAPABILITIES=compute,utility \ | ||
NV_CUDA_CUDART_VERSION=11.8.89-1 \ | ||
NV_CUDA_COMPAT_VERSION=520.61.05-1 | ||
|
||
RUN dnf config-manager \ | ||
--add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/cuda-rhel9.repo \ | ||
&& dnf install -y \ | ||
cuda-cudart-11-8-${NV_CUDA_CUDART_VERSION} \ | ||
cuda-compat-11-8-${NV_CUDA_COMPAT_VERSION} \ | ||
&& echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf \ | ||
&& echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf \ | ||
&& dnf clean all | ||
FROM registry.access.redhat.com/ubi9/ubi:latest as cuda-base | ||
ARG CUDA_VERSION=12-3 | ||
|
||
ENV CUDA_VERSION=${CUDA_VERSION} | ||
|
||
RUN dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/cuda-rhel9.repo && \ | ||
dnf install -y \ | ||
cuda-cudart-${CUDA_VERSION} \ | ||
cuda-compat-${CUDA_VERSION} \ | ||
libcublas-${CUDA_VERSION} \ | ||
&& \ | ||
echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \ | ||
echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf && \ | ||
dnf clean all | ||
|
||
ENV CUDA_HOME="/usr/local/cuda" | ||
ENV PATH="/usr/local/nvidia/bin:${CUDA_HOME}/bin:${PATH}" | ||
ENV LD_LIBRARY_PATH="/usr/local/nvidia/lib:/usr/local/nvidia/lib64:$CUDA_HOME/lib64:$CUDA_HOME/extras/CUPTI/lib64:${LD_LIBRARY_PATH}" | ||
|
||
|
||
FROM base as builder | ||
ENV NV_NVTX_VERSION=11.8.86-1 \ | ||
NV_LIBNPP_VERSION=11.8.0.86-1 \ | ||
NV_LIBCUBLAS_VERSION=11.11.3.6-1 \ | ||
NV_LIBNCCL_PACKAGE_VERSION=2.15.5-1+cuda11.8 \ | ||
NVCC_VERSION=11-8 \ | ||
CUBLAS_VERSION=11-8 \ | ||
CUDART_VERSION=11-8 | ||
FROM cuda-base as builder | ||
ARG CUDA_VERSION | ||
ENV CUDA_VERSION=${CUDA_VERSION} | ||
|
||
RUN dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/cuda-rhel9.repo && \ | ||
dnf -y update && \ | ||
dnf -y install \ | ||
git gcc-toolset-12-gcc-c++ gcc-toolset-12 cmake shadow-utils python3.11-pip \ | ||
cuda-nvcc-${NVCC_VERSION} \ | ||
libcublas-${CUBLAS_VERSION} \ | ||
cuda-libraries-11-8-${NV_CUDA_LIB_VERSION} \ | ||
cuda-nvtx-11-8-${NV_NVTX_VERSION} \ | ||
libnpp-11-8-${NV_LIBNPP_VERSION} \ | ||
libcublas-11-8-${NV_LIBCUBLAS_VERSION} \ | ||
libnccl-${NV_LIBNCCL_PACKAGE_VERSION} && \ | ||
git gcc-toolset-12-gcc-c++ gcc-toolset-12 cmake python3.11-pip \ | ||
cuda-nvcc-${CUDA_VERSION} \ | ||
libcublas-devel-${CUDA_VERSION} \ | ||
cuda-cudart-devel-${CUDA_VERSION} \ | ||
cuda-driver-devel-${CUDA_VERSION} \ | ||
&& \ | ||
dnf clean all && \ | ||
pip3.11 install --no-cache-dir --upgrade pip wheel | ||
|
||
ENV POETRY_VIRTUALENVS_IN_PROJECT=1 | ||
|
||
RUN dnf -y install cuda-cudart-${CUDART_VERSION} | ||
# ENV POETRY_VIRTUALENVS_IN_PROJECT=1 | ||
# ENV CMAKE_ARGS="-DLLAMA_CUBLAS=on" | ||
WORKDIR /llama-cpp-python | ||
COPY pyproject.toml . | ||
COPY poetry.lock . | ||
|
||
# WORKDIR /llama-cpp-python | ||
# COPY pyproject.toml . | ||
# COPY poetry.lock . | ||
# RUN pip3.11 install poetry && \ | ||
# scl enable gcc-toolset-12 -- poetry install | ||
ENV CMAKE_ARGS="-DLLAMA_CUBLAS=on" | ||
RUN pip3.11 install poetry && \ | ||
scl enable gcc-toolset-12 -- poetry install | ||
|
||
|
||
# FROM base as deploy | ||
FROM cuda-base as deploy | ||
|
||
# RUN dnf -y update && \ | ||
# dnf -y install \ | ||
# shadow-utils python3.11 && \ | ||
# dnf clean all | ||
RUN dnf -y install \ | ||
shadow-utils python3.11 && \ | ||
dnf clean all | ||
|
||
# WORKDIR /llama-cpp-python | ||
WORKDIR /llama-cpp-python | ||
|
||
# COPY --from=builder /llama-cpp-python/.venv /llama-cpp-python/.venv | ||
COPY --from=builder /llama-cpp-python/.venv /llama-cpp-python/.venv | ||
|
||
# ENV VIRTUAL_ENV=/llama-cpp-python/.venv | ||
# ENV PATH="$VIRTUAL_ENV/bin:$PATH" | ||
ENV VIRTUAL_ENV=/llama-cpp-python/.venv | ||
ENV PATH="$VIRTUAL_ENV/bin:$PATH" | ||
|
||
# RUN groupadd --system llama --gid 1001 && \ | ||
# adduser --system --uid 1001 --gid 0 --groups llama \ | ||
# --create-home --home-dir /llama-cpp-python --shell /sbin/nologin \ | ||
# --comment "Llama user" llama | ||
RUN groupadd --system llama --gid 1001 && \ | ||
adduser --system --uid 1001 --gid 0 --groups llama \ | ||
--create-home --home-dir /llama-cpp-python --shell /sbin/nologin \ | ||
--comment "Llama user" llama | ||
|
||
# USER llama | ||
USER llama | ||
|
||
# # TODO: configuration | ||
# ENTRYPOINT ["python", "-m", "llama_cpp.server"] | ||
# TODO: configuration? | ||
ENTRYPOINT ["python", "-m", "llama_cpp.server"] |