mmp / pbrt-v4

Source code to pbrt, the ray tracer described in the forthcoming 4th edition of the "Physically Based Rendering: From Theory to Implementation" book.
https://pbrt.org
Apache License 2.0
2.8k stars 429 forks source link

GPU Build issue: cuda not found #373

Closed YouthImagination closed 9 months ago

YouthImagination commented 1 year ago

When I build with cmake-gui or cmd. cmake can't find cuda compiler Automatically. And cmake give output log

Looking for a CUDA compiler
Looking for a CUDA compiler - NOTFOUND
CUDA not found

I alredy add cuda path to enviroment, set CMAKE_CUDA_COMPILER with C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\bin\nvcc.exe and set PBRT_OPTIX7_PATH value with D:/software/NVIDIA Corporation/OptiX SDK 7.3.0 Then cmake give log

CMake Error at D:/software/CMake/share/cmake-3.23/Modules/CMakeDetermineCUDACompiler.cmake:633 (message):
  Failed to detect a default CUDA architecture.

  Compiler output:

Call Stack (most recent call first):
  CMakeLists.txt:191 (enable_language)

Configuring incomplete, errors occurred!
See also "D:/Codes/pbrt-v4/build/CMakeFiles/CMakeOutput.log".
See also "D:/Codes/pbrt-v4/build/CMakeFiles/CMakeError.log".

My display card is Nvidia GeForce GTX1660Ti so I specify CMAKE_CUDA_ARCHITECTURES to sm_75. cmake error is

Including Win32 support
Unable to find -lprofiler
Found CUDA: 11.6.124
The CUDA compiler identification is unknown
CMake Error at D:/software/CMake/share/cmake-3.23/Modules/CMakeDetermineCUDACompiler.cmake:654 (message):
  The CMAKE_CUDA_ARCHITECTURES:

    75

  do not all work with this compiler.  Try:

  instead.
Call Stack (most recent call first):
  CMakeLists.txt:191 (enable_language)

Configuring incomplete, errors occurred!
See also "D:/Codes/pbrt-v4/build/CMakeFiles/CMakeOutput.log".
See also "D:/Codes/pbrt-v4/build/CMakeFiles/CMakeError.log".

I try another arch, but it didn't work. How could I deal with this.

YouthImagination commented 1 year ago

I think I install cuda visual studio integration 11.6 correctly. Just in case, I re-install cuda again, and install all component. But I get same problem CUDA not found

mmp commented 1 year ago

Try setting CMAKE_CUDA_ARCHITECTURES to just 75, as per https://github.com/mmp/pbrt-v4/issues/374#issuecomment-1652419182

YouthImagination commented 1 year ago

Thanks for reply! I try to set CMAKE_CUDA_ARCHITECTURES just to 75 and change cuda version to 12.1. But I got same error, it seems not work for me

Found CUDA: 12.1.105
The CUDA compiler identification is unknown
CMake Error at D:/software/CMake/share/cmake-3.23/Modules/CMakeDetermineCUDACompiler.cmake:654 (message):
  The CMAKE_CUDA_ARCHITECTURES:

    75

  do not all work with this compiler.  Try:

  instead.
Call Stack (most recent call first):
  CMakeLists.txt:191 (enable_language)

Configuring incomplete, errors occurred!
See also "D:/Codes/pbrt-v4/build/CMakeFiles/CMakeOutput.log".
See also "D:/Codes/pbrt-v4/build/CMakeFiles/CMakeError.log".

My Cmake version is 3.23.0-rc5. I set CMAKE_CUDA_COMPILER to C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/bin/nvcc.exe. I am not sure if it is correnct.