holoscan-install-container
NVIDIA/skills
從 NGC 拉取並驗證官方 Holoscan SDK 容器,選擇與主機 GPU 相符的 CUDA/架構標籤,並透過隨附的 Python 和 C++ 範例進行驗證。
...展開全部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:來自 daemon 的錯誤回應:無法選取裝置驅動程式「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 檔案中硬編碼的路徑。
---
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.
所有檔案
5 個檔案安裝 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
複製





首頁
