holoscan-install-source
NVIDIA/skills
使用 Holoscan SDK 內建的基於 Docker 的建置腳本,從原始碼建置 Holoscan SDK,並產生適用於基於 CMake 的應用程式的本地安裝目錄。
...展開全部Holoscan SDK — 從原始碼編譯
目的
從 nvidia-holoscan/holoscan-sdk 原始碼樹,並使用其 ./run 腳本(該腳本在 Docker 容器內執行)從原始碼樹建置 Holoscan SDK,產出可作為 CMake 依賴項使用的本機安裝樹。
先決條件
- 配備 NVIDIA GPU 及驅動程式的 Linux 主機(
nvidia-smi). git,並安裝了 NVIDIA Container Toolkit 的 Docker(docker run --gpus all亦適用),以及docker-buildx-plugin.- 約 20 GB 可用磁碟空間,供建置容器及建置/安裝目錄使用。
- 首次乾淨編譯需時 10–30 分鐘。
限制
- 僅在已發佈的套件(Conda/容器/apt/wheel)無法滿足需求時才建議使用——例如需要除錯符號、自訂 CMake 選項,或未受支援的設定。
- 仍需使用 Docker —— 該
./run腳本是在容器內進行建置;這並非真正的裸機建置。 - 若要跨平台編譯至 aarch64,則需
qemu-user-static。
步驟 0:參閱官方安裝說明
請務必參閱 https://docs.nvidia.com/holoscan/sdk-user-guide/sdk_installation.html (以及所連結的 GitHub README.md / DEVELOP.md )的「從原始碼編譯」部分。重點摘要:必需的 ./run 標誌(針對目標架構與 CUDA 主要版本)、受支援的分支/標籤、該版本中特別提及的 Dockerfile 修補程式,以及驗證時建議使用的測試名稱。若文件內容與以下說明有任何衝突,以文件為準。
步驟 1:先決條件
請確認已安裝 git 和 Docker(需支援 GPU 直通功能):
git --version
docker --version
docker run --rm --gpus all ubuntu:22.04 nvidia-smi
- 若缺少 Docker → 請參閱 https://docs.docker.com/engine/install/ 進行安裝
- 若 GPU 直通功能失敗 → 安裝 NVIDIA Container Toolkit:
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list \ | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' \ | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit sudo nvidia-ctk runtime configure --runtime=docker && sudo systemctl restart docker - 若缺少 Docker buildx:
sudo apt-get install docker-buildx-plugin
步驟 2:克隆儲存庫
如有需要,請將儲存庫克隆至 ~/holoscan/holoscan-sdk
mkdir -p ~/holoscan/
git clone https://github.com/nvidia-holoscan/holoscan-sdk.git
cd ~/holoscan/holoscan-sdk
若要建置特定的發行標籤(為確保穩定性,建議採用此方式):
git tag | grep -E '^v[0-9]' | sort -V | tail -5 # list recent tags
git checkout v # e.g. v4.1.0
步驟 3:建置
該 ./run build 腳本會一步完成容器建立、CMake 配置、編譯及安裝。請提醒使用者,首次執行需耗時 10 至 30 分鐘(包含下載基礎映像檔與編譯)。
./run build
常用選項:
| 參數 | 用途 |
|---|---|
--type debug |
除錯版本(含符號,無優化) |
--type RelWithDebInfo |
發行版 + 除錯符號 |
--arch aarch64 |
針對 ARM64 的交叉編譯(需 sudo apt install qemu-user-static) |
--gpu igpu |
Jetson/IGX 的 iGPU 版本 |
--dryrun |
預覽指令而不執行 |
若變更選項後發生 CMake 快取錯誤:
./run clear_cache && ./run build
輸出檔案會存放於這些資料夾中,可透過 ./run get_build_dir 以及 ./run get_install_dir
- 建置目錄:
build-cu- / - 安裝目錄:
install-cu.- /
步驟 4:執行測試
執行以下測試
- EXAMPLE_CPP_HELLO_WORLD_TEST
- EXAMPLE_PYTHON_HELLO_WORLD_TEST
- EXAMPLE_CPP_TENSOR_INTEROP_TEST
- EXAMPLE_PYTHON_TENSOR_INTEROP_TEST
- EXAMPLE_CPP_VIDEO_REPLAYER_TEST
- EXAMPLE_PYTHON_VIDEO_REPLAYER_TEST
./run test
若要一次執行所有六項必測項目,請使用單引號包圍的正規表達式( | 必須加上引號,以防止 bash 將其視為管線):
./run test --options "-R 'EXAMPLE_CPP_HELLO_WORLD_TEST|EXAMPLE_PYTHON_HELLO_WORLD_TEST|EXAMPLE_CPP_TENSOR_INTEROP_TEST|EXAMPLE_PYTHON_TENSOR_INTEROP_TEST|EXAMPLE_CPP_VIDEO_REPLAYER_TEST|EXAMPLE_PYTHON_VIDEO_REPLAYER_TEST' --output-on-failure"
根據名稱或正則表達式執行特定測試:
./run test --name
./run test --options "-R '' --output-on-failure"
./run test --verbose
重要:當正規表達式字串包含 | — 時,請務必使用單引號將正規表達式字串括起來;若未加引號,bash 會將 | 為管線,導致指令因 command not found.
預期結果:所有測試皆通過。在繼續之前,請記錄任何失敗情況並向使用者回報。
步驟 5:將應用程式指向安裝目錄樹
建置完成後,應用程式可將安裝目錄作為 CMake 依賴項。請提供使用者此路徑:
/path/to/holoscan-sdk/install-cu-/
使用者可設定 Holoscan_ROOT 或 CMAKE_PREFIX_PATH 此目錄。
疑難排解
| 症狀 | 解決方法 |
|---|---|
bash: 執行測試時 |
正規表達式包含 | — 請用單引號包起來: --options "-R ' |
| 變更選項後出現 CMake 快取錯誤 | ./run clear_cache && ./run build |
| 找不到 Docker buildx | sudo apt-get install docker-buildx-plugin |
| 建置容器內無法偵測到 GPU | 請確認 NVIDIA Container Toolkit 並重新執行 sudo nvidia-ctk runtime configure --runtime=docker |
| 交叉編譯失敗(aarch64) | 安裝 qemu: sudo apt-get install qemu-user-static |
---
name: holoscan-install-source
description: Build the Holoscan SDK from source using its in-tree Docker-based build script, producing a local install tree for CMake-based applications.
license: Apache-2.0
---
# Holoscan SDK — Build from Source
## Purpose
Build the Holoscan SDK from the `nvidia-holoscan/holoscan-sdk` source tree using its `./run` script (which builds inside a Docker container), producing a local install tree consumable as a CMake dependency.
## Prerequisites
- Linux host with NVIDIA GPU + driver (`nvidia-smi`).
- `git`, Docker with NVIDIA Container Toolkit (`docker run --gpus all` works), and `docker-buildx-plugin`.
- ~20 GB free disk for the build container + build/install trees.
- 10–30 min for a clean first build.
## Limitations
- Only recommended when published packages (Conda / container / apt / wheel) don't fit — debug symbols, custom CMake options, or unsupported configs.
- Still requires Docker — the `./run` script builds inside a container; this is not a true bare-metal build.
- Cross-compiling to aarch64 needs `qemu-user-static` on the host.
## Step 0: Consult the Official Install Instructions
Always fetch the "Build from Source" section of `https://docs.nvidia.com/holoscan/sdk-user-guide/sdk_installation.html` (and the linked GitHub `README.md` / `DEVELOP.md` for the chosen tag) before building. Extract: required `./run` flags for the target architecture and CUDA major, supported branches/tags, any Dockerfile patches called out for the release, and the test names recommended for verification. If the doc disagrees with anything below, the doc wins.
## Step 1: Prerequisites
Check that git and Docker (with GPU passthrough) are available:
```bash
git --version
docker --version
docker run --rm --gpus all ubuntu:22.04 nvidia-smi
```
- If Docker is missing → help install from https://docs.docker.com/engine/install/
- If GPU passthrough fails → install NVIDIA Container Toolkit:
```bash
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list \
| sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' \
| sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker && sudo systemctl restart docker
```
- If Docker buildx is missing: `sudo apt-get install docker-buildx-plugin`
## Step 2: Clone the Repository
Clone repo to ~/holoscan/holoscan-sdk if needed
```bash
mkdir -p ~/holoscan/
git clone https://github.com/nvidia-holoscan/holoscan-sdk.git
cd ~/holoscan/holoscan-sdk
```
To build a specific release tag (recommended for stability):
```bash
git tag | grep -E '^v[0-9]' | sort -V | tail -5 # list recent tags
git checkout v<VERSION> # e.g. v4.1.0
```
## Step 3: Build
The `./run build` script handles container creation, CMake configuration, compilation, and install in one step. Warn the user this takes **10–30 minutes** on first run (downloads base image + compiles).
```bash
./run build
```
Common options:
| Flag | Purpose |
|------|---------|
| `--type debug` | Debug build (symbols, no optimization) |
| `--type RelWithDebInfo` | Release + debug symbols |
| `--arch aarch64` | Cross-compile for ARM64 (needs `sudo apt install qemu-user-static`) |
| `--gpu igpu` | iGPU build for Jetson/IGX |
| `--dryrun` | Preview commands without executing |
If CMake cache errors occur after changing options:
```bash
./run clear_cache && ./run build
```
Output lands in these folders, and can be retrieved with `./run get_build_dir` and `./run get_install_dir`
* Build dir: `build-cu<N>-<arch>/`
* Install dir: `install-cu<N>-<arch>/`.
## Step 4: Run Tests
Run the following tests
* EXAMPLE_CPP_HELLO_WORLD_TEST
* EXAMPLE_PYTHON_HELLO_WORLD_TEST
* EXAMPLE_CPP_TENSOR_INTEROP_TEST
* EXAMPLE_PYTHON_TENSOR_INTEROP_TEST
* EXAMPLE_CPP_VIDEO_REPLAYER_TEST
* EXAMPLE_PYTHON_VIDEO_REPLAYER_TEST
```bash
./run test
```
To run all six required tests at once, use a single-quoted regex (the `|` must be quoted to prevent bash from treating it as a pipe):
```bash
./run test --options "-R 'EXAMPLE_CPP_HELLO_WORLD_TEST|EXAMPLE_PYTHON_HELLO_WORLD_TEST|EXAMPLE_CPP_TENSOR_INTEROP_TEST|EXAMPLE_PYTHON_TENSOR_INTEROP_TEST|EXAMPLE_CPP_VIDEO_REPLAYER_TEST|EXAMPLE_PYTHON_VIDEO_REPLAYER_TEST' --output-on-failure"
```
Run a specific test by name or regex:
```bash
./run test --name <test_name>
./run test --options "-R '<regex>' --output-on-failure"
./run test --verbose
```
**Important:** Always single-quote the regex string when it contains `|` — without quotes, bash interprets `|` as a pipe and the command fails with `command not found`.
Expected: all tests pass. Note any failures and report them to the user before continuing.
## Step 5: Point Applications at the Install Tree
Once built, applications can use the install tree as a CMake dependency. Give the user this path:
```
/path/to/holoscan-sdk/install-cu<N>-<arch>/
```
They can set `Holoscan_ROOT` or `CMAKE_PREFIX_PATH` to this directory when building their own applications.
## Troubleshooting
| Symptom | Fix |
|---------|-----|
| `bash: <TEST_NAME>: command not found` when running tests | The regex contains `\|` — wrap it in single quotes: `--options "-R '<regex>'"` |
| CMake cache errors after option change | `./run clear_cache && ./run build` |
| Docker buildx not found | `sudo apt-get install docker-buildx-plugin` |
| GPU not visible inside build container | Verify NVIDIA Container Toolkit and re-run `sudo nvidia-ctk runtime configure --runtime=docker` |
| Cross-compile fails (aarch64) | Install qemu: `sudo apt-get install qemu-user-static` |
所有檔案
5 個檔案安裝 holoscan-install-source
請將技能檔案下載並解壓縮至您的 .claude/skills/ 目錄中。
下載 ZIP複製儲存庫並將技能檔案複製到您的專案中。
git clone https://github.com/NVIDIA/skills/tree/main/skills/holoscan-install-source # Copy SKILL.md to your .claude/skills/ directory
複製





首頁
