Cmake cannot find CUDA when installed in local directory

I have a question regarding cmake and cuda. I installed CUDA 23.1 and I load the module file in my .bashrc file
module load ~/Install_nvhpc/version_23.1/modulefiles/nvhpc/23.1
When i check the nvcc --version and which nvcc, i get correct results. Now I made one .cu file and one main.cpp file. I used cmake (version 3.19.8) with the following CMakeLists.txt

cmake_minimum_required( VERSION 3.3.2)

# set compilers
set (CMAKE_CXX_COMPILER 		nvc++	)
set (CMAKE_C_COMPILER 			nvc		)
set (PROJECT "dummy")
set(CUDA_TOOLKIT_ROOT_DIR ~/Install_nvhpc/version_23.1/Linux_x86_64/23.1/cuda)



file(GLOB dummy_executable_srcs
#     "*.h"
#     "*.cpp"
#     "*.cuh"

add_executable(dummy ${dummy_executable_srcs} main.cpp)
target_compile_options(dummy PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:--gpu-architecture=sm_86>)

However, when I run cmake …, I get the following output.

-- The C compiler identification is PGI 23.1.0
-- The CXX compiler identification is PGI 23.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/Ism/Install_nvhpc/version_23.1/Linux_x86_64/23.1/compilers/bin/nvc - 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: /home/Ism/Install_nvhpc/version_23.1/Linux_x86_64/23.1/compilers/bin/nvc++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for a CUDA compiler
-- Looking for a CUDA compiler - NOTFOUND
-- Configuring done
-- Generating done

Subsequent compilation generates catastrophic error about cuda.h

Similarly, when i try to build Thrust using
I get the below error

CMake Error at /home/Ism/Install_nvhpc/cmake/3.19.8/share/cmake-3.19/Modules/CMakeDetermineCUDACompiler.cmake:187 (message):
  Couldn't find CUDA library root.

I guess it has something to do with non-standard installation location of cmake and HPC SDK. I want to use CUB library in Thrust but I am unable to resolve this cmake issue. Please help me.

I figured out the problem. The CUDA driver was not updated while I installed a recent SDK. The solution is to either update the CUDA driver or use older SDK. Therefore, I installed an older SDK, compatible with my CUDA driver and solved the problem.

Thank You

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.