Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use specific CMAKE_CUDA_COMPILER instead of forcing CMake to use the same compiler for both CXX and CUDA #1710

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

alexlnkp
Copy link
Contributor

Kind of a niche feature, I think. The idea behind the change is that CUDA compiler should be separate from CXX compiler, simply because then the user will be able to use -DCMAKE_CUDA_COMPILER=/specific/cuda/cc.

Made this change because nvcc doesn't like the latest GCC release in the package manager. However, conveniently there exists gcc13 package, that contains gcc-13.x versions. The issue is that CMake will want to use latest GCC for CXX, but due to specifying the compiler for CUDA as the same as compiler for CXX, CUDA will not be able to properly compile on latest GCC releases.

Solution? Simple! Just use the CMake's built-in CMAKE_<LANG>_COMPILER for handling the compiler specification for every language that is used in the CMake project.
This way, CMake can decide what compiler to use for CUDA on its own, or users will be able to specify the host compiler for nvcc using the -DCMAKE_CUDA_COMPILER=/specific/cuda/cc flag.

Additional changes:

  • Made CUDA's nvcc flag -std have the same value as the project's CMAKE_CXX_STANDARD for consistency. (Could possibly use set(CMAKE_CUDA_STANDARD 17) instead of list(APPEND CUDA_NVCC_FLAGS "-std=c++${CMAKE_CXX_STANDARD}"), but not sure if it would work as expected?)

@alexlnkp alexlnkp changed the title Use specific CMAKE_CUDA_COMPILER instead of forcing CMake to use specific compiler for both CXX and CUDA Use specific CMAKE_CUDA_COMPILER instead of forcing CMake to use the same compiler for both CXX and CUDA May 25, 2024
@alexlnkp
Copy link
Contributor Author

Python-wheels checks seemed to fail.
It would appear some pip packages were updated?

ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
    unknown package:
        Expected sha256 88593919a82336df9c990a5d9cda2cf47765a754ec55841894f44ebf11554338
             Got        906aeb1e8eca06e2b37fd2ad1d32a9520e7587c0a536a84e686226c400a72f63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant