Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Windows native build

on:
push:
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
msvc:
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Fetch official OpenCV and GLEW development packages
shell: pwsh
run: |
New-Item -ItemType Directory -Path build/deps -Force | Out-Null
Invoke-WebRequest https://github.com/opencv/opencv/releases/download/4.10.0/opencv-4.10.0-windows.exe -OutFile build/deps/opencv.exe
7z x build/deps/opencv.exe -obuild/deps -y -bso0 -bsp0
if ($LASTEXITCODE -ne 0) { throw 'OpenCV extraction failed' }
Invoke-WebRequest https://github.com/nigels-com/glew/releases/download/glew-2.2.0/glew-2.2.0-win32.zip -OutFile build/deps/glew.zip
Expand-Archive build/deps/glew.zip build/deps
- name: Build all Windows targets and run model-free regression tests
shell: pwsh
run: |
./scripts/build_windows.ps1 -OpenCVDir build/deps/opencv/build -GLEWRoot build/deps/glew-2.2.0
powershell.exe -NoProfile -ExecutionPolicy Bypass -File tests/test_fetch_model.ps1
if ($LASTEXITCODE -ne 0) { throw 'PowerShell download tests failed' }
# A hosted runner has no guaranteed OpenGL 3.3 desktop. test_wgl_context
# is compiled here; opt in to its execution locally with -TestOpenGL.
235 changes: 183 additions & 52 deletions CMakeLists.txt

Large diffs are not rendered by default.

49 changes: 32 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,24 +292,39 @@ CMake handles dependencies automatically:
> libonnxruntime_providers_cuda.so` or `Could not find an implementation for
> Expand(13)`, see **[DEPENDENCIES.md](knowledge/DEPENDENCIES.md)** for the cause and fix.

#### Windows (headless build)

Windows is supported as a **headless build only** (MSVC + CMake; OpenCV via
vcpkg). CMake automatically fetches the `win-x64` ONNX Runtime and configures the
CLI (`fast_sam_3dbody_run`) and offline BVH extractor (`offline_sam_3dbody_render`).

The live OpenGL overlay viewer (`fast_sam_3dbody_render`) is **not built on
Windows** — it depends on GLX/X11, which has no in-tree Windows equivalent. CMake
prints a notice to this effect at configure time. For visualization on Windows,
use the offline BVH output or the Python frontends. Linux remains the platform
for live rendering.

Outputs in `build/`:
#### Windows (native build and WGL viewer)

Native Windows supports the CLI, offline BVH extractor, Python/C shared DLL,
and an OpenGL 3.3 viewer using Win32/WGL. Use **Visual Studio 2022 x64**, **CMake
3.21+**, the official **OpenCV 4.10.0** Windows package (`vc16` x64 libraries),
and **GLEW 2.2.0** for the viewer. From the repository root in PowerShell:

```powershell
.\scripts\build_windows.ps1 `
-OpenCVDir D:\deps\opencv\build `
-GLEWRoot D:\deps\glew-2.2.0 -Gpu
.\tools\fetch_model.ps1 -Profile cuda -Yes
```

| File | Description |
|------|-------------|
| `fast_sam_3dbody_run` | Standalone CLI executable |
| `libfast_sam_3dbody.so` | Shared library for C++ linking or ctypes |
`-Gpu` uses GPU ONNX Runtime 1.20.1 without requiring nvcc; without a CUDA
compiler, native ggml/LBS remains on the CPU. Running the CUDA provider still
requires CUDA 12.x/cuDNN 9.x runtime DLLs on `PATH`. Use `-Headless` to omit the
viewer, `-TestOpenGL` to opt into its desktop graphics test, or
`-OnnxRuntimeDir` to supply an existing ORT package.

| Default Release output | Description |
|---|---|
| `build/windows/Release/fast_sam_3dbody_run.exe` | Inference CLI |
| `build/windows/Release/fast_sam_3dbody_render.exe` | WGL viewer, unless built with `-Headless` |
| `build/windows/Release/offline_sam_3dbody_render.exe` | Offline BVH extractor |
| `build/windows/Release/fast_sam_3dbody.dll` | C++/C/Python library with ABI-checked ctypes bindings |

Keep running from the **repository root**: shaders, mesh assets and BVH
templates retain repository-relative paths. The output folder alone is not a
standalone distribution. See **[WINDOWS.md](knowledge/WINDOWS.md)** for CPU and
FP16 model profiles, CUDA-provider commands that do not require TensorRT,
Python `--lib-dir build/windows`, DLL setup and platform limitations.
The WGL implementation credits [beemsoft's PR #13](https://github.com/AmmarkoV/SAM3DBody-cpp/pull/13).

---

Expand Down
7 changes: 7 additions & 0 deletions cmake/StageRuntime.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# A static dependency configuration can legitimately produce an empty list.
foreach(_dll IN LISTS SAM3D_RUNTIME_DLLS)
if(NOT _dll STREQUAL "")
get_filename_component(_name "${_dll}" NAME)
file(COPY_FILE "${_dll}" "${SAM3D_DESTINATION}/${_name}" ONLY_IF_DIFFERENT)
endif()
endforeach()
8 changes: 4 additions & 4 deletions knowledge/DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ at runtime**, you are almost certainly in the right place.

| Component | Version | Notes |
|-----------|---------|-------|
| ONNX Runtime | **1.20.1 (GPU build)** | Downloaded automatically by CMake into `build/onnxruntime_dl/` if not found. |
| ONNX Runtime | **1.20.1 (GPU build)** | Downloaded automatically by CMake into `build/onnxruntime_dl/<full-package-name>/` if not found; for Linux GPU this is `onnxruntime-linux-x64-gpu-1.20.1`. CPU/GPU packages use separate directories. |
| CUDA | **12.x** | Required by the ORT 1.20.1 CUDA execution provider. |
| cuDNN | **9.x** | Required by ORT ≥ 1.19. **cuDNN 8 will not work** and is the #1 cause of the CUDA EP failing to load. |
| NVIDIA driver | Recent enough for CUDA 12 (≥ 525) | Check with `nvidia-smi`. |
Expand Down Expand Up @@ -41,7 +41,7 @@ version — virtually always **cuDNN 9** or a CUDA 12 runtime lib.
nvidia-smi

# 2. THE decisive command — what is the provider .so actually missing?
ldd build/onnxruntime_dl/lib/libonnxruntime_providers_cuda.so | grep -i "not found"
ldd build/onnxruntime_dl/onnxruntime-linux-x64-gpu-1.20.1/lib/libonnxruntime_providers_cuda.so | grep -i "not found"

# 3. Is cuDNN 9 / cuBLAS installed and visible to the loader?
ldconfig -p | grep -i "cudnn\|cublas\|cufft"
Expand Down Expand Up @@ -72,7 +72,7 @@ for m in (nvidia.cudnn, nvidia.cublas)))"):$LD_LIBRARY_PATH

```bash
# Should now print nothing (no missing libraries):
ldd build/onnxruntime_dl/lib/libonnxruntime_providers_cuda.so | grep -i "not found"
ldd build/onnxruntime_dl/onnxruntime-linux-x64-gpu-1.20.1/lib/libonnxruntime_providers_cuda.so | grep -i "not found"
```

Re-run `scripts/webcam.sh` — the CUDA EP should load and the pipeline should run
Expand Down Expand Up @@ -172,7 +172,7 @@ A system `.deb`/`.tar` TensorRT 10.4 install from developer.nvidia.com/tensorrt
(then `sudo ldconfig`) works too. Verify the runtime is visible:

```bash
ldd build/onnxruntime_dl/lib/libonnxruntime_providers_tensorrt.so | grep -i nvinfer
ldd build/onnxruntime_dl/onnxruntime-linux-x64-gpu-1.20.1/lib/libonnxruntime_providers_tensorrt.so | grep -i nvinfer
# every libnvinfer*.so.10 / libnvonnxparser.so.10 line should resolve (no "not found")
```

Expand Down
Loading