-
Notifications
You must be signed in to change notification settings - Fork 514
Add Dockerfile to examples/puzzletron #2009
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
grzegorz-k-karch
wants to merge
4
commits into
puzzletron_v2
Choose a base branch
from
gkarch/puzzletron_v2-nano-dockerfile
base: puzzletron_v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| ARG CUDA_VERSION=12.9.2 | ||
| ARG BUILD_BASE_IMAGE=nvidia/cuda:${CUDA_VERSION}-cudnn-devel-ubuntu24.04 | ||
|
|
||
| FROM ${BUILD_BASE_IMAGE} AS base | ||
|
|
||
| ARG DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| ARG MODEL_OPT_ROOT=/workspace/modelopt | ||
| ARG VLLM_ROOT=/workspace/vllm | ||
| ARG AUTOMODEL_ROOT=/workspace/Automodel | ||
|
|
||
| # Copy only the setup script first so that the expensive dep-install layer | ||
| # stays cached as long as the script hasn't changed, regardless of source edits. | ||
| COPY examples/puzzletron/configs/families/nemotron3/setup_env.sh /tmp/setup_env.sh | ||
|
|
||
| # Tell the build system to proceed without a live GPU | ||
| ARG FORCE_CUDA=1 | ||
| # Avoid GPU detection at compile time | ||
| ARG TORCH_CUDA_ARCH_LIST="8.0;8.6;9.0;10.0" | ||
|
|
||
| RUN MODEL_OPT_ROOT="${MODEL_OPT_ROOT}" \ | ||
| VLLM_ROOT="${VLLM_ROOT}" \ | ||
| AUTOMODEL_ROOT="${AUTOMODEL_ROOT}" \ | ||
| bash /tmp/setup_env.sh --deps | ||
|
|
||
| ENV VIRTUAL_ENV=/venv | ||
| ENV PATH=/venv/bin/:$PATH | ||
|
|
||
| # Copy the full repo after deps so source changes don't bust the cache above. | ||
| COPY . "${MODEL_OPT_ROOT}"/ | ||
|
|
||
| RUN MODEL_OPT_ROOT="${MODEL_OPT_ROOT}" bash /tmp/setup_env.sh --modelopt |
119 changes: 119 additions & 0 deletions
119
examples/puzzletron/configs/families/nemotron3/setup_env.sh
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| #!/usr/bin/env bash | ||
| # Shared setup script for the Nemotron3 Puzzletron environment. | ||
| # | ||
| # Used by the Dockerfile (--deps before COPY, --modelopt after COPY) and | ||
| # can be run standalone to set up a bare-metal environment (no arguments). | ||
| # | ||
| # Usage: | ||
| # ./setup_env.sh [--deps | --modelopt] | ||
| # --deps System packages, git clones, venv, pip deps — safe to Docker-cache | ||
| # --modelopt Install the local ModelOpt source only (run after --deps) | ||
| # (no args) Full setup — suitable for bare-metal | ||
| # | ||
| # Configurable via environment variables (all have defaults): | ||
| # MODEL_OPT_ROOT Path to the ModelOpt repo root | ||
| # Default: 5 directories above this script | ||
| # VLLM_ROOT Where to clone vLLM (default: /workspace/vllm) | ||
| # AUTOMODEL_ROOT Where to clone Automodel (default: /workspace/Automodel) | ||
| # VIRTUAL_ENV Python venv path (default: /venv) | ||
| # SKIP_APT Set to 1 to skip apt-get (default: 0) | ||
| # FORCE_CUDA Build CUDA exts without a live GPU (default: 1) | ||
| # TORCH_CUDA_ARCH_LIST Architectures to compile for | ||
| # (default: "8.0;8.6;9.0;10.0") | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| MODE="${1:-all}" | ||
|
|
||
| # ── Paths ────────────────────────────────────────────────────────────────────── | ||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| # examples/puzzletron/configs/families/nemotron3 → 5 levels up to repo root | ||
| MODEL_OPT_ROOT="${MODEL_OPT_ROOT:-$(cd "${SCRIPT_DIR}/../../../../.." && pwd)}" | ||
| VLLM_ROOT="${VLLM_ROOT:-/workspace/vllm}" | ||
| AUTOMODEL_ROOT="${AUTOMODEL_ROOT:-/workspace/Automodel}" | ||
| VIRTUAL_ENV="${VIRTUAL_ENV:-/venv}" | ||
|
|
||
| # ── Build flags ──────────────────────────────────────────────────────────────── | ||
| SKIP_APT="${SKIP_APT:-0}" | ||
| export FORCE_CUDA="${FORCE_CUDA:-1}" | ||
| export TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-8.0;8.6;9.0;10.0}" | ||
|
|
||
| activate_venv() { | ||
| export VIRTUAL_ENV | ||
| export PATH="${VIRTUAL_ENV}/bin:${PATH}" | ||
| } | ||
|
|
||
| # ══════════════════════════════════════════════════════════════════════════════ | ||
| # DEPS phase — nothing here depends on the local ModelOpt source. | ||
| # In Docker this runs before `COPY .` so it stays cached across source changes. | ||
| # ══════════════════════════════════════════════════════════════════════════════ | ||
| install_deps() { | ||
| if [[ "${SKIP_APT}" != "1" ]]; then | ||
| apt-get update | ||
| apt-get install -y build-essential cmake git ninja-build \ | ||
| python3 python3-dev python3-pip python3-venv | ||
| fi | ||
|
|
||
| # Clone external repos (idempotent) | ||
| [[ -d "${VLLM_ROOT}" ]] || \ | ||
| git clone --branch feature/add_anymodel_to_vllm --single-branch \ | ||
| https://github.com/Separius/vllm.git "${VLLM_ROOT}" | ||
| [[ -d "${AUTOMODEL_ROOT}" ]] || \ | ||
| git clone --branch puzzletron --single-branch \ | ||
| https://github.com/Separius/Automodel.git "${AUTOMODEL_ROOT}" | ||
|
|
||
| [[ -d "${VIRTUAL_ENV}" ]] || python3 -m venv "${VIRTUAL_ENV}" | ||
| activate_venv | ||
|
|
||
| python -m pip install --upgrade pip \ | ||
| "setuptools>=80,<81" "setuptools-scm>=8" setuptools-rust wheel \ | ||
| "packaging>=24.2" "cmake>=3.26.1" ninja jinja2 | ||
|
|
||
| python -m pip install \ | ||
| torch==2.11.0 torchvision==0.26.0 torchaudio==2.11.0 \ | ||
| --index-url https://download.pytorch.org/whl/cu129 | ||
|
|
||
| VLLM_USE_PRECOMPILED=1 VLLM_PRECOMPILED_WHEEL_VARIANT=cu129 \ | ||
| python -m pip install --no-build-isolation -e "${VLLM_ROOT}" | ||
|
|
||
| python -m pip install -e "${AUTOMODEL_ROOT}" | ||
| python -m pip install aiperf | ||
|
|
||
| # CUDA extension packages placed here (before COPY .) so they stay cached | ||
| # across ModelOpt source changes in Docker builds. | ||
| python -m pip install --no-build-isolation \ | ||
| "git+https://github.com/fanshiqing/grouped_gemm@v1.1.4" | ||
| python -m pip install "mamba-ssm[causal-conv1d]" --no-build-isolation | ||
| python -m pip install "flash-linear-attention[cuda]" | ||
| } | ||
|
|
||
| # ══════════════════════════════════════════════════════════════════════════════ | ||
| # MODELOPT phase — installs the local ModelOpt source. | ||
| # In Docker this runs after `COPY .` and re-runs on every source change. | ||
| # ══════════════════════════════════════════════════════════════════════════════ | ||
| install_modelopt() { | ||
| activate_venv | ||
| python -m pip install -e "${MODEL_OPT_ROOT}[hf]" | ||
| } | ||
|
|
||
| # ── Dispatch ─────────────────────────────────────────────────────────────────── | ||
| case "${MODE}" in | ||
| --deps) | ||
| install_deps | ||
| ;; | ||
| --modelopt) | ||
| install_modelopt | ||
| ;; | ||
| all) | ||
| install_deps | ||
| install_modelopt | ||
| echo "" | ||
| echo "Setup complete. Activate your environment with:" | ||
| echo " source ${VIRTUAL_ENV}/bin/activate" | ||
| ;; | ||
| *) | ||
| echo "Unknown argument: ${MODE}" >&2 | ||
| echo "Usage: $0 [--deps | --modelopt]" >&2 | ||
| exit 1 | ||
| ;; | ||
| esac |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need such a complicated setup? Can we just use nemo:26.06 as base container and install puzzletron dependencies on top of it? Would be much simpler and also much faster docker build step