fix(setup_host): make the script work on ubuntu 26.04 - #174
Merged
Merged
Conversation
The script aborted partway through on a fresh host regardless of Ubuntu version, leaving pixi, uv and the docker group setup uninstalled: - docker run hello-world ran before usermod -aG docker, so it hit a permission denied on the socket and set -e killed the script. The group setup now happens right after the docker install, and the smoke tests run under sudo. - sudo groupadd docker always failed, since docker-ce already creates the group. It is now guarded with getent. - newgrp docker at the end would have spawned an interactive subshell. Ubuntu 26.04 ships neither sg nor newgrp, so this is gone in favour of a "log out and back in" message. Ubuntu 26.04 specifics: - download.docker.com does publish a resolute suite, so $VERSION_CODENAME still resolves, but the script now falls back to noble if the host's codename has not been published yet. - nvidia-docker2 is dropped. It is deprecated, frozen at 2.14.0 and no longer in NVIDIA's docs; nvidia-container-toolkit alone is what nvidia-ctk runtime configure needs. Other fixes: - The NVIDIA half is skipped unless nvidia-smi -L succeeds, with a hint to install a driver first, rather than installing a toolkit that every GPU container then fails against. - The conflicting-package removal is a single apt-get remove -y instead of a loop without -y that prompted mid-script. - gpg --dearmor gains --yes so re-runs do not prompt, and the pixi completion line is only appended to .bashrc once. - Added a GPU smoke test using ubuntu:$VERSION_ID. A plain ubuntu image avoids pinning a CUDA version, since the toolkit injects nvidia-smi and the driver libraries from the host. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Reviewer's GuideUpdates host provisioning for reliable, non-interactive execution on Ubuntu 22.04–26.04, including Docker repository fallback and group handling, conditional modern NVIDIA Toolkit setup with smoke tests, and idempotent pixi/uv installation guidance. Sequence diagram for Docker setup and smoke testingsequenceDiagram
participant User
participant Setup as setup_host.sh
participant Apt
participant Docker
participant System
User->>Setup: Run as non-root user
Setup->>System: sudo -v
Setup->>Apt: apt-get remove -y conflicting packages
Setup->>Apt: Resolve published Docker suite
Setup->>Apt: apt-get install -y docker-ce and plugins
Setup->>System: getent group docker
alt docker group missing
Setup->>System: groupadd docker
end
Setup->>System: usermod -aG docker USER
Setup->>Docker: sudo docker run --rm hello-world
Setup->>User: Log out and back in to apply group membership
Sequence diagram for conditional NVIDIA Container Toolkit setupsequenceDiagram
participant Setup as setup_host.sh
participant Driver
participant Apt
participant Docker
Setup->>Driver: nvidia-smi -L
alt NVIDIA driver works
Setup->>Apt: Install nvidia-container-toolkit
Setup->>Docker: nvidia-ctk runtime configure
Setup->>Docker: Restart Docker
Setup->>Docker: sudo docker run --rm --gpus all ubuntu:VERSION_ID nvidia-smi
else Driver unavailable
Setup->>Setup: Skip NVIDIA setup
Setup->>Setup: Print driver installation hint
end
Flow diagram for resilient Ubuntu host setupflowchart TD
A[Start as non-root user] --> B[sudo -v]
B --> C[Remove conflicting packages]
C --> D[Resolve Docker apt suite]
D --> E[Install Docker]
E --> F[Ensure docker group]
F --> G[Add current user to docker group]
G --> H{nvidia-smi succeeds?}
H -->|Yes| I[Install NVIDIA Container Toolkit]
I --> J[Configure NVIDIA Docker runtime]
J --> K[Restart Docker]
H -->|No| L[Skip NVIDIA setup and show driver hint]
K --> M[Run Docker smoke tests]
L --> M
M --> N[Install pixi and uv]
N --> O[Log out and back in]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
scripts/setup_host.shaborted partway through on a fresh host regardless of Ubuntu version, leaving pixi, uv and the docker group setup uninstalled. Verified on a clean Ubuntu 26.04.1 (resolute, kernel 7.0.0-31) machine.Bugs fixed
docker run hello-worldran beforeusermod -aG docker, so it hitpermission deniedon the socket andset -ekilled the script. Group setup now happens right after the docker install, and the smoke tests run undersudo.sudo groupadd dockeralways failed, sincedocker-cealready creates the group — anotherset -eabort. Now guarded withgetent.newgrp dockerat the end would have spawned an interactive subshell. Ubuntu 26.04 ships neithersgnornewgrp(loginis now really util-linux 2.41.3, and shadow'spasswd4.17.4 dropped them), so this is gone in favour of a "log out and back in" message.-y, which prompted mid-script. Now a singleapt-get remove -y.Ubuntu 26.04 specifics
download.docker.comdoes publish aresolutesuite (docker-ce 29.8.0, containerd.io 2.3.5), so$VERSION_CODENAMEstill resolves. The script now also falls back tonobleif the host's codename has not been published yet.nvidia-docker2is dropped — deprecated, frozen at 2.14.0 and no longer in NVIDIA's docs.nvidia-container-toolkitalone (1.20.0) is whatnvidia-ctk runtime configureneeds.Other
nvidia-smi -Lsucceeds, with a hint to install a driver first, rather than installing a toolkit that every GPU container then fails against.gpg --dearmorgains--yesso re-runs do not prompt, and the pixi completion line is only appended to.bashrconce.ubuntu:$VERSION_ID. A plain ubuntu image avoids pinning a CUDA version: the toolkit injectsnvidia-smiand the driver libraries from the host.nvidia/cudaonly publishesubuntu26.04tags for CUDA >= 13.3, which setsNVIDIA_REQUIRE_CUDA=cuda>=13.3and would refuse to start on the 580 driver branch (CUDA 13.0).README.md: the script no longer claims to assume ubuntu 22.04.Testing
Run end to end on Ubuntu 26.04.1 with an NVIDIA Quadro M2000M and driver 580.178.04. Docker 29.8.0, compose v5.5.1, buildx 0.37.1, nvidia-container-toolkit 1.20.0 and the
nvidiaruntime in/etc/docker/daemon.jsonall install cleanly, and the docker group membership is applied.🤖 Generated with Claude Code
Summary by Sourcery
Make host setup complete reliably across supported Ubuntu releases, including Ubuntu 26.04, with current Docker and NVIDIA container tooling.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: