apptainer-overlay-build

apptainer-overlay-build is a cursor rule for Cursor from AMDResearch/ai4science-studio. It costs 0 tokens per session (383 once invoked), scanned A, original, MIT.

A rule for building Apptainer overlay images, which add writable software layers to otherwise fixed container images, while reusing the PyTorch installation already inside the container.

In plain words
What is it for?
Use it when installing extra Python packages into an Apptainer overlay for an existing ROCm/PyTorch image.
Why use it?
It prevents pip from downloading a second copy of the large ROCm-enabled PyTorch package when that package is already available.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when installing extra Python packages into an Apptainer overlay for an existing ROCm/PyTorch image.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/amdresearch/ai4science-studio/apptainer-overlay-build
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/AMDResearch/ai4science-studio

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for apptainer-overlay-build

README.md
[![agentmods](https://agentmods.dev/badge/rules/amdresearch/ai4science-studio/apptainer-overlay-build.svg)](https://agentmods.dev/rules/amdresearch/ai4science-studio/apptainer-overlay-build)
Your own site
<a href="https://agentmods.dev/rules/amdresearch/ai4science-studio/apptainer-overlay-build"><img src="https://agentmods.dev/badge/rules/amdresearch/ai4science-studio/apptainer-overlay-build.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 383 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00383
Opus 5 $0.00000 $0.00192
Sonnet 5 $0.00000 $0.00077
Haiku 4.5 $0.00000 $0.00038

Measured 7d ago against content hash 4cbee3fc0278, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

apptainer-overlay-build scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/apptainer-overlay-build.mdc · 41 lines

What it actually says

Apptainer overlay: use the SIF venv instead of --target

When building overlay images for Apptainer/Singularity containers that already ship a PyTorch venv (e.g. /opt/venv in rocm/pytorch images), prefer installing into the activated venv rather than using pip install --target.

Problem

pip install --target <dir> creates a fully isolated install that does not see packages in the container's venv. When a dependency like pytorch-lightning declares torch as a requirement, pip resolves and downloads the full ROCm torch wheel (~6 GB), even though the identical version is already present in the SIF.

Preferred approach

  1. Mount the overlay read-write and activate the SIF's venv.
  2. Use plain pip install (no --target). pip sees the existing torch and skips it; new packages are written into the overlay's upper layer.
  3. No post-install strip step is needed because torch was never downloaded.
apptainer exec --rocm --overlay "$OVERLAY:rw" "$SIF" bash -c '
  source /opt/venv/bin/activate
  pip install --no-cache-dir mpi4py huggingface-hub pytorch-lightning ...
'

When --target is still acceptable

  • If the overlay must keep packages strictly isolated from the venv (e.g. multiple overlays with conflicting dep versions).
  • In that case, keep the existing NFS-staging + strip-torch pattern, but document the ~6 GB download overhead in a comment.
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago First seen · 41 lines · 0 tokens per session scan A 4cbee3fc0278

Subscribe to this mod's changes

apptainer-overlay-build is a cursor rule published in the GitHub repository AMDResearch/ai4science-studio (4 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 383 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.