build-slurm-image
Skill484 starsChanged 3 months agoMIT-0View on GitHub
Build the Slurm compute node container image via CodeBuild or local Docker, generate SSH keys, and render Helm values using setup.sh
- Reads credentials
In this repository12 other files it gives its agents.
- AGENTS.mdAGENTS.md
- architectures/sagemaker-hyperpod-eks/slinky-slurm/AGENTS.mdAGENTS.md
- architectures/sagemaker-hyperpod-eks/terraform-modules/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- bash-testingSkill
- deploy-infrastructureSkill
- deployment-preflightSkill
- deploy-slurm-clusterSkill
- validate-deploymentSkill
- hyperpod-devops-agent-solutionSkill
- hyperpod-incident-rcaSkill
- hyperpod-incident-triageSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
Use this skill to build the Slurmd DLC (Deep Learning Container) image, generate SSH keys for login node access, and render the …
- Very specific: line 23
After the image build, setup.sh always:
- Very specific: line 149
If missing, generates a new ed25519 key pair with ssh-keygen
- Very specific: line 200
No unresolved ${...} variables in slurm-values.yaml
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Build Slurm Image & Generate Values
Overview
Use this skill to build the Slurmd DLC (Deep Learning Container) image, generate
SSH keys for login node access, and render the slurm-values.yaml Helm values
file from the template. This is Phase 2 of the slinky-slurm deployment
workflow.
The setup.sh script handles three image build paths:
| Mode | Flag | When to Use |
| CodeBuild (default) | (none) | Production builds in AWS (creates a CodeBuild project to build the image) |
| Local Docker | --local-build | Development/testing on a local machine with Docker |
| Skip Build | --skip-build | Image already exists in ECR from a prior build |
After the image build, setup.sh always:
- Generates an SSH key pair (
~/.ssh/id_ed25519_slurm) if not present - Renders
slurm-values.yamlfromslurm-values.yaml.templatewith profile-specific values (GPU count, EFA count, GRES, replicas, etc.)
Prerequisites
- AWS CLI configured with valid credentials
--instance-typeand--infraflags decided- For CodeBuild (default):
env_vars.shavailable (fromdeploy.sh) for AWS_ACCOUNT_ID, AWS_REGIONzipcommand availablejq(for CFN) orterraform(for TF)
- For Local Docker:
- Docker Desktop running
- Access to DLC ECR registry (
763104351884.dkr.ecr.us-east-1.amazonaws.com)
- For Skip Build:
- Image must already exist in ECR
See the deployment-preflight skill for full prerequisite validation.
Steps
Step 1: Choose build mode and run setup.sh
CodeBuild (default) -- recommended for production:
# Build via CodeBuild for g5 instances using CloudFormation
bash setup.sh --instance-type ml.g5.8xlarge --infra cfn
# Build via CodeBuild for p5 instances using Terraform
bash setup.sh --instance-type ml.p5.48xlarge --instance-count 2 --infra tfLocal Docker -- for development/testing:
# Build locally for g5 instances
bash setup.sh --instance-type ml.g5.8xlarge --infra cfn --local-build
# Build locally for p5 instances
bash setup.sh --instance-type ml.p5.48xlarge --instance-count 2 --infra tf --local-buildSkip Build -- image already in ECR:
# Use existing ECR image
bash setup.sh --instance-type ml.g5.8xlarge --infra cfn --skip-build
# With custom repo name and tag
bash setup.sh --instance-type ml.g5.8xlarge --infra cfn --skip-build \
--repo-name my-slurmd --tag v1.0Step 2: Verify outputs
After setup.sh completes:
# Verify slurm-values.yaml was generated
cat slurm-values.yaml | head -20
# Check for unresolved template variables (should find none)
grep '${' slurm-values.yaml
# Expected: no output (all variables substituted)
# Verify SSH key exists
ls -la ~/.ssh/id_ed25519_slurm*What setup.sh Does Internally
CodeBuild Path (Default)
- Sources
lib/deploy_helpers.shand callsresolve_helm_profile() - Gets AWS account ID via
aws sts get-caller-identity - Sources
env_vars.shif available (for AWS_ACCOUNT_ID, AWS_REGION) - Creates an S3 bucket for build context:
dlc-slurmd-codebuild-<account_id>-<region> - Packages
dlc-slurmd.Dockerfile+buildspec.ymlinto a zip file - Uploads zip to
s3://<bucket>/codebuild/slurmd-build-context.zip - Deploys CodeBuild stack:
- CFN path:
aws cloudformation create-stackwithcodebuild-stack.yaml - TF path:
terraform applywithcodebuild.tf
- CFN path:
- Gets the CodeBuild project name from stack outputs
- Starts the build:
aws codebuild start-build - Polls build status every 15 seconds until SUCCEEDED/FAILED
- On success, the image is in ECR at
<account>.dkr.ecr.<region>.amazonaws.com/dlc-slurmd:<tag>
Local Docker Path (--local-build)
Authenticates to the DLC ECR registry in
us-east-1:aws ecr get-login-password --region us-east-1 | \ docker login --username AWS \ --password-stdin 763104351884.dkr.ecr.us-east-1.amazonaws.com- Builds the image (platform-aware):
- macOS:
docker buildx build --platform linux/amd64 - Linux:
docker build
- macOS:
- Creates ECR repository if it doesn't exist
- Authenticates to the project's ECR registry
- Tags and pushes the image
Skip Build Path (--skip-build)
Verifies the image exists in ECR:
aws ecr describe-images \ --repository-name dlc-slurmd \ --image-ids imageTag=25.11.1-ubuntu24.04- Fails with an error if the image is not found
SSH Key Generation (All Paths)
- Checks for
~/.ssh/id_ed25519_slurm - If missing, generates a new ed25519 key pair with
ssh-keygen - The public key is embedded into
slurm-values.yamlfor login node access
Values File Rendering (All Paths)
Calls resolve_helm_profile() which sets these variables based on
--instance-type:
| Variable | g5 Value | p5 Value |
HELM_ACCEL_INSTANCE_TYPE | ml.g5.8xlarge | ml.p5.48xlarge |
GPU_COUNT | 1 | 8 |
EFA_COUNT | 1 | 32 |
GPU_GRES | gpu:a10g:1 | gpu:h100:8 |
REPLICAS | 4 | 2 |
MGMT_INSTANCE_TYPE | ml.m5.4xlarge | ml.m5.4xlarge |
PVC_NAME | fsx-claim | fsx-claim |
Then uses sed to substitute 10 template variables in
slurm-values.yaml.template:
${image_repository},${image_tag},${ssh_key}${mgmt_instance_type},${accel_instance_type}${gpu_count},${efa_count},${gpu_gres}${replicas},${pvc_name}
Command Reference
Usage: setup.sh --instance-type <ml.X.Y> --infra <cfn|tf> [OPTIONS]
Required:
--instance-type <type> SageMaker instance type for GPU/EFA/GRES resolution
--infra <cfn|tf> Infrastructure method for CodeBuild stack
Optional:
--instance-count <N> Number of compute node replicas (default: varies by instance type)
--repo-name <name> ECR repository name (default: dlc-slurmd)
--tag <tag> Image tag (default: 25.11.1-ubuntu24.04)
--region <region> AWS region (default: AWS CLI configured or us-west-2)
--local-build Build image locally instead of CodeBuild
--skip-build Skip image build (use existing image in ECR)
--help Show helpVerification
Build is successful when:
setup.shexits with code 0slurm-values.yamlexists in the project directory- No unresolved
${...}variables inslurm-values.yaml - SSH key pair exists at
~/.ssh/id_ed25519_slurm - ECR image exists (verify with
aws ecr describe-images)
# Quick verification
ls -la slurm-values.yaml
grep -c '${' slurm-values.yaml # Should return 0 / exit 1
ls ~/.ssh/id_ed25519_slurm
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
aws ecr describe-images \
--repository-name dlc-slurmd \
--image-ids imageTag=25.11.1-ubuntu24.04 \
--region "${AWS_REGION:-us-west-2}"Troubleshooting
| Symptom | Cause | Fix |
| CodeBuild FAILED status | Dockerfile build error or DLC base image pull failure | Check CodeBuild logs: aws codebuild batch-get-builds --ids <build-id> |
| Docker login fails for DLC ECR | Region mismatch | DLC registry is always in us-east-1, not the deployment region |
docker buildx fails on macOS | Docker Desktop not running or buildx not enabled | Start Docker Desktop; ensure buildx is available: docker buildx version |
ECR image not found (--skip-build) | Wrong repo name, tag, or region | Verify with aws ecr describe-images --repository-name <name> |
| Template variables not substituted | resolve_helm_profile failed | Check that --instance-type is a valid instance type |
| S3 bucket creation fails | Bucket name already taken | The bucket name includes account ID and region; check IAM permissions |
| CodeBuild stack already exists | Prior run created it | Script handles this gracefully (skips creation) |
References
setup.sh-- Main image build and values generation scriptlib/deploy_helpers.sh--resolve_helm_profile()function (lines 43-70)dlc-slurmd.Dockerfile-- Multi-stage Dockerfile for Slurm compute nodeslurm-values.yaml.template-- Helm values template with 10 variablesbuildspec.yml-- CodeBuild build specificationcodebuild-stack.yaml-- CloudFormation template for CodeBuild projectcodebuild.tf-- Terraform config for CodeBuild project
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

