# Package logic: # 1. base target: # - Install tools. # - Upgrade GCC if needed. # - Install C buildkit. # - Upgrade Python if needed. # - Install Python buildkit. # 2. gpustack target(final): # - Install GPUStack. # - Install Vox-Box as an independent executor for GPUStack, # see https://github.com/gpustack/gpustack/pull/2473#issue-3222391256. # - Set up the entrypoint to start GPUStack. # Arguments description: # - PYTHON_VERSION is the version of Python, # which should be properly set, it must be 3.x. ARG PYTHON_VERSION=3.11 # Stage Base # # Example build command: # docker build --tag=gpustack/gpustack:cpu-base --file=pack/Dockerfile.cpu --target=base --progress=plain . # FROM ubuntu:22.04 AS base SHELL ["/bin/bash", "-eo", "pipefail", "-c"] ARG TARGETPLATFORM ARG TARGETOS ARG TARGETARCH ENV DEBIAN_FRONTEND=noninteractive \ LANG='en_US.UTF-8' \ LANGUAGE='en_US:en' \ LC_ALL='en_US.UTF-8' ARG TARGETPLATFORM ARG TARGETOS ARG TARGETARCH ENV DEBIAN_FRONTEND=noninteractive \ LANG='en_US.UTF-8' \ LANGUAGE='en_US:en' \ LC_ALL='en_US.UTF-8' RUN < /etc/timezone \ && dpkg-reconfigure --frontend noninteractive tzdata # Cleanup rm -rf /var/tmp/* \ && rm -rf /tmp/* \ && rm -rf /var/cache/apt EOF ## Upgrade GCC if needed RUN <= 21.04" | bc -l) )); then echo "Skipping GCC upgrade for ${VERSION_ID}..." exit 0 fi # Install apt-get install -y --no-install-recommends \ gcc-11 g++-11 gfortran-11 gfortran # Update alternatives if [[ -f /etc/alternatives/gcov-dump ]]; then update-alternatives --remove-all gcov-dump; fi; update-alternatives --install /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-11 10 if [[ -f /etc/alternatives/lto-dump ]]; then update-alternatives --remove-all lto-dump; fi; update-alternatives --install /usr/bin/lto-dump lto-dump /usr/bin/lto-dump-11 10 if [[ -f /etc/alternatives/gcov ]]; then update-alternatives --remove-all gcov; fi; update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-11 10 if [[ -f /etc/alternatives/gcc ]]; then update-alternatives --remove-all gcc; fi; update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 10 if [[ -f /etc/alternatives/gcc-nm ]]; then update-alternatives --remove-all gcc-nm; fi; update-alternatives --install /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-11 10 if [[ -f /etc/alternatives/cpp ]]; then update-alternatives --remove-all cpp; fi; update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-11 10 if [[ -f /etc/alternatives/g++ ]]; then update-alternatives --remove-all g++; fi; update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 10 if [[ -f /etc/alternatives/gcc-ar ]]; then update-alternatives --remove-all gcc-ar; fi; update-alternatives --install /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-11 10 if [[ -f /etc/alternatives/gcov-tool ]]; then update-alternatives --remove-all gcov-tool; fi; update-alternatives --install /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-11 10 if [[ -f /etc/alternatives/gcc-ranlib ]]; then update-alternatives --remove-all gcc-ranlib; fi; update-alternatives --install /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-11 10 if [[ -f /etc/alternatives/gfortran ]]; then update-alternatives --remove-all gfortran; fi; update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-11 10 # Cleanup rm -rf /var/tmp/* \ && rm -rf /tmp/* \ && rm -rf /var/cache/apt EOF ## Install C buildkit RUN </dev/null | grep libpython${PYTHON_VERSION})" ]]; then PYTHON_LIB_PREFIX=$(python3 -c "import sys; print(sys.base_prefix);") echo "${PYTHON_LIB_PREFIX}/lib" >> /etc/ld.so.conf.d/python3.conf echo "${PYTHON_LIB_PREFIX}/lib64" >> /etc/ld.so.conf.d/python3.conf fi exit 0 fi # Add deadsnakes PPA for Python versions for i in 1 2 3; do add-apt-repository -y ppa:deadsnakes/ppa && break || { echo "Attempt $i failed, retrying in 5s..."; sleep 5; } done apt-get update -y # Install apt-get install -y --no-install-recommends \ python${PYTHON_VERSION} \ python${PYTHON_VERSION}-dev \ python${PYTHON_VERSION}-venv \ python${PYTHON_VERSION}-distutils \ python${PYTHON_VERSION}-lib2to3 \ python${PYTHON_VERSION}-gdbm \ python${PYTHON_VERSION}-tk \ libibverbs-dev # Update alternatives if [[ -f /etc/alternatives/python3 ]]; then update-alternatives --remove-all python3; fi; update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1 if [[ -f /etc/alternatives/python ]]; then update-alternatives --remove-all python; fi; update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1 curl -sS "https://bootstrap.pypa.io/get-pip.py" | python${PYTHON_VERSION} if [[ -f /etc/alternatives/2to3 ]]; then update-alternatives --remove-all 2to3; fi; update-alternatives --install /usr/bin/2to3 2to3 /usr/bin/2to3${PYTHON_VERSION} 1 || true if [[ -f /etc/alternatives/pydoc3 ]]; then update-alternatives --remove-all pydoc3; fi; update-alternatives --install /usr/bin/pydoc3 pydoc3 /usr/bin/pydoc${PYTHON_VERSION} 1 || true if [[ -f /etc/alternatives/idle3 ]]; then update-alternatives --remove-all idle3; fi; update-alternatives --install /usr/bin/idle3 idle3 /usr/bin/idle${PYTHON_VERSION} 1 || true if [[ -f /etc/alternatives/python3-config ]]; then update-alternatives --remove-all python3-config; fi; update-alternatives --install /usr/bin/python3-config python3-config /usr/bin/python${PYTHON_VERSION}-config 1 || true # Cleanup rm -rf /var/tmp/* \ && rm -rf /tmp/* \ && rm -rf /var/cache/apt EOF ## Install Python buildkit ENV PIP_NO_CACHE_DIR=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ PIP_ROOT_USER_ACTION=ignore RUN </tmp/requirements.txt build cmake<4 ninja<1.11 setuptools<80 setuptools-scm packaging<25 wheel pybind11 Cython psutil==7.0.0 pipx==1.7.1 EOT pip install -r /tmp/requirements.txt # Cleanup rm -rf /var/tmp/* \ && rm -rf /tmp/* EOF ## Preset this to simplify configuration, ENV LOCAL_VENVS=/opt/venvs \ USE_EMOJI="false" # # Stage GPUStack # # Example build command: # docker build --tag=gpustack/gpustack:cpu --file=pack/Dockerfile.cpu --progress=plain . # FROM base AS gpustack SHELL ["/bin/bash", "-eo", "pipefail", "-c"] ARG TARGETPLATFORM ARG TARGETOS ARG TARGETARCH ## Install GPUStack RUN --mount=type=bind,target=/workspace/gpustack,rw <