选项
首页首页 Skill 开发运营和 CI/CD holoscan-install-container

holoscan-install-container

NVIDIA/skills NVIDIA/skills

从 NGC 拉取并验证官方 Holoscan SDK 容器,为宿主 GPU 选择正确的 CUDA/架构标签,并通过随附的 Python 和 C++ 示例进行验证。

...展开全部
2
更新时间 2026-09-27

Holoscan NGC 容器安装

目的

从 NGC(nvcr.io/nvidia/clara-holoscan/holoscan)拉取并验证官方 Holoscan SDK 容器,根据主机 GPU 选择正确的 CUDA/架构标签,并通过随附的 Python 和 C++ 示例进行验证。

先决条件

  • 配备 NVIDIA GPU 且驱动程序(nvidia-smi)可正常运行的 Linux 主机。
  • 已安装 Docker,且用户属于docker组(或具有sudo 权限)。
  • 已安装 NVIDIA Container Toolkit(可执行 `docker run --gpus all` 命令)。
  • 约 10–20 GB 可用磁盘空间用于拉取镜像。
  • 可访问nvcr.io和docs.nvidia.com。

限制

  • 容器镜像仅涵盖下表中的标签矩阵——内部不包含 Conda/pip 环境。
  • GUI 示例需要 X11 转发;本技能通过无头模式运行 Holoviz 以避免此需求。
  • 标签后缀必须与主机 GPU/驱动程序匹配(cuda13 / cuda12-dgpu / cuda12-igpu)——后缀错误 → CUDA 初始化失败。

使用说明

  • 容器仓库:nvcr.io/nvidia/clara-holoscan/holoscan。
  • https://docs.nvidia.com/holoscan/sdk-user-guide/sdk_installation.html 上的文档页面为权威版本——若下文内容与之不符,请以该页面为准。
  • 请按顺序执行以下步骤:选择标签、验证 GPU 直通并拉取代码、通过六个示例进行验证,然后提交启动命令。

步骤 1:选择标签

标签 =- ,例如v4.1.0-cuda13。从上述文档页面获取当前 SDK 版本;从nvidia-smi中选择后缀(表格标题右上角的“CUDA 版本”字段):

nvidia-smiCUDA 版本 后缀
13.x+ cuda13
12.x,Ampere/Ada 独立显卡 cuda12-dgpu
12.x,ARM64 集成显卡 (nvgpu) cuda12-igpu

当容器携带的 CUDA 次版本号高于主机驱动程序所支持的版本时,会出现“CUDA 前向兼容模式已启用”的提示——这并非错误。前向兼容适配层可让容器的 CUDA 运行时在同一主版本范围内与较旧的主机驱动程序协同工作。

步骤 2:验证 GPU 直通,然后拉取

docker run --rm --gpus all ubuntu:22.04 nvidia-smi 2>&1 | tail -5

如果未安装 Docker → 请从 https://docs.docker.com/engine/install/ 安装。 如果 GPU 直通失败 → 请按照 https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html 安装 NVIDIA Container Toolkit,然后重试。

拉取镜像(约 10–20 GB — 开始前请提醒用户):

docker pull nvcr.io/nvidia/clara-holoscan/holoscan:

步骤 3:使用六个示例进行验证

测试涵盖:纯 Python 绑定(1a)、纯 C++ 运行时(1b、2a)、Python + Holoviz/Vulkan(2b、3a)以及 C++ + Holoviz/Vulkan(3b)。 Holoviz 示例始终以无头模式运行(在 YAML 中注入headless: true)——无论是否连接显示器,此方式均可正常工作,并可避免通过 SSH 连接时出现的 GUI 故障。

IMG=nvcr.io/nvidia/clara-holoscan/holoscan:
RUN=(docker run --rm --runtime=nvidia --gpus all --cap-add CAP_SYS_PTRACE --ipc=host --ulimit memlock=-1 --ulimit stack=67108864)

# 1a. hello_world(Python)—— 预期输出“Hello World!”
"${RUN[@]}" "$IMG" bash -c \
  "ulimit -s 32768 && python3 /opt/nvidia/holoscan/examples/hello_world/python/hello_world.py"

# 1b. hello_world (C++) — 预期输出“Hello World!”
"${RUN[@]}" "$IMG" bash -c \
  "ulimit -s 32768 && /opt/nvidia/holoscan/examples/hello_world/cpp/hello_world"

# 2a. tensor_interop (C++) — 预期张量在每次迭代中翻倍,输出“Graph execution finished.”
"${RUN[@]}" "$IMG" bash -c \
  "ulimit -s 32768 && /opt/nvidia/holoscan/examples/tensor_interop/cpp/tensor_interop"

# 2b. tensor_interop (Python,10 帧) — Holoviz,无头模式。YAML 文件默认没有
#     headless 字段,因此需在 `holoviz:` 下添加一个。预期结果为
#     “message received (count: 10)”。
"${RUN[@]}" "$IMG" bash -c "
  ulimit -s 32768
  sed -e 's/count: 0/count: 10/' \
      -e 's/repeat: true/repeat: false/' \
      -e 's/realtime: true/realtime: false/' \
      -e 's/^holoviz:/holoviz:\n  headless: true/' \
      /opt/nvidia/holoscan/examples/tensor_interop/python/tensor_interop.yaml > /tmp/ti.yaml
  cd /opt/nvidia/holoscan/examples/tensor_interop/python
  python3 tensor_interop.py --config /tmp/ti.yaml
"

# 3a. video_replayer(Python,10 帧)— Holoviz,无界面模式。在 `holoviz:` 下方(`width: 854` 之上)插入 `headless: true`
#    。 相同的 sed 命令也适用于 3b 中的 C++ YAML ——
#     这两个文件的 `holoviz:` 部分结构相同。
"${RUN[@]}" "$IMG" bash -c "
  ulimit -s 32768
  sed -e 's/count: 0/count: 10/' \
      -e 's/repeat: true/repeat: false/' \
      -e 's/realtime: true/realtime: false/' \
      -e 's/^  width: 854/  headless: true\n  width: 854/' \
      /opt/nvidia/holoscan/examples/video_replayer/python/video_replayer.yaml > /tmp/vr.yaml
  cd /opt/nvidia/holoscan/examples/video_replayer/python
  HOLOSCAN_INPUT_PATH=/opt/nvidia/holoscan/data python3 video_replayer.py --config /tmp/vr.yaml
"

# 3b. video_replayer(C++,10 帧)— 与 3a 相同的无头注入。C++
#     YAML 文件中硬编码了 `directory: "../data/racerx"`,但 HOLOSCAN_INPUT_PATH
#     会覆盖该设置,因此无需修补该字段。
"${RUN[@]}" "$IMG" bash -c "
  ulimit -s 32768
  sed -e 's/count: 0/count: 10/' \
      -e 's/repeat: true/repeat: false/' \
      -e 's/realtime: true/realtime: false/' \
      -e 's/^  width: 854/  headless: true\n  width: 854/' \
      /opt/nvidia/holoscan/examples/video_replayer/cpp/video_replayer.yaml > /tmp/vr_cpp.yaml
  cd /opt/nvidia/holoscan/examples/video_replayer/cpp
  HOLOSCAN_INPUT_PATH=/opt/nvidia/holoscan/data ./video_replayer --config /tmp/vr_cpp.yaml
"

步骤 4:运行命令

  • 请阅读《https://catalog.ngc.nvidia.com/orgs/nvidia/teams/clara-holoscan/containers/holoscan》。
  • 向用户解释下方的 Docker 参数。
  • 请引导用户参考该链接了解其他参数(例如,如何挂载 V4L2 视频设备)。
docker run -it --rm \
  --runtime=nvidia --gpus all --cap-add CAP_SYS_PTRACE \
  --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 \
  nvcr.io/nvidia/clara-holoscan/holoscan:
# 示例:/opt/nvidia/holoscan/examples/
# 挂载文件:-v /host/path:/container/path
# 图形界面示例:添加 -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY

下一步:

  • 探索:ls /opt/nvidia/holoscan/examples/
  • 逐步操作示例:/holoscan-explain-example

故障排除

  • docker:收到守护进程的错误响应:无法选择设备驱动程序“nvidia”。缺少 NVIDIA Container Toolkit 或未正确配置。请按照步骤 2 中的链接进行安装,然后重启 Docker。
  • 容器内部的 CUDA 初始化失败。标签后缀与主机不匹配。请重新检查nvidia-smi 中的CUDA 版本以及步骤 1 中的表格。
  • 启动示例时发生段错误。容器内部未应用ulimit -s 32768设置。请使用步骤 3 中展示的bash -c "ulimit -s 32768 && ..."模式。
  • 通过 SSH 运行 Holoviz 示例时卡死/无窗口。YAML 文件未修改为headless: true。请使用步骤 3 中展示的sed命令进行修改。
  • video_replayer无法找到数据。请设置HOLOSCAN_INPUT_PATH=/opt/nvidia/holoscan/data— 该设置将覆盖 YAML 文件中硬编码的路径。
在 GitHub 上查看
---
name: holoscan-install-container
description: Pull and verify the official Holoscan SDK container from NGC, selecting the correct CUDA/arch tag for the host GPU and validating with bundled Python and C++ examples.
license: Apache-2.0
---

# Holoscan NGC Container Installation

## Purpose

Pull and verify the official Holoscan SDK container from NGC (`nvcr.io/nvidia/clara-holoscan/holoscan`), selecting the right CUDA/arch tag for the host GPU and validating with the bundled Python and C++ examples.

## Prerequisites

- Linux host with an NVIDIA GPU and a working driver (`nvidia-smi`).
- Docker installed and the user in the `docker` group (or `sudo`).
- NVIDIA Container Toolkit installed (`docker run --gpus all` works).
- ~10–20 GB free disk for the image pull.
- Network access to `nvcr.io` and `docs.nvidia.com`.

## Limitations

- Container images cover only the tag matrix below — no Conda/pip env inside.
- GUI examples require X11 forwarding; this skill runs Holoviz headless to avoid that.
- Tag suffix must match the host GPU/driver (cuda13 / cuda12-dgpu / cuda12-igpu) — wrong suffix → CUDA init failures.

## Instructions

- Container repo: `nvcr.io/nvidia/clara-holoscan/holoscan`.
- The doc page at https://docs.nvidia.com/holoscan/sdk-user-guide/sdk_installation.html is canonical — fetch it if anything below disagrees.
- Work through the steps below in order: pick the tag, verify GPU passthrough and pull, verify with the six examples, then hand off the launch command.

## Step 1: Pick the tag

Tag = `<version>-<suffix>`, e.g. `v4.1.0-cuda13`. Get the current SDK version from the doc page above; pick the suffix from `nvidia-smi` (the "CUDA Version" field, top-right of the table header):

| `nvidia-smi` CUDA Version | Suffix |
|---|---|
| 13.x+ | `cuda13` |
| 12.x, Ampere/Ada dGPU | `cuda12-dgpu` |
| 12.x, ARM64 iGPU (nvgpu) | `cuda12-igpu` |

The "CUDA Forward Compatibility mode ENABLED" banner is expected — not an error — when the container ships a newer CUDA minor version than the host driver supports. The forward-compat shim lets the container's CUDA runtime work against the older host driver within the same major version.

## Step 2: Verify GPU passthrough, then pull

```bash
docker run --rm --gpus all ubuntu:22.04 nvidia-smi 2>&1 | tail -5
```

If Docker is missing → install from https://docs.docker.com/engine/install/. If GPU passthrough fails → install the NVIDIA Container Toolkit per https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html, then retry.

Pull (~10–20 GB — warn the user before starting):

```bash
docker pull nvcr.io/nvidia/clara-holoscan/holoscan:<TAG>
```

## Step 3: Verify with six examples

Tests cover: bare Python binding (1a), bare C++ runtime (1b, 2a), Python + Holoviz/Vulkan (2b, 3a), and C++ + Holoviz/Vulkan (3b). Holoviz examples always run headless (inject `headless: true` into the YAML) — this works whether or not a display is attached and avoids GUI failure modes over SSH.

```bash
IMG=nvcr.io/nvidia/clara-holoscan/holoscan:<TAG>
RUN=(docker run --rm --runtime=nvidia --gpus all --cap-add CAP_SYS_PTRACE --ipc=host --ulimit memlock=-1 --ulimit stack=67108864)

# 1a. hello_world (Python) — expect "Hello World!"
"${RUN[@]}" "$IMG" bash -c \
  "ulimit -s 32768 && python3 /opt/nvidia/holoscan/examples/hello_world/python/hello_world.py"

# 1b. hello_world (C++) — expect "Hello World!"
"${RUN[@]}" "$IMG" bash -c \
  "ulimit -s 32768 && /opt/nvidia/holoscan/examples/hello_world/cpp/hello_world"

# 2a. tensor_interop (C++) — expect tensors doubling each pass, "Graph execution finished."
"${RUN[@]}" "$IMG" bash -c \
  "ulimit -s 32768 && /opt/nvidia/holoscan/examples/tensor_interop/cpp/tensor_interop"

# 2b. tensor_interop (Python, 10 frames) — Holoviz, headless. The YAML has no
#     headless field by default, so inject one under `holoviz:`. Expect
#     "message received (count: 10)".
"${RUN[@]}" "$IMG" bash -c "
  ulimit -s 32768
  sed -e 's/count: 0/count: 10/' \
      -e 's/repeat: true/repeat: false/' \
      -e 's/realtime: true/realtime: false/' \
      -e 's/^holoviz:/holoviz:\n  headless: true/' \
      /opt/nvidia/holoscan/examples/tensor_interop/python/tensor_interop.yaml > /tmp/ti.yaml
  cd /opt/nvidia/holoscan/examples/tensor_interop/python
  python3 tensor_interop.py --config /tmp/ti.yaml
"

# 3a. video_replayer (Python, 10 frames) — Holoviz, headless. Inject `headless: true`
#     under `holoviz:` (above `width: 854`). Same sed works for the C++ YAML in 3b —
#     both files share the same `holoviz:` section shape.
"${RUN[@]}" "$IMG" bash -c "
  ulimit -s 32768
  sed -e 's/count: 0/count: 10/' \
      -e 's/repeat: true/repeat: false/' \
      -e 's/realtime: true/realtime: false/' \
      -e 's/^  width: 854/  headless: true\n  width: 854/' \
      /opt/nvidia/holoscan/examples/video_replayer/python/video_replayer.yaml > /tmp/vr.yaml
  cd /opt/nvidia/holoscan/examples/video_replayer/python
  HOLOSCAN_INPUT_PATH=/opt/nvidia/holoscan/data python3 video_replayer.py --config /tmp/vr.yaml
"

# 3b. video_replayer (C++, 10 frames) — same headless injection as 3a. The C++
#     YAML hard-codes `directory: "../data/racerx"`, but HOLOSCAN_INPUT_PATH
#     overrides it, so we don't need to patch that field.
"${RUN[@]}" "$IMG" bash -c "
  ulimit -s 32768
  sed -e 's/count: 0/count: 10/' \
      -e 's/repeat: true/repeat: false/' \
      -e 's/realtime: true/realtime: false/' \
      -e 's/^  width: 854/  headless: true\n  width: 854/' \
      /opt/nvidia/holoscan/examples/video_replayer/cpp/video_replayer.yaml > /tmp/vr_cpp.yaml
  cd /opt/nvidia/holoscan/examples/video_replayer/cpp
  HOLOSCAN_INPUT_PATH=/opt/nvidia/holoscan/data ./video_replayer --config /tmp/vr_cpp.yaml
"
```

## Step 4: Launch command

- Read https://catalog.ngc.nvidia.com/orgs/nvidia/teams/clara-holoscan/containers/holoscan.
- Explain the docker flags below to the user.
- Refer the user to that link for additional flags (e.g., how to mount V4L2 video devices).

```bash
docker run -it --rm \
  --runtime=nvidia --gpus all --cap-add CAP_SYS_PTRACE \
  --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 \
  nvcr.io/nvidia/clara-holoscan/holoscan:<TAG>
# Examples: /opt/nvidia/holoscan/examples/
# Mount files: -v /host/path:/container/path
# GUI examples: add -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY
```

Next:
- Explore: `ls /opt/nvidia/holoscan/examples/`
- Walk through one: `/holoscan-explain-example`

## Troubleshooting

- **`docker: Error response from daemon: could not select device driver "nvidia"`.** NVIDIA Container Toolkit is missing or not configured. Install per the link in Step 2 and restart Docker.
- **CUDA init failure inside the container.** Tag suffix doesn't match the host. Re-check `nvidia-smi` CUDA Version and the table in Step 1.
- **Segmentation fault when launching an example.** `ulimit -s 32768` wasn't applied inside the container. Use the `bash -c "ulimit -s 32768 && ..."` pattern shown in Step 3.
- **Holoviz example hangs / no window over SSH.** YAML wasn't patched to `headless: true`. Use the `sed` injection shown in Step 3.
- **`video_replayer` can't find data.** Set `HOLOSCAN_INPUT_PATH=/opt/nvidia/holoscan/data` — overrides the YAML's hard-coded path.

安装 holoscan-install-container

下载技能文件并将其解压到 .claude/skills/ 目录下。

下载ZIP

克隆仓库并复制技能文件到您的项目中。

git clone https://github.com/NVIDIA/skills/tree/main/skills/holoscan-install-container # Copy SKILL.md to your .claude/skills/ directory

复制 复制
快速设置: 将技能文件夹复制到 .claude/skills/ Claude 会自动检测并使用该技能
仓库 NVIDIA/skills

相关技能

klingai-upgrade-migration
更新时间 2026-07-03
Verification &amp; Quality Assurance
更新时间 2026-06-29
base44-cli
更新时间 2026-06-29
Railway CLI Management
更新时间 2026-07-02
OR