PBRT_OPTIX7_PATH set right, but GPU compilation failed, why?

hi, recently I am working on PBRT-v4, I want to test how fast it is to leverage nvidia’s optix to accelerate raytracing, I installed cuda11 and optix7, but when I build PBRT-v4 , it throws an error that PBRT_OPTIX_PATH is not set, GPU compilation disabled, but I had set the this environment value in the system, why it still throws this error? in this case I am not able to use GPU in PBRT-v4 to render an image!

Unable to find -lprofiler
Found CUDA: 11.4.100
CMake Warning at CMakeLists.txt:176 (message):
Found CUDA but PBRT_OPTIX7_PATH is not set. Disabling GPU compilation.

You misunderstood the PBRT-v4 instructions in its README.md.

It says:
It is necessary to manually set the cmake PBRT_OPTIX7_PATH configuration option to point at an OptiX installation.

That is not an environment variable but a CMake variable you can find inside the CMakeLists.txt line 21 where it is set to an empty string.
Put your OptiX installation directory there manually. In CMake, use forward slashes for the directory path.

(I just looked into the pbrt-v4 CMakeLists.txt for the first time. There is no place where an environment variable of this name is read.)

This is not an OptiX issue. Please raise further issues about pbrt-v4 in its github repository. https://github.com/mmp/pbrt-v4/issues

Note that the implementation of OptiX 7 in PBRT is not really an indication of how fast OptiX 7 can be. That PBRT GPU implementation is maximizing code reuse, not runtime performance.

thanks, I had followed your instructions, and it can properly build with gpu, but the --gpu option is still unusable, these are possible reasons, but I don’t know what it means:
CMake Warning (dev) in CMakeLists.txt:
Policy CMP0104 is not set: CMAKE_CUDA_ARCHITECTURES now detected for NVCC,
empty CUDA_ARCHITECTURES not allowed. Run “cmake --help-policy CMP0104”
for policy details. Use the cmake_policy command to set the policy and
suppress this warning.

CUDA_ARCHITECTURES is empty for target “optix.cu”.
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
Policy CMP0104 is not set: CMAKE_CUDA_ARCHITECTURES now detected for NVCC,
empty CUDA_ARCHITECTURES not allowed. Run “cmake --help-policy CMP0104”
for policy details. Use the cmake_policy command to set the policy and
suppress this warning.

CUDA_ARCHITECTURES is empty for target “optix.cu”.
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
Policy CMP0104 is not set: CMAKE_CUDA_ARCHITECTURES now detected for NVCC,
empty CUDA_ARCHITECTURES not allowed. Run “cmake --help-policy CMP0104”
for policy details. Use the cmake_policy command to set the policy and
suppress this warning.

CUDA_ARCHITECTURES is empty for target “optix.cu”.
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
Policy CMP0104 is not set: CMAKE_CUDA_ARCHITECTURES now detected for NVCC,
empty CUDA_ARCHITECTURES not allowed. Run “cmake --help-policy CMP0104”
for policy details. Use the cmake_policy command to set the policy and
suppress this warning.

CUDA_ARCHITECTURES is empty for target “optix.cu”.
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
Policy CMP0104 is not set: CMAKE_CUDA_ARCHITECTURES now detected for NVCC,
empty CUDA_ARCHITECTURES not allowed. Run “cmake --help-policy CMP0104”
for policy details. Use the cmake_policy command to set the policy and
suppress this warning.

CUDA_ARCHITECTURES is empty for target “pbrt_lib”.
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
Policy CMP0104 is not set: CMAKE_CUDA_ARCHITECTURES now detected for NVCC,
empty CUDA_ARCHITECTURES not allowed. Run “cmake --help-policy CMP0104”
for policy details. Use the cmake_policy command to set the policy and
suppress this warning.

CUDA_ARCHITECTURES is empty for target “pbrt_lib”.
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
Policy CMP0104 is not set: CMAKE_CUDA_ARCHITECTURES now detected for NVCC,
empty CUDA_ARCHITECTURES not allowed. Run “cmake --help-policy CMP0104”
for policy details. Use the cmake_policy command to set the policy and
suppress this warning.

CUDA_ARCHITECTURES is empty for target “pbrt_lib”.
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
Policy CMP0104 is not set: CMAKE_CUDA_ARCHITECTURES now detected for NVCC,
empty CUDA_ARCHITECTURES not allowed. Run “cmake --help-policy CMP0104”
for policy details. Use the cmake_policy command to set the policy and
suppress this warning.

CUDA_ARCHITECTURES is empty for target “pbrt_lib”.
This warning is for project developers. Use -Wno-dev to suppress it.

Please follow the README.md instructions again.
https://github.com/mmp/pbrt-v4#using-pbrt-on-the-gpu

That sounds as if you would need to set the CMake variable PBRT_GPU_SHADER_MODEL to the compute capability of your installed GPU.

You’ll find that this CMake variable is set to an empty string one line below the one you just changed.
You did not provide the necessary system configuration information to say what would belong there.

Search for PBRT_GPU_SHADER_MODEL inside all files of the repository. (That is all I’m doing here.)
I see it inside the README.md, the CMakeLists.txt and some ci-gpu.yml.
(No idea if the latter is used, but it contains a hardcoded sm_80 which will only work for Ampere GPUs.

The CMakeLists.txt tries to detect the compute capability, by building some checkcuda.cu source. Maybe that failed on your configuration? This should not be executed when you set the SM versions manually.

If that doesn’t help, maybe your CMake version is too new? The strings “CMAKE_CUDA_ARCHITECTURES” or “CUDA_ARCHITECTURES” don’t appear inside the pbrt-v4. This is something from CMake.

Anyway, this is all PBRT build environment related which does not belong on this developer forum but here:
https://github.com/mmp/pbrt-v4/issues

thanks, I had posted it on github but no reply, again I post my specifications here:
win10 home x64, rtx3070laptop, cmake 3.21.1, vs2019
set (PBRT_OPTIX7_PATH “D:/ProgramData/NVIDIA Corporation/OptiX SDK 7.3.0” CACHE PATH “Path to OptiX 7 SDK”)
set (PBRT_GPU_SHADER_MODEL “sm_80” CACHE STRING “sm_80”)
this is what I did, but it still can’t use --gpu

Maybe because RTX 3070 is sm_86?
https://en.wikipedia.org/wiki/CUDA

unfortunately I test sm_86, it doesn’t work as well, I will switch to ubuntu20.04 to rebuild it!

Well, there was also the idea to use an older CMake if the newest one isn’t working.
The CMakeLists.txt requires 3.12 and newer: cmake_minimum_required (VERSION 3.12)

I had switched to cmake3.17.1 under ubuntu20.04, with the same command
pbrt --gpu D:\pbrt-v4\pbrt-v4-scenes-master\transparent-machines\frame1266.pbrt
but it stills yeilds
nvcc fatal : Option ‘–ptx (-ptx)’ is not allowed when compiling for multiple GPU architectures
make[2]: *** [CMakeFiles/optix.cu.dir/build.make:82: CMakeFiles/optix.cu.dir/src/pbrt/gpu/optix.ptx] Error 1
make[1]: *** [CMakeFiles/Makefile2:914: CMakeFiles/optix.cu.dir/all] Error 2