negativo17 / cuda

NVIDIA Compute Unified Device Architecture Toolkit
14 stars 1 forks source link

cuda-devel does not intall /usr/include/c++/13 on Fedora-41 #35

Open eleaver opened 3 weeks ago

eleaver commented 3 weeks ago

Fedora 41 system compiler is gcc-14.2.x. nvcc from cuda-nvcc calls /usr/bin/cuda/g++ from cuda-devel, version 13.3.x. But for example /usr/include/cub/util_device.cuh explicitly defines std::atomic flag; (where DeviceEntryStatus is type int), and I have been unable to find where /usr/include/cuda provides an explicit std::atomic replacement. Perhaps I'm mistaken, or perhaps it doesn't.

Either way, /usr/bin/cuda/g++ would ordinarily look for std::atomic in /usr/include/c++/13, and ordinarily find it if /usr/bin/g++ were version 13.x.y. But on Fedora 41 it isn't. And one cannot just "dnf install gcc13-c++" from fedora repo and be done, as gcc13-c++ and cuda-gcc-c++ both provide /usr/libexec/gcc/x86_64-redhat-linux/13, so both cannot be simultaneously installed.

Resolving this issue -- if that's what it is -- might require a modicum of thought to avoid similar package conflicts elsewhere or on other distros e.g. where /usr/bin/g++ and /usr/bin/cuda/g++ are same version. Fortunately, there is time for thought as the issue -- if that's what it is -- is not pressing as there's a ready workaround:

a. dnf remove cuda-devel b. dnf install gcc13-c++ from fedora repo, which installs /usr/include/c++/13 c. cp -rap /usr/include/c++/13 13.bak d. dnf remove gcc13-c++ (deletes /usr/include/c++/13) e. dnf install cuda-devel f. cp -rap 13.bak /usr/include/c++/13 g. Compile and link massive legacy project, run its test suite. Done!

Thanks!

scaronni commented 3 weeks ago

Hallo, have you tried one of the following:

# rpm -e --nodeps cuda-gcc cuda-gcc-c++
# unset NVCC_PREPEND_FLAGS (or logout/login, as you prefer)
# export NVCC_PREPEND_FLAGS='-ccbin /usr/bin/g++-13'

If passing the include on the command line works with cuda-gcc-c++ works, then it means there might be a bug in the compilation / the way the package is assembled.

If the second one works, it might be as well easier to make cuda-gcc-c++ provide only the necessary variable and get rid completely of the custom cuda-gcc.

scaronni commented 3 weeks ago

You can also try with NVCC_BIN as described here: https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/#nvcc-environment-variables

# rpm -e --nodeps cuda-gcc cuda-gcc-c++
# unset NVCC_PREPEND_FLAGS (or logout/login, as you prefer)
# export NVCC_BIN='g++-13'
scaronni commented 2 weeks ago

@eleaver any feedback?

eleaver commented 2 weeks ago

My apologies, Simone. I've urgent family issues to attend atm. Will return to this later.