Skip to content

added build support on Ampere - #2267

Merged
kmuseth merged 3 commits into
AcademySoftwareFoundation:masterfrom
kmuseth:build_nanovdb_examples_on_Ampere
Aug 25, 2026
Merged

kmuseth merged 3 commits into
AcademySoftwareFoundation:masterfrom
kmuseth:build_nanovdb_examples_on_Ampere

Conversation

@kmuseth

@kmuseth kmuseth commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

ex_make_mgpu_nanovdb uses TF32 WMMA which requires SM_80+ (Ampere or newer)

changed cmake to address this issue

Signed-off-by: Ken Museth <ken.museth@gmail.com>
Comment thread nanovdb/nanovdb/examples/CMakeLists.txt Outdated
target_link_libraries(ex_make_mgpu_nanovdb PRIVATE CUDA::curand)
# ex_make_mgpu_nanovdb uses TF32 WMMA which requires SM_80+ (Ampere or newer)
execute_process(
COMMAND bash -c "nvidia-smi --query-gpu=compute_cap --format=csv,noheader 2>/dev/null | sort -n | tail -1 | tr -d '.'"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you're building on a machine that doesn't have a GPU and going to run it on an SM >=8.0 machine? Or are we assuming all examples are built/run on the same machine and/or they're not used as CI tests (which might have this behaviour)?

Comment thread nanovdb/nanovdb/examples/CMakeLists.txt Outdated
target_link_libraries(ex_make_mgpu_nanovdb PRIVATE CUDA::curand)
# ex_make_mgpu_nanovdb uses TF32 WMMA which requires SM_80+ (Ampere or newer)
execute_process(
COMMAND bash -c "nvidia-smi --query-gpu=compute_cap --format=csv,noheader 2>/dev/null | sort -n | tail -1 | tr -d '.'"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Windows, assuming availability of bash is a hard requirement. Can we rely on something like CMAKE_CUDA_ARCHITECTURES (see, e.g. this) instead of probing the local machine with bash and nvidia-smi?

@apradhana apradhana Aug 5, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked Codex to scan CMAKE_CUDA_ARCHITECTURES and only add target if at least one architecture is >=80

if(CUDAToolkit_FOUND)
  set(_nanovdb_has_sm80 OFF)

  foreach(_cuda_arch IN LISTS CMAKE_CUDA_ARCHITECTURES)
    string(REGEX MATCH "^[0-9]+" _cuda_arch_number "${_cuda_arch}")
    if(_cuda_arch_number GREATER_EQUAL 80)
      set(_nanovdb_has_sm80 ON)
    endif()
  endforeach()

  if(_nanovdb_has_sm80)
    nanovdb_example(NAME "ex_make_mgpu_nanovdb") # requires cuRAND and SM_80+ (TF32 WMMA)
    target_link_libraries(ex_make_mgpu_nanovdb PRIVATE CUDA::curand)
  else()
    message(STATUS "Skipping ex_make_mgpu_nanovdb: requires CUDA architecture 80 or newer")
  endif()

  unset(_nanovdb_has_sm80)
  unset(_cuda_arch_number)
  unset(_cuda_arch)
endif()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, both of you — the nvidia-smi/bash probe was checking the wrong thing (the configure-time machine's GPU) in the wrong way (not portable to Windows). Replaced it with a check against CMAKE_CUDA_ARCHITECTURES instead, which already governs what SM architectures this build actually targets (and is what the rest of nanovdb/CMakeLists.txt uses for this purpose too, defaulting to 75 when unset) — so it correctly handles cross-compiling and GPU-less CI runners, and has no bash/nvidia-smi dependency at all.

@apradhana — used your Codex-suggested loop over CMAKE_CUDA_ARCHITECTURES as-is. Verified the arch-matching regex/comparison standalone against 75, 80, 86, the -real/-virtual suffix forms, native, and empty/multi-value lists — all resolve as expected.

@swahtz swahtz added the nanovdb label Aug 5, 2026
kmuseth and others added 2 commits August 22, 2026 14:52
The unit test provides its own main() and uses only gtest (no gmock), so it
needs just GTest::gtest. Listing gmock / gtest_main / gmock_main as well pulled
libgtest.a and libgmock.a onto the link line multiple times, which the macOS
(Xcode 15+) linker flags as "ignoring duplicate libraries". Linking only
GTest::gtest removes the warning and also works against gtest-only GoogleTest
installs (BUILD_GMOCK=OFF).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Ken Museth <ken.museth@gmail.com>
Signed-off-by: Ken Museth <ken.museth@gmail.com>
@kmuseth
kmuseth force-pushed the build_nanovdb_examples_on_Ampere branch from 9711fe7 to 4bd415f Compare August 22, 2026 21:52

@swahtz swahtz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing my notes

@apradhana apradhana left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the comment regarding bash+nvidia-smi approach, Ken. I tested the CMake with CUDA architecture: 75 skips, while 80, 75;80, and suffixed values like 80-real build as expected.

@kmuseth
kmuseth merged commit eb0f1bf into AcademySoftwareFoundation:master Aug 25, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants