Skip to content

Conversation

samuelpmish
Copy link

@samuelpmish samuelpmish commented Jul 17, 2025

Summary

I was trying out amr-wind earlier and found its CMake build was unable to configure for Blackwell architecture GPUs:

cmake . -Bbuild [...] -DCMAKE_CUDA_ARCHITECTURES=100
...
...
CMake Error at /usr/share/cmake-4.0/Modules/FindCUDA/select_compute_arch.cmake:245 (message):
  Unknown CUDA Architecture Name 10.0 in CUDA_SELECT_NVCC_ARCH_FLAGS
Call Stack (most recent call first):
  Tools/CMake/AMReXUtils.cmake:265 (cuda_select_nvcc_arch_flags)
  Tools/CMake/AMReXParallelBackends.cmake:99 (set_cuda_architectures)
  Src/CMakeLists.txt:40 (include)

It seems that the underlying cause was not in amr-wind itself, but in AMReX's use of some deprecated CMake CUDA features.

This PR makes a small change to the CMake build system to avoid those deprecated features, so that AMReX can compile with Hopper and Blackwell architecture GPUs. The configuration behavior is as follows:

cmake . -DAMReX_GPU_BACKEND=CUDA
will default to the "native" option (which selects architecture based on the hardware present in the machine)

cmake . -DAMReX_GPU_BACKEND=CUDA -DCMAKE_CUDA_ARCHITECTURES=100
builds for the explicitly-specified architecture(s)

Tasks

  • ensure "native" compilation still picks he local GPU, if present, with the same precedence of user hints as before
  • ensure user interface does not break, e.g., AMREX_CUDA_ARCH env hint still works and has the same precendence
  • Update docs/logic on Device LTO and avoid to break users.
  • Ensure that for HPC machines, we pre-compile (i.e., at least when AMREX_CUDA_ARCH is set / CMAKE_CUDA_ARCHITECTURES is selected to a narrow set) down to SASS code, otherwise we will in an MPI context compile every process on startup from PTX to SASS, potentially 10's of thousands of times.
  • CUDA 12.9 raises: Support for offline compilation for architectures prior to '<compute/sm/lto>_75' will be removed in a future release

Checklist

The proposed changes:

  • fix a bug or incorrect behavior in AMReX
  • add new capabilities to AMReX
  • are likely to significantly affect the results of downstream AMReX users
  • include documentation in the code and/or rst files, if appropriate

@ax3l
Copy link
Member

ax3l commented Jul 24, 2025

Thank you for this!

Yes #3948 is over-due and it looks like we also have some breakage with the latest CUDA 12.9 and CMake now with the old logic.

I am OoO for the rest of the week, but we should try to get this in for the next release of AMReX and I will try to help next week.

Bumping CMake to 3.24+ globally is fine now, please go ahead.

Please check that we can use the build mode of building for the local "native" GPU when one is discovered, to simplify development. Otherwise, let us keep the AMREX_ARCH env hint (if set) that we use so far to set a default for CMAKE_CUDA_ARCHITECTURES.

set(AMReX_CUDA_ARCH_DEFAULT "${CMAKE_CUDA_ARCHITECTURES}")
endif ()
if(DEFINED ENV{AMREX_CUDA_ARCH})
set(AMReX_CUDA_ARCH_DEFAULT "$ENV{AMREX_CUDA_ARCH}")
Copy link
Member

Choose a reason for hiding this comment

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

Let us keep that $ENV{AMREX_CUDA_ARCH} hint to avoid breakage for users.

If found, we simply set the default for CMAKE_CUDA_ARCHITECTURES to it.

# Take care of cuda archs
set_cuda_architectures(AMReX_CUDA_ARCH)
# default to building for the architecture of the available GPU
set(AMREX_CUDA_ARCHS native)
Copy link
Member

Choose a reason for hiding this comment

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

Great!

@ax3l
Copy link
Member

ax3l commented Jul 24, 2025

@samuelpmish There is a lot of legacy logic in Tools/CMake/AMReXUtils.cmake and others where we wrange CUDA archs and CUDA device LTO flags.

Can you remove/clean those out if you have a chance?

I can help next week, too.

@ax3l
Copy link
Member

ax3l commented Jul 24, 2025

@cyrush can you potentially update the Catalyst image we use in AMReX/WarpX to include CMake 3.24 or newer? 🙏

@ax3l
Copy link
Member

ax3l commented Jul 24, 2025

@c-wetterer-nelson can you potentially update the SENSEI image we use in AMReX/WarpX to include CMake 3.24 or newer? 🙏

@c-wetterer-nelson
Copy link
Contributor

Hey Axel, are there still SENSEI users across AMReX/WarpX?

@cyrush
Copy link
Contributor

cyrush commented Jul 25, 2025

@ax3l our current ascent containers (0.9.4) are using CMake 3.28. The internal layout changed a bit, but I can address that.
It looks like you are using Ascent 0.9.2.

Ascent 0.9.3 (also available) is using CMake 3.26.3.

So a quick update to ascent 0.9.3 will get you beyond CMake 3.24, down the road I can help get 0.9.4 working your CI.

@ax3l ax3l added the bug label Jul 29, 2025
@ax3l
Copy link
Member

ax3l commented Jul 29, 2025

@c-wetterer-nelson

Hey Axel, are there still SENSEI users across AMReX/WarpX?

That is a good question, I think in WarpX not anymore.

@WeiqunZhang should we drop SENSEI throughout AMReX & BLAST codes?

This was referenced Jul 29, 2025
roelof-groenewald pushed a commit to BLAST-WarpX/warpx that referenced this pull request Jul 29, 2025
Update Ascent to the latest patch release of the 0.9.X line, primarily
for a newer CMake in the image.

X-ref:
AMReX-Codes/amrex#4572 (comment)
@ax3l
Copy link
Member

ax3l commented Jul 30, 2025

I have to move this PR and testing it downstream into the 25.09 release cycle, due to other deadlines.

There is a hotfix for CUDA 12.9 for now in #4589

@ax3l
Copy link
Member

ax3l commented Jul 30, 2025

I added a task list to the PR description on things we will need to carefully check with downstream codes to avoid breakage.

atmyers pushed a commit that referenced this pull request Jul 30, 2025
## Summary

The legacy CMake logic we have fails the moment that CUDA Toolkit
advertises SMs >= 10.0. While we work on a modernization #4572, the
current `development` breaks **all CUDA builds** in CUDA 12.9, even for
older SMs.

Exclude newer SMs for now from our build logic.

## Additional background

Seen with
```
$ cmake --version
cmake version 3.30.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).

$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2025 NVIDIA Corporation
Built on Tue_May_27_02:21:03_PDT_2025
Cuda compilation tools, release 12.9, V12.9.86
Build cuda_12.9.r12.9/compiler.36037853_0
```

## Checklist

The proposed changes:
- [x] fix a bug or incorrect behavior in AMReX
- [ ] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [ ] include documentation in the code and/or rst files, if appropriate
WeiqunZhang pushed a commit that referenced this pull request Jul 31, 2025
## Summary

Update Ascent to the latest patch release of the 0.9.X line, primarily
for a newer CMake in the image.

## Additional background

See
#4572 (comment)
Thanks @cyrush !!
@samuelpmish
Copy link
Author

Hey, sorry to disappear for a bit after posting this PR. I'm not sure I understand AMReX's build system enough to address some of the tasks on my own. Can someone help clarify the requirements for the listed tasks:

- ensure "native" compilation still picks he local GPU, if present, with the same precedence of user hints as before
- ensure user interface does not break, e.g., AMREX_CUDA_ARCH env hint still works and has the same precendence
- Update docs/logic on Device LTO and avoid to break users.
- Ensure that for HPC machines, we pre-compile (i.e., at least when AMREX_CUDA_ARCH is set / CMAKE_CUDA_ARCHITECTURES is selected to a narrow set) down to SASS code, otherwise we will in an MPI context compile every process on startup from PTX to SASS, potentially 10's of thousands of times.
- CUDA 12.9 raises: Support for offline compilation for architectures prior to '<compute/sm/lto>_75' will be removed in a future release

It seems like some of them are already satisfied (e.g. native compilation picking the local GPU). I believe the -arch=native will generate SASS for the available GPUs already.

Other ones like the warning about sm_75 can be suppressed with a flag, but I'm not sure that's always a good thing (as it hides important info from users with those cards).

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.

4 participants