NVIDIA / NVIDIA/AMGX

[Issue] CLASSICAL AMG fails with `cudaErrorInvalidDeviceFunction` on CUDA 13 / SM89 while AGGREGATION works

Open
#380 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Cuda
Stars
692
Forks
197
PR merge metrics
No merged PRs in 30d

Description

Hello,

I get a Thrust failure: parallel_for failed: cudaErrorInvalidDeviceFunction: invalid device function during AMGX_solver_setup() when using CLASSICAL AMG. Using AGGREGATION seems to work. I may be missing a required configuration or build option, but I have been unable to identify what if any.

This happens on a completely fresh clone of AMGX, the supplied amgx_capi example, and a Poisson matrix generated by the supplied generate_poisson example.

The same AMGX build, executable, matrix, GPU, and CUDA installation seems to work correctly when using AGGREGATION AMG.

Environment
  • OS: WSL2 / Ubuntu 22.04.5 LTS
  • GPU: NVIDIA RTX 500 Ada Generation Laptop GPU
  • Compute capability: 8.9 / SM89
  • NVIDIA driver: 595.95
  • CUDA toolkit: CUDA 13.0
  • CUDA runtime reported by AMGX: 13.0
  • CUDA driver API reported by AMGX: 13.2
  • AMGX source: current main
  • AMGX commit: 91a8413ef267b1c32aff4014c02820e1c5897ac2
  • Runtime AMGX banner reports version: 2.5.0
  • Build type: Release
  • CMake version: 4.2.3
  • C/C++ compiler: CMAKE_C_COMPILER:FILEPATH=/usr/bin/cc CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++ CMAKE_CUDA_COMPILER:FILEPATH=/usr/local/cuda-13.0/bin/nvcc
  • CUDA architecture:
    CMAKE_CUDA_ARCHITECTURES:STRING=89

This issue can be seen with the serial amgx_capi example

Build

Fresh clone:

git clone https://github.com/NVIDIA/AMGX.git AMGX-clean
cd AMGX-clean

mkdir build
cd build

cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DCUDA_ARCH="89" \
    ..

make -j10 all

CMake cache confirms:

CMAKE_CUDA_ARCHITECTURES:STRING=89
CUDA_ARCH:UNINITIALIZED=89

The example loads the library from this fresh build:

libamgxsh.so => /home/mike/src/AMGX-clean/build/libamgxsh.so

Reproduction

Generate a 32x32x32 7-point Poisson problem:

cd ~/src/AMGX-clean/build

./examples/generate_poisson \
    -p 7 32 32 32 \
    -o poisson_32.mtx
Test 1: supplied CLASSICAL configuration — fails
./examples/amgx_capi \
    -m poisson_32.mtx \
    -c ../src/configs/FGMRES_CLASSICAL_AGGRESSIVE_PMIS.json

Result:

AMGX version 2.5.0
Compiled with CUDA Runtime 13.0, using CUDA driver 13.2
Matrix A is scalar and has 32768 rows
Thrust failure: parallel_for failed: cudaErrorInvalidDeviceFunction: invalid device function
File and line number are not available for this exception.
Test 2: minimal/default CLASSICAL AMG — fails

Configuration:

{
    "config_version": 2,
    "solver": {
        "solver": "AMG",
        "max_iters": 1,
        "print_grid_stats": 1
    }
}

Run:

./examples/amgx_capi \
    -m poisson_32.mtx \
    -c ../minimal_classical.json

This fails during setup with the same:

Thrust failure: parallel_for failed: cudaErrorInvalidDeviceFunction: invalid device function
Test 3: supplied AGGREGATION configuration — works
./examples/amgx_capi \
    -m poisson_32.mtx \
    -c ../src/configs/FGMRES_AGGREGATION.json

This succeeds, builds an 8-level hierarchy, and solves normally:

AMG Grid:
         Number of Levels: 8
...
Total Iterations: 10
Final Residual: 9.384372e-05
Test 4: minimal AGGREGATION AMG — works

Configuration:

{
    "config_version": 2,
    "solver": {
        "solver": "AMG",
        "algorithm": "AGGREGATION",
        "selector": "SIZE_2",
        "max_iters": 1,
        "print_grid_stats": 1
    }
}

Run:

./examples/amgx_capi \
    -m poisson_32.mtx \
    -c ../minimal_aggregation.json

This successfully constructs an 8-level AMG hierarchy.

Expected behavior

CLASSICAL AMG should successfully construct the hierarchy and attempt to solve the Poisson problem on an SM89 GPU using CUDA 13.0.

Actual behavior

CLASSICAL AMG fails during setup with:

Thrust failure: parallel_for failed: cudaErrorInvalidDeviceFunction: invalid device function

while AGGREGATION AMG works with the same build and input.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure by building with CMake using CUDA architecture 89, then run examples/generate_poisson and examples/amgx_capi with the supplied CLASSICAL and AGGREGATION configuration files. Compare the CLASSICAL AMG setup path with the working AGGREGATION path; done means CLASSICAL constructs the hierarchy and attempts the Poisson solve on SM89 with CUDA 13.0 while AGGREGATION still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake
Domain
hpc
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.