NVIDIA / NVIDIA/cuda-samples

cmake add_custom_command() is not passing the ccbin flag to nvcc for the Fatbin and PTX cuda samples

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

Nobody has claimed this yet.

Dominant language
C++
Stars
9.6k
Forks
2.4k
Avg merge
53m
Merged PRs (30d)
1

Description

Using Version 13.3 of CUDA Toolkit on Fedora 44. The default GCC/G++ is version 16 and is unsupported by the cuda toolkit (> 15 not supported)

After generation of makefiles using the following command which passes older GCC/G++ compiler versions:
cmake -D CMAKE_C_COMPILER=gcc-15 -D CMAKE_CXX_COMPILER=g++-15 -D CMAKE_CUDA_HOST_COMPILER:STRING=g++-15 ..

nvcc is not receiving the correct compiler version via the cmake custom commands in a few samples. This only affects the samples involving the cmake custom commands used by fatbin and PTX related code. All other samples compile fine and run correctly.

I've introduced a workaround to the each of the affected CMakeLists.txt files to pass the compiler version:

Changed from:
add_custom_command(
...
COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} -Wno-deprecated-gpu-targets ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE}
...
)

To:
COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} -Wno-deprecated-gpu-targets -ccbin=${CMAKE_CUDA_HOST_COMPILER} ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE}

Although I think there might be a more appropriate option to pass in this case.

The affected examples are:
0_Introduction/
matrixMulDrv
simpleDrvRuntime
simpleTextureDrv
vectorAddDrv
vectorAddMMAP
2_Concepts_and_Techniques/
threadMigration
3_CUDA_Features/
memMapIPCDrv
ptxjit

Contributor guide

Open the contributing guide

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

Start with the CMakeLists.txt files for the listed fatbin and PTX examples, especially the add_custom_command() invocations that call nvcc. Reproduce generation with CMAKE_C_COMPILER=gcc-15, CMAKE_CXX_COMPILER=g++-15, and CMAKE_CUDA_HOST_COMPILER=g++-15, then verify the affected samples receive the selected host compiler and build successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.