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.75k stars 407 forks source link

GPU rendering not working with MSCV Version 14.40 and newer #429

Open Wil-Lee opened 1 month ago

Wil-Lee commented 1 month ago

It seems like MSVC >=14.40 breaks the framework somehow, so that the GPU rendering is not working anymore. MSCV >= 14.40 only supports CUDA 12.4+. Trying to render the killeroo-simple scene (pbrt tests scenes) results in an error: Wavefront rendering failed at sample 0. Debug with "--debugstart 0". Trying to build the framework with Cuda 12.5 results in a compile error like in https://github.com/mmp/pbrt-v4/issues/427.

I asked three other developers to try executing the GPU renderer.

  1. RTX 4000 Series, Cuda 12.3, Optix 8.0.0, MSVC 14.38 -> renders without any problems.
  2. GTX 1060, Cuda 12.4, Optix 8.0.0, MSVC 14.39 -> renders without any problems.
  3. RTX 3000 Series, Cuda 12.4, Optix 8.0.0, MSVC 14.40 -> renderer crashes at first sample
  4. RTX 2080, Cuda 12.4, Opitx 8.0.0, MSVC 14.40 -> renderer crashes at first sample (my system)
  5. RTX 2080, Cuda 12.5, Opitx 8.0.0, MSVC 14.40 -> compiler crashes only when cuda was detected

I tried MSVC 14.29 and the gpu renderer works (most of the time, still some crashes).

A workaround for this with Visual Studio 2022 and Windows 10:

  1. Open Visual Studio Installer
  2. Click "Change"-Button
  3. Click on "Components"
  4. Look for MSVC v143 - VS 2022 C++ x64/x86-Buildtools (v14.39 -17.9) and install it
  5. Open CMD and cd to: \<Your Visual Studio installation Path>\Microsoft Visual Studio\2022\<your edition>\VC\Auxiliary\Build
  6. execute: vcvarall.bat x64 -vcvars_ver=14.39 to set the standard compiler version for Visual Studio
  7. Reinstall Cuda 12.4 (I guess you can somehow reconfig Visual Studio so that CUDA gets detected, but this is the easiest way at least for me)
  8. Rebuild the project with cmake

Everything should be working with that.