dspl1236/cheshire

Meshroom/AliceVision photogrammetry on AMD Radeon GPUs via HIP: CUDA->HIP compatibility layer, VRAM->system-RAM memory bridge, Windows + Linux bundles, validated on RDNA1/2/4 against a CUDA node.

0

stars

64

commits

C++

primary language

Sep 14, 2026

updated

alicevision
amd
cuda-to-hip
depth-map
gpu
hip
linux
meshroom
photogrammetry
radeon
rdna
rocm
windows

README

Cheshire

Meshroom / AliceVision photogrammetry on AMD Radeon GPUs, via HIP.

AliceVision's dense reconstruction (DepthMap, the stage Meshroom needs a GPU for) is written in CUDA and has only ever run on NVIDIA. Cheshire compiles those same CUDA kernels as HIP through a small compatibility layer, adds a memory bridge that lets the stage spill from VRAM into system RAM instead of failing, and packages the result for Windows and Linux. Validated against a CUDA node's output on RDNA1, RDNA2 and RDNA4 cards.

The cat that grins on any hardware.

Results

Same photos, same SfM, same DepthMap parameters as the CUDA reference (Meshroom 2023.3 on a GTX 1080 Ti); only the GPU stage differs. Metrics are per view over pixels valid in both maps.

GPUOS6 views41 viewsvalid masksmedian rel. depth errorwithin 1 % (median view, 6 / 41)
GTX 1080 Ti (CUDA reference)Linux31.9 s105.5 s
Radeon RX 9070, RDNA4Windows17.4 s124.4 sidentical0.000098.9 % / 98.7 %
Radeon RX 6750 XT, RDNA2Linux31.0 s226.1 sidentical0.000097.5 % / 98.1 %
Radeon RX 5500 XT, RDNA1Linux60.7 s447.7 sidentical0.000097.5 % / 98.1 %

RDNA1 and RDNA2 produce bit-identical depth maps. The remaining 1-3 % of pixels that differ by more than 1 % between GPU generations (and against CUDA) is the algorithm's cross-hardware noise floor: texture-filter and FMA rounding, not a port defect. Full per-view tables and side-by-side panels: docs/validation.

Memory bridge

Measured on the RX 9070 (hip/tests/membridge_probe.hip), the tiers the bridge chooses between:

memorykernel streaming read
VRAM (hipMalloc)585-619 GB/s
mapped system RAM (hipHostMalloc, PCIe 4.0 x16)24.6-26.6 GB/s
hipMallocManaged26.6 GB/s (no page migration on Windows)
pinned host copies28 GB/s each way

On Windows the driver already lets hipMalloc run past VRAM into system RAM; on Linux it fails hard. The bridge (hip/compat/include/cheshire/bridge.h) makes both behave the same, and v2 decides what spills by buffer class instead of by arrival order. Measured, one class at a time behind PCIe, every run bit-identical:

spilled to system RAM (6 views)fine-grained host memorycoarse-grained (shipped)
nothing20.6 s20.2 s
depth/sim maps (879 MB)35.9 s (1.7x)25.5 s (1.3x)
similarity volumes (6.0 GB)96.4 s (4.7x)76.6 s (3.8x)
camera images (186 MB)460 s (22x)20.4 s (1.0x)

The host tier is coarse-grained (hipHostMallocNonCoherent): the GPU caches it, atomics work, and the texture-sampled camera images stop costing anything. Images stay resident regardless (the planner reserves VRAM for them), volumes and maps spill, and the DepthMap planner sizes its tile parallelism from the bridge's budget instead of hipMemGetInfo:

VRAM availablev1 (arrival order, planner unaware)v2
1.5 GB47.7 s, 188 spills20.0 s, 0 spills
1 GB20.3 s, 0 spills
500 MB (below one tile)fails upstream47.2 s, runs

Tile parallelism costs nothing to give up on this GPU, so a card with 1 GB to spare runs the stage at full speed. Design, knobs and every table: docs/02-memory-bridge.md.

What was found on the way (reproducers in hip/tests/)

  • HIP drops surf2Dwrite stores into 16-bit float arrays, on Windows and Linux alike; reads are fine. AliceVision's mip chain is built through a buffer copy instead.
  • Linux ROCm 7.2 has no hipMallocMipmappedArray on RDNA1 (and WSL2 has no textures at all). Mipmaps are emulated in the compat layer as one texture per level, in array or pitched linear memory: bit-identical to native mipmaps on the RX 9070, 15 % slower there, so the Windows build keeps native. Linear levels are what lets the bridge account for camera images.
  • GPU atomics into mapped host memory are silently wrong on Linux unless the memory is allocated non-coherent: on an RX 6750 XT, atomicMin into default (fine-grained) host memory fails on every element while atomicAdd works, and both are right on hipHostMallocNonCoherent memory (hip/tests/host_atomics.hip; Windows passes all cases). Anything that spills a buffer kernels do atomics on, LLM runtimes included, needs to know.
  • Fine-grained host memory is the wrong tier for texture-sampled data: with the default mapping, 186 MB of camera images behind PCIe cost 22x while 6 GB of streamed volumes cost 4.7x; allocated coarse-grained, the device caches them and the images cost nothing.
  • ROCm for Windows installs as pip wheels, no admin installer. CMake refuses to mix cl.exe with clang for HIP: use clang-cl for both. -fgpu-rdc is broken on Windows, so the device code is compiled as one unity translation unit.
  • A relocatable bundle needs things the dependency walkers never see: HIP loads the code-object manager (libamd_comgr / amd_comgr0702.dll) at runtime on both OSes, and without it the GPU simply "does not exist". On Linux a WSL build box also ships the /dev/dxg flavour of libhsa-runtime64, which must be swapped for the KFD one. With those in place RDNA1 works natively on ROCm 7.2.

Downloads

Binaries are on the v0.2.1 release (bridge v2 plus APU code objects); the data sets and references are on v0.1.0 and unchanged, the depth maps being bit-identical between the two:

assetsizecontents
cheshire-alicevision-hip-windows-x64-rocm7.2.1-gfx1201.zip (v0.2.1)100 MBself-contained AliceVision + HIP DepthMap for RDNA4 on Windows; unzip, needs only the Adrenalin driver
cheshire-alicevision-hip-windows-x64-rocm7.2.1-rdna3-rdna4.zip (v0.2.1)100 MBthe same, with code objects for RDNA3/RDNA4 discrete parts and the RDNA3 APUs (gfx1100/1101/1102/1103/1150/1151/1152/1153/1200/1201): RX 7000 owners and Ryzen 7040/8040/AI laptops, this is the one to try
cheshire-alicevision-hip-linux-x64-rocm7.2.tar.gz (v0.2.1)~120 MBrelocatable Linux bundle, code objects for RDNA1-RDNA4 discrete parts, the RDNA2/RDNA3 APUs (gfx1035/1036/1103/1150/1151/1152/1153) and Vega (gfx900/906, untested); needs only amdgpu + /dev/kfd
monstree-mini6-meshroom-cache.tar.gz (v0.1.0)383 MB6-view Meshroom 2023.3 cache: CameraInit, SfM, PrepareDenseScene and the CUDA DepthMap reference
monstree-full-cuda-reference.tar.gz (v0.1.0)680 MB41-view SfM + CUDA DepthMap reference (GTX 1080 Ti)
cheshire-hip-depthmap-outputs.tar.gz (v0.1.0)966 MBthe HIP depth maps behind the table above (RX 9070 6 + 41 views, RX 5500 XT, RX 6750 XT)

Reproduce a row: unpack a cache under data/ref/<dataset>/, then scripts\run-depthmap.cmd <dataset> (Windows, set CHESHIRE_INSTALL to the unzipped folder) or scripts/linux/run-depthmap.sh (Linux). Both run the exact Meshroom 2023.3 DepthMap command line and finish with scripts/compare_depthmaps.py, which prints the per-view table and writes the side-by-side panels. Photos are alicevision/dataset_monstree.

Help wanted: RDNA3

Every package carries RDNA3 code objects (gfx1100/1101/1102, plus the APUs gfx1103/1150/1151/1152/1153) and none has run on RDNA3 hardware; there is no such chip here. Ten minutes on an RX 7600/7700/7800/7900, or a Ryzen 7040/8040/AI 300 laptop, closes the gap:

  1. Download the RDNA3+RDNA4 Windows zip (or the Linux bundle) and monstree-mini6-meshroom-cache.tar.gz from the release pages above.
  2. Unpack the cache under data/ref/monstree-mini6/, unzip the package anywhere, then set CHESHIRE_INSTALL=<unzipped folder> and scripts\run-depthmap.cmd monstree-mini6 (Linux: scripts/linux/run-depthmap.sh <bundle> <cache> <out> <cache>/DepthMap/<id>).
  3. It prints the card name, Task done in (s), and a per-view table against the CUDA reference; compare_stats.md lands next to the depth maps. Open an issue with those two things and the card model. A [cheshire] bridge summary line appears with CHESHIRE_BRIDGE_LOG=1 if anything spilled.

Expected: mask agreement 1.000, median relative depth error 0.0000, 97-99 % of pixels within 1 % on every view, and a time somewhere between the RX 6750 XT and the RX 9070 rows.

Layout

PathWhat
hip/compat/include/cheshire/the CUDA -> HIP compatibility header, the memory bridge, the mipmap emulation
hip/port/fused SGM aggregation and the other upstreamable source changes, applied by scripts/apply_hip_patch.py
hip/tests/standalone HIP probes: textures, surfaces, mipmaps, bandwidth, allocation, launch overhead, the bridge
scripts/Windows build (build-alicevision.cmd), Linux superbuild and bundle (scripts/linux/), validation runner, comparison tool
docs/findings, toolchain notes, bridge design, port log, validation, performance, Linux build
third_party/aliceVisionupstream AliceVision, pinned as a submodule and left untouched; the HIP backend is a patch set

Building

  • Windows (RDNA3/RDNA4): docs/01-toolchain-windows.md, then scripts\build-alicevision.cmd gfx1201 install.
  • Linux (RDNA1-RDNA4): docs/06-linux-build.md, then scripts/linux/build-deps.sh and scripts/linux/build-alicevision.sh bundle.
  • Validate: scripts\run-depthmap.cmd <dataset> or scripts/linux/run-depthmap.sh against a Meshroom cache; scripts/compare_depthmaps.py produces the numbers and panels.

Status and next

Works end to end on RDNA1, RDNA2 and RDNA4; RDNA3 has its code object in every bundle but no hardware run yet. GCN 4 (RX 400/500) is out: the ROCm 7.2 runtime refuses to initialise on an RX 570 even though the kernel driver accepts it (docs/06). A production Meshroom 2023.3 node runs its DepthMap on the HIP build through scripts/linux/meshroom-pair.sh (one wrapper, picks CUDA or HIP per run, so the card can be swapped). Next: planner-chosen tile sizes for the below-one-tile regime, a same-version CUDA reference, RDNA3 hardware.

Primary repository: git.hausofdub.com/dspl1236/cheshire; mirror: github.com/dspl1236/cheshire. Licensed MPL-2.0.

Contributors

dspl1236

64 commits

dspl1236/cheshire

Meshroom/AliceVision photogrammetry on AMD Radeon GPUs via HIP: CUDA->HIP compatibility layer, VRAM->system-RAM memory bridge, Windows + Linux bundles, validated on RDNA1/2/4 against a CUDA node.

0

stars

64

commits

C++

primary language

Sep 14, 2026

updated

alicevision
amd
cuda-to-hip
depth-map
gpu
hip
linux
meshroom
photogrammetry
radeon
rdna
rocm
windows

README

Cheshire

Meshroom / AliceVision photogrammetry on AMD Radeon GPUs, via HIP.

AliceVision's dense reconstruction (DepthMap, the stage Meshroom needs a GPU for) is written in CUDA and has only ever run on NVIDIA. Cheshire compiles those same CUDA kernels as HIP through a small compatibility layer, adds a memory bridge that lets the stage spill from VRAM into system RAM instead of failing, and packages the result for Windows and Linux. Validated against a CUDA node's output on RDNA1, RDNA2 and RDNA4 cards.

The cat that grins on any hardware.

Results

Same photos, same SfM, same DepthMap parameters as the CUDA reference (Meshroom 2023.3 on a GTX 1080 Ti); only the GPU stage differs. Metrics are per view over pixels valid in both maps.

GPUOS6 views41 viewsvalid masksmedian rel. depth errorwithin 1 % (median view, 6 / 41)
GTX 1080 Ti (CUDA reference)Linux31.9 s105.5 s
Radeon RX 9070, RDNA4Windows17.4 s124.4 sidentical0.000098.9 % / 98.7 %
Radeon RX 6750 XT, RDNA2Linux31.0 s226.1 sidentical0.000097.5 % / 98.1 %
Radeon RX 5500 XT, RDNA1Linux60.7 s447.7 sidentical0.000097.5 % / 98.1 %

RDNA1 and RDNA2 produce bit-identical depth maps. The remaining 1-3 % of pixels that differ by more than 1 % between GPU generations (and against CUDA) is the algorithm's cross-hardware noise floor: texture-filter and FMA rounding, not a port defect. Full per-view tables and side-by-side panels: docs/validation.

Memory bridge

Measured on the RX 9070 (hip/tests/membridge_probe.hip), the tiers the bridge chooses between:

memorykernel streaming read
VRAM (hipMalloc)585-619 GB/s
mapped system RAM (hipHostMalloc, PCIe 4.0 x16)24.6-26.6 GB/s
hipMallocManaged26.6 GB/s (no page migration on Windows)
pinned host copies28 GB/s each way

On Windows the driver already lets hipMalloc run past VRAM into system RAM; on Linux it fails hard. The bridge (hip/compat/include/cheshire/bridge.h) makes both behave the same, and v2 decides what spills by buffer class instead of by arrival order. Measured, one class at a time behind PCIe, every run bit-identical:

spilled to system RAM (6 views)fine-grained host memorycoarse-grained (shipped)
nothing20.6 s20.2 s
depth/sim maps (879 MB)35.9 s (1.7x)25.5 s (1.3x)
similarity volumes (6.0 GB)96.4 s (4.7x)76.6 s (3.8x)
camera images (186 MB)460 s (22x)20.4 s (1.0x)

The host tier is coarse-grained (hipHostMallocNonCoherent): the GPU caches it, atomics work, and the texture-sampled camera images stop costing anything. Images stay resident regardless (the planner reserves VRAM for them), volumes and maps spill, and the DepthMap planner sizes its tile parallelism from the bridge's budget instead of hipMemGetInfo:

VRAM availablev1 (arrival order, planner unaware)v2
1.5 GB47.7 s, 188 spills20.0 s, 0 spills
1 GB20.3 s, 0 spills
500 MB (below one tile)fails upstream47.2 s, runs

Tile parallelism costs nothing to give up on this GPU, so a card with 1 GB to spare runs the stage at full speed. Design, knobs and every table: docs/02-memory-bridge.md.

What was found on the way (reproducers in hip/tests/)

  • HIP drops surf2Dwrite stores into 16-bit float arrays, on Windows and Linux alike; reads are fine. AliceVision's mip chain is built through a buffer copy instead.
  • Linux ROCm 7.2 has no hipMallocMipmappedArray on RDNA1 (and WSL2 has no textures at all). Mipmaps are emulated in the compat layer as one texture per level, in array or pitched linear memory: bit-identical to native mipmaps on the RX 9070, 15 % slower there, so the Windows build keeps native. Linear levels are what lets the bridge account for camera images.
  • GPU atomics into mapped host memory are silently wrong on Linux unless the memory is allocated non-coherent: on an RX 6750 XT, atomicMin into default (fine-grained) host memory fails on every element while atomicAdd works, and both are right on hipHostMallocNonCoherent memory (hip/tests/host_atomics.hip; Windows passes all cases). Anything that spills a buffer kernels do atomics on, LLM runtimes included, needs to know.
  • Fine-grained host memory is the wrong tier for texture-sampled data: with the default mapping, 186 MB of camera images behind PCIe cost 22x while 6 GB of streamed volumes cost 4.7x; allocated coarse-grained, the device caches them and the images cost nothing.
  • ROCm for Windows installs as pip wheels, no admin installer. CMake refuses to mix cl.exe with clang for HIP: use clang-cl for both. -fgpu-rdc is broken on Windows, so the device code is compiled as one unity translation unit.
  • A relocatable bundle needs things the dependency walkers never see: HIP loads the code-object manager (libamd_comgr / amd_comgr0702.dll) at runtime on both OSes, and without it the GPU simply "does not exist". On Linux a WSL build box also ships the /dev/dxg flavour of libhsa-runtime64, which must be swapped for the KFD one. With those in place RDNA1 works natively on ROCm 7.2.

Downloads

Binaries are on the v0.2.1 release (bridge v2 plus APU code objects); the data sets and references are on v0.1.0 and unchanged, the depth maps being bit-identical between the two:

assetsizecontents
cheshire-alicevision-hip-windows-x64-rocm7.2.1-gfx1201.zip (v0.2.1)100 MBself-contained AliceVision + HIP DepthMap for RDNA4 on Windows; unzip, needs only the Adrenalin driver
cheshire-alicevision-hip-windows-x64-rocm7.2.1-rdna3-rdna4.zip (v0.2.1)100 MBthe same, with code objects for RDNA3/RDNA4 discrete parts and the RDNA3 APUs (gfx1100/1101/1102/1103/1150/1151/1152/1153/1200/1201): RX 7000 owners and Ryzen 7040/8040/AI laptops, this is the one to try
cheshire-alicevision-hip-linux-x64-rocm7.2.tar.gz (v0.2.1)~120 MBrelocatable Linux bundle, code objects for RDNA1-RDNA4 discrete parts, the RDNA2/RDNA3 APUs (gfx1035/1036/1103/1150/1151/1152/1153) and Vega (gfx900/906, untested); needs only amdgpu + /dev/kfd
monstree-mini6-meshroom-cache.tar.gz (v0.1.0)383 MB6-view Meshroom 2023.3 cache: CameraInit, SfM, PrepareDenseScene and the CUDA DepthMap reference
monstree-full-cuda-reference.tar.gz (v0.1.0)680 MB41-view SfM + CUDA DepthMap reference (GTX 1080 Ti)
cheshire-hip-depthmap-outputs.tar.gz (v0.1.0)966 MBthe HIP depth maps behind the table above (RX 9070 6 + 41 views, RX 5500 XT, RX 6750 XT)

Reproduce a row: unpack a cache under data/ref/<dataset>/, then scripts\run-depthmap.cmd <dataset> (Windows, set CHESHIRE_INSTALL to the unzipped folder) or scripts/linux/run-depthmap.sh (Linux). Both run the exact Meshroom 2023.3 DepthMap command line and finish with scripts/compare_depthmaps.py, which prints the per-view table and writes the side-by-side panels. Photos are alicevision/dataset_monstree.

Help wanted: RDNA3

Every package carries RDNA3 code objects (gfx1100/1101/1102, plus the APUs gfx1103/1150/1151/1152/1153) and none has run on RDNA3 hardware; there is no such chip here. Ten minutes on an RX 7600/7700/7800/7900, or a Ryzen 7040/8040/AI 300 laptop, closes the gap:

  1. Download the RDNA3+RDNA4 Windows zip (or the Linux bundle) and monstree-mini6-meshroom-cache.tar.gz from the release pages above.
  2. Unpack the cache under data/ref/monstree-mini6/, unzip the package anywhere, then set CHESHIRE_INSTALL=<unzipped folder> and scripts\run-depthmap.cmd monstree-mini6 (Linux: scripts/linux/run-depthmap.sh <bundle> <cache> <out> <cache>/DepthMap/<id>).
  3. It prints the card name, Task done in (s), and a per-view table against the CUDA reference; compare_stats.md lands next to the depth maps. Open an issue with those two things and the card model. A [cheshire] bridge summary line appears with CHESHIRE_BRIDGE_LOG=1 if anything spilled.

Expected: mask agreement 1.000, median relative depth error 0.0000, 97-99 % of pixels within 1 % on every view, and a time somewhere between the RX 6750 XT and the RX 9070 rows.

Layout

PathWhat
hip/compat/include/cheshire/the CUDA -> HIP compatibility header, the memory bridge, the mipmap emulation
hip/port/fused SGM aggregation and the other upstreamable source changes, applied by scripts/apply_hip_patch.py
hip/tests/standalone HIP probes: textures, surfaces, mipmaps, bandwidth, allocation, launch overhead, the bridge
scripts/Windows build (build-alicevision.cmd), Linux superbuild and bundle (scripts/linux/), validation runner, comparison tool
docs/findings, toolchain notes, bridge design, port log, validation, performance, Linux build
third_party/aliceVisionupstream AliceVision, pinned as a submodule and left untouched; the HIP backend is a patch set

Building

  • Windows (RDNA3/RDNA4): docs/01-toolchain-windows.md, then scripts\build-alicevision.cmd gfx1201 install.
  • Linux (RDNA1-RDNA4): docs/06-linux-build.md, then scripts/linux/build-deps.sh and scripts/linux/build-alicevision.sh bundle.
  • Validate: scripts\run-depthmap.cmd <dataset> or scripts/linux/run-depthmap.sh against a Meshroom cache; scripts/compare_depthmaps.py produces the numbers and panels.

Status and next

Works end to end on RDNA1, RDNA2 and RDNA4; RDNA3 has its code object in every bundle but no hardware run yet. GCN 4 (RX 400/500) is out: the ROCm 7.2 runtime refuses to initialise on an RX 570 even though the kernel driver accepts it (docs/06). A production Meshroom 2023.3 node runs its DepthMap on the HIP build through scripts/linux/meshroom-pair.sh (one wrapper, picks CUDA or HIP per run, so the card can be swapped). Next: planner-chosen tile sizes for the below-one-tile regime, a same-version CUDA reference, RDNA3 hardware.

Primary repository: git.hausofdub.com/dspl1236/cheshire; mirror: github.com/dspl1236/cheshire. Licensed MPL-2.0.

Contributors

dspl1236

64 commits

Languages

C++

29.5%

HIP

26.7%

Python

21.7%

Batchfile

9.9%

Shell

8.3%

CMake

3.1%