CMake and CUDA 11.7

Hi,

I’m trying to move older code to new environment.

I’m having a hard time figuring out what the latest working way to use CMake and CUDA is

My project is

MainProject

Subproject

(cuda kernels and cpp)

FindCudaToolkit?

Findpackage(CUDA)?

But cuda_add_library() seems deprecated?

It’s a bit frustrating.

Anyone have an up-to-the-latest template?

This is on Windows fwiw.

Thanks

Rick Frank

You should be able to enable_language(CUDA) (or pass it to project(LANGUAGES)) and just use CUDA files natively with new enough CMake.

Cc: @robert.maynard

1 Like

I’m getting “No CUDA toolset found”

Using CMake version 3.24.0-rc1

Using cmake policy CMP0104 NEW

Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.

The CXX compiler identification is MSVC 19.29.30145.0

The C compiler identification is MSVC 19.29.30145.0

Detecting CXX compiler ABI info

Detecting CXX compiler ABI info - done

Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped

Detecting CXX compile features

Detecting CXX compile features - done

Detecting C compiler ABI info

Detecting C compiler ABI info - done

Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped

Detecting C compile features

Detecting C compile features - done

CMake Error at C:/Program Files/CMake/share/cmake-3.24/Modules/CMakeDetermineCompilerId.cmake:491 (message):
No CUDA toolset found.
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.24/Modules/CMakeDetermineCompilerId.cmake:6 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
C:/Program Files/CMake/share/cmake-3.24/Modules/CMakeDetermineCompilerId.cmake:48 (__determine_compiler_id_test)
C:/Program Files/CMake/share/cmake-3.24/Modules/CMakeDetermineCUDACompiler.cmake:307 (CMAKE_DETERMINE_COMPILER_ID)
CMakeLists.txt:26 (enable_language)

with

I created a “nothing” project. The CMakeLists.txt file is

cmake_minimum_required(VERSION 3.18)

project(testcuda)

enable_language(CUDA)

set(SOURCE

 main.cpp

)

add_executable(testcuda ${SOURCE})

target_link_libraries(testcuda

)

and I get the same error

Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.

The C compiler identification is MSVC 19.29.30145.0

The CXX compiler identification is MSVC 19.29.30145.0

Detecting C compiler ABI info

Detecting C compiler ABI info - done

Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped

Detecting C compile features

Detecting C compile features - done

Detecting CXX compiler ABI info

Detecting CXX compiler ABI info - done

Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped

Detecting CXX compile features

Detecting CXX compile features - done

CMake Error at C:/Program Files/CMake/share/cmake-3.24/Modules/CMakeDetermineCompilerId.cmake:491 (message):
No CUDA toolset found.
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.24/Modules/CMakeDetermineCompilerId.cmake:6 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
C:/Program Files/CMake/share/cmake-3.24/Modules/CMakeDetermineCompilerId.cmake:48 (__determine_compiler_id_test)
C:/Program Files/CMake/share/cmake-3.24/Modules/CMakeDetermineCUDACompiler.cmake:307 (CMAKE_DETERMINE_COMPILER_ID)
CMakeLists.txt:6 (enable_language)

Configuring incomplete, errors occurred!

See also “D:/Projects/TestCuda.bin/CMakeFiles/CMakeOutput.log”.

You’ll need to make the CUDA toolset available in your environment. Perhaps it needs ot be installed for VS 2019?

It is. I

just found an older project that uses the deprecated cmake commands and it works fine.

I wonder if the CMake developers want to look into this with 11.7? The old(er) commands seem to find everything ok.

enable_language(CUDA) seems to fail. Unless I’m using the new commands incorrectly, but I can’t find any examples (say on github) that use the new commands. Tough to be on the bleeding edge…

The one thing that would really improve the CMake Documentation would be to have some examples. The current documentation is rather abstract, and hard for mortals like myself to understand…

when I look at cppreference.com the first thing I do is scroll down to the examples…

-----Update---------
Ouch. I take that back. I deleted the cache and I get No Cuda Toolkit found for that project that used to work fine,

I’ve uninstalled and reinstalled 11.7 and still a problem.

Will now try going backwards in time on CMake…

oof.

—UPDATE UPDATE—

This appears to be an NVidia Installer bug. Although I’m not certain if this is the “correct” solution, but the solution posted here:

Fixes my problem. I hope this helps some other poor soul…!