cuda-samples icon indicating copy to clipboard operation
cuda-samples copied to clipboard

CMake Configuration Fails with OpenMP_CUDA Not Found

Open shw0622 opened this issue 10 months ago • 7 comments

Environment Configuration

Component Version
GPU Model NVIDIA RTX 4070
CUDA Toolkit 12.8
Visual Studio 2022 (17.9.6)
CMake 3.31.0
OS Windows 10

Reproduction Steps

git clone https://github.com/NVIDIA/cuda-samples
cd cuda-samples
mkdir build
cd build
cmake .. -G "Visual Studio 17 2022" -A x64
Error LogCMake Error at D:/CMake/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
  Could NOT find OpenMP_CUDA (missing: OpenMP_CUDA_FLAGS OpenMP_CUDA_LIB_NAMES)
Call Stack:
  FindOpenMP.cmake:616 (find_package_handle_standard_args)
  Samples/0_Introduction/UnifiedMemoryStreams/CMakeLists.txt:21 (find_package)

shw0622 avatar Feb 21 '25 07:02 shw0622

This looks like it might be a CMake issue. Support for the CUDA language in FindOpenMP was added in CMake 3.31 so it's pretty new, there may be fixes needed for Visual Studio.

Thanks for the report, we're looking into it.

rwarmstr avatar Feb 21 '25 18:02 rwarmstr

For now, if you don't actually need to build that sample, you can comment out the corresponding add_subdirectory command in the CMakeLists.txt in the parent folder

rwarmstr avatar Feb 21 '25 19:02 rwarmstr

Thanks, the fix works fine, the other 181 sample projects are generated .

Peter-RealiSim avatar Mar 08 '25 13:03 Peter-RealiSim

CMake: cmake version 4.0.1 cuda-samples\Samples\0_Introduction\UnifiedMemoryStreams\CMakeLists.txt

# Source file
# find_package(OpenMP REQUIRED)
find_package(OpenMP REQUIRED C CXX)

usopp333 avatar Apr 18 '25 04:04 usopp333

also happened using cmake 4.1.1, arch linux. fixed it changing the file Samples/0_Introduction/UnifiedMemoryStreams/CMakeLists.txt:32 (find_package):

find_package(OpenMP REQUIRED C CXX)

moraisaugusto avatar Sep 22 '25 18:09 moraisaugusto

I tried @moraisaugusto suggestion on the previous comment, but that didn't work for me.

What worked for me was simply checking out the tag corresponding to my CUDA version, without modifying any file:

git checkout v12.9

I'm using Manjaro with CUDA 12.9.1 and CMake 4.1.1. My laptop has a NVIDIA RTX 4070 GPU.

antoniomedeirosdev avatar Oct 26 '25 16:10 antoniomedeirosdev