spcl / open-earth-compiler

development repository for the open earth compiler
https://arxiv.org/abs/2005.13014
Other
76 stars 14 forks source link

Compilation fails when CUDA is not in the usual path #49

Open cbouilla opened 3 months ago

cbouilla commented 3 months ago

I tried to compile openearth following the steps of the README, but this fails with the following error:

[ 77%] Building CXX object lib/Conversion/LoopsToGPU/CMakeFiles/obj.GPUToKernelAndRuntimeCalls.dir/ConvertKernelFuncToCubin.cpp.o
.../open-earth-compiler/lib/Conversion/LoopsToGPU/ConvertKernelFuncToCubin.cpp:16:10: fatal error: cuda.h: No such file or directory
   16 | #include "cuda.h"
      |          ^~~~~~~~

This happens in a computing center that uses "modules" (implemented with spack).

Before running CMake, I "activated" CUDA by running module load cuda.

CMake correctly found the CUDA compiler:

-- Looking for a CUDA compiler - /grid5000/spack/v1/opt/spack/linux-debian11-x86_64_v2/gcc-10.4.0/cuda-12.0.0-g2atnxvq3akekpc6otev56c2rqzmnr7y/bin/nvcc
-- The CUDA compiler identification is NVIDIA 12.0.76

But It did not correctly set the path of the include files when invoking the compiler. I could compile openearth by taking these steps:

  1. Tell CMake to generate Unix Makefiles instead of a Ninja build file
  2. Run make (it fails with the above error)
  3. Compile the offending file by running the right command manually and adding a -I option to gcc with the right paths of the include files (in my case: /grid5000/spack/v1/opt/spack/linux-debian11-x86_64_v2/gcc-10.4.0/cuda-12.0.0-g2atnxvq3akekpc6otev56c2rqzmnr7y/include)
  4. Run make again to finish compiling
gysit commented 3 months ago

Thanks for reporting the issue and the possible workaround.

The intent was that the following line adds the CUDA headers to the target: https://github.com/spcl/open-earth-compiler/blob/1e48dee6a1a021bc11d6621432450406349b3733/lib/Conversion/LoopsToGPU/CMakeLists.txt#L34

It may very well be that this does not work anymore on modern systems.