npx skills add ...
npx skills add nvidia/skills --skill tao-run-on-docker
Docker conventions for running NVIDIA GPU container workloads — NGC authentication, --gpus flag, mount patterns,
npx skills add nvidia/skills --skill tao-run-on-docker
Standalone install? If this session was not initialized by the TAO skill bank plugin, run the
tao-setupskill first (host preflight, credentials, cross-skill discovery).
This skill documents the generic Docker conventions that GPU container workloads rely on. Model and data skills specify what image and what command to run; this skill covers how to run docker in a way that satisfies GPU + NVIDIA container requirements.
Sources: official Docker CLI reference (https://docs.docker.com/reference/cli/docker/) and NVIDIA Container Toolkit docs.
>=580, CUDA Toolkit >=13.0, and NVIDIA Container Toolkit >=1.19.0. If the selected model's references/skill_info.yaml declares runtime_requirements.gpu_host, pass those values to tao-setup-nvidia-gpu-host instead. Model requirements override the defaults for that workflow.docker --version must return ≥ 20.10. Install: https://docs.docker.com/engine/install/.nvcr.io/* pulls. Get from https://ngc.nvidia.com/.If the selected model declares runtime_requirements.gpu_host, append the
corresponding --min-driver-version, --min-cuda-version, and
--min-container-toolkit-version values to both the check and any approved
install command. Do not apply one model's override to unrelated workflows.
Persists in ~/.docker/config.json across reboots. Re-run on unauthorized errors.
docker run — canonical flagsNotes:
--gpus '"device=0,1"' — specific GPUs (double-quote-escaped). Without nvidia-container-toolkit: could not select device driver "" with capabilities: [[gpu]].--rm — clean up the container at exit; omit when you want docker logs after exit.--shm-size=8g — torchrun + PyTorch DataLoaders exhaust the default 64 MB /dev/shm otherwise; size it for multi-GPU training and raise (e.g. 16g) if you still hit Bus error.--user "$(id -u):$(id -g)" — required by default whenever a bind mount is writable. It prevents root-owned checkpoint trees that the submitting host user cannot clean up.0 for the canonical writable-bind path. If the launcher itself is root, obtain the verified non-root submitting UID:GID explicitly; never infer it from the output-directory owner.--group-add <gid> — preserve supplementary host-group access to shared datasets and workspaces. The canonical array adds every host group except the primary GID.HOME, USER, LOGNAME, and cache redirects — keep frameworks from writing to image-owned locations such as /root after the user override. Prepare these directories on the writable mount before launch. USER/LOGNAME are load-bearing, not cosmetic: an arbitrary --user UID has no /etc/passwd entry in the image, and torch 2.x calls getpass.getuser() at import (torch/_dynamo → inductor cache-dir setup) — with neither env var set the container crashes with KeyError: 'getpwuid(): uid not found: <uid>' before any workload code runs. Any non-empty name satisfies it; the name does not need to exist in the image.-v host:container — bind mount; the command references container paths only.-e VAR — passthrough from parent shell (no value needed if already set). Use this form for secrets.docker run --name X fails if a container named X already exists. Defensive pattern before reusing a name:
For multi-step workflows on the same container (download → run → post-process), avoid restart cost:
Tag containers for filtered listing later:
The container expects its data at conventional paths defined by the image (often /data, /results, /workspace/checkpoints). The host side is arbitrary. The command inside docker run references container paths only.
For every writable bind mount, run as the submitting host UID:GID by default.
Pre-creating the mount root is not sufficient when a root container can create
deeper 0755 directories: deletion is controlled by the parent-directory
permissions, so those subtrees still become inaccessible to the host user.
Container --rm and docker rm remove container state only; neither deletes or
repairs bind-mounted checkpoints.
An image may run as root only when its documentation or a preflight proves that
host-user execution is incompatible. Treat this as an explicit launch
exception. Isolate its writable outputs and, after every terminal exit or
cancellation, normalize ownership before another experiment starts. For an
image with /bin/sh and chown, the post-run repair is:
Apply the repair to every writable output/cache mount. If the agent cannot run
or verify the ownership normalization, it must not use the root-required
exception. Never substitute chmod 777 as the normal fix.
Common passthrough vars for TAO-style workloads (the calling skill declares which it needs):
NGC_KEY — nvcr.io pulls; some runtimes also read at runtimeHF_TOKEN — gated HuggingFace model downloadsAWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_ENDPOINT_URL — S3 I/O inside the containerWANDB_API_KEY — optional W&B loggingUse -e VAR (no =value) when the var is in the parent shell. Avoid placing secrets on the command line.
Alternative GPU selection: -e NVIDIA_VISIBLE_DEVICES=0,1 (or all) and -e NVIDIA_DRIVER_CAPABILITIES=all instead of --gpus. The --gpus flag is preferred on standard x86 hosts; the env-var form is older and is what runtime=nvidia (Tegra/Jetson) requires.
docker inspect is the canonical source of truth for a container's mounts, env, cmd, network, and exit code. Use it to debug why a container isn't behaving as expected.
Pull once per host; docker run reuses cached image. NVIDIA images are typically 5-40GB.
Some cloud GPU providers ship with a small root volume + larger ephemeral. Docker writes to /var/lib/docker on root by default — large images fill it. Check:
If / is smaller than your total image footprint and there's a larger disk mounted elsewhere, relocate before pulling images:
For microservice containers that talk to each other by name, create a docker network and attach containers:
Most TAO training workloads don't need this — single container per job.
could not select device driver "" with capabilities: [[gpu]] — NVIDIA Container Toolkit missing or Docker is not configured for the NVIDIA runtime. Run tao-setup-nvidia-gpu-host with --backend docker --install after user approval (append --yes for a non-interactive agent run), then restart Docker.
unauthorized: authentication required on docker pull — NGC key invalid/missing. Re-run docker login nvcr.io.
no space left on device — first identify which filesystem and storage
class is full; bind-mounted training outputs are not counted by docker system df and are not fixed by pruning Docker images:
For a bind mount, clean only confirmed terminal job directories using the SDK
retention path or a reviewed ownership repair; never assume docker system prune touches them. For Docker's own root, relocate data-root as described
above. docker system prune -a --volumes is destructive and may remove unused
images and volumes belonging to other workflows, so run it only after explicit
user approval and a reviewed docker system df inventory.
Bus error / DataLoader worker exited unexpectedly — /dev/shm too small. Increase shared memory with --shm-size (e.g. --shm-size=16g).
permission denied on bind-mounted paths — container UID ≠ host UID, or HOME/a framework cache still points to an image-owned directory. Use the canonical host UID:GID mapping and writable HOME/cache redirects above. For a documented root-required image, complete the mandatory post-run ownership normalization before retrying.
KeyError: 'getpwuid(): uid not found: <uid>' at import of torch/torchvision — the container runs as a --user UID with no /etc/passwd entry and no USER/LOGNAME env var, so getpass.getuser() falls through to pwd.getpwuid() at import time. -e HOME=... alone does not fix it. Keep the UID:GID mapping and launch with the canonical identity env block (-e USER=... -e LOGNAME=... + writable HOME + cache redirects). Do not work around it by running as root; that recreates the root-owned-outputs hazard.
Error: No such container: <name> after docker run -d — container crashed on startup. docker ps -a shows exited; docker logs <name> for cause. Drop --rm while debugging.
This skill covers the how of running docker on a GPU host. Platform-specific layering (how to get onto the host, dispatch via a CLI wrapper) lives in:
tao-skill-bank:tao-run-on-brev — running docker via brev exec on a Brev instancetao-skill-bank:tao-run-platform — optional Python layer wrapping docker invocations with Job handles, state persistence, and S3 I/OModel and data skills specify what image and command; they defer to this skill for the how.