Bulding 2.82 (master) with Optix fails

A very weird build error. Building with CUDA works fine, but building with Optix gives a very strange error.

-- Found OptiX: /home/dgsantana/blender_git/lib/linux_x86_64/optix/include  
CMake Warning at intern/cycles/kernel/CMakeLists.txt:368 (message):
  CUDA version .  detected, build may succeed but only CUDA 10.1 is
  officially supported


CMake Error at intern/cycles/kernel/CMakeLists.txt:475 (elseif):
  given arguments:

    "sm_30" "MATCHES" "sm_7." "AND" "LESS" "100"

But running nvcc return fine:

Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243

Any help would be appreciated ;).

The issue seems to be with the regex that extracts the CUDA major and minor version.

string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR "${NVCC_OUT}")
string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR "${NVCC_OUT}")

If I’m not mistaken the double slash in the regex is wrong. It should try to match the literal . not a backslash.

This is nonsense, the backslash is treated as an escape character. See my reply below.

Thanks Robert, will have a look again later (i’m on windows now), but I did try to use a hardcoded version, but got another error with the ptx compilation. The weird thing, is that last week it was building and running just fine with Optix.

I spoke too soon and was mistaken. CMake uses the backslash as an escape character (even within regex) and therefore escaping the backslash is necessary in order to have a single backslash in the actual regex that is executed.

I would’ve been surprised if that was the actual source of the error since others would have experienced the same issue as well. Especially since the commit that introduced it is from April.

While cuda sets an environment var to help locate it, the optiX sdk does not, and may need a little help, be sure that the OPTIX_ROOT_DIR cmake variable is set to the install path of the optix sdk.

I did set that in the environment Found OptiX: /home/dgsantana/blender_git/lib/linux_x86_64/optix/include.
What I did diferent was that I use make deps and use those deps instead of the one you get with install_deps.sh.

no idea then, i’d start sprinkling some debug prints here and there, starting with

message("NVCC = ${CUDA_NVCC_EXECUTABLE}")
message("NVCC_OUT = ${NVCC_OUT}")

near those regexes see what is happening there.

I will do, as soon as I boot up into Ubuntu again, need to finish some work first.
Thanks any way @LazyDodo ;).
I’m moving my company production stuff to linux, mostly due to speed, even Resolve is faster there, that’s why I’m building master there also.

Ok after some more tests, it seems that either the find_package(CUDA) is not ran or the variables are cleared. The only place where I found the find_package(CUDA), was on the NOT WITH_CUDA_DYNLOAD. I was building the make ninja full, but it seems the full doesn’t add all the necessary WITH’s…
So for anyone with problems building OPTIX, here is a simple shell script.

OPTIX_ROOT_DIR=~/blender_git/lib/linux_x86_64/optix
BUILD_CMAKE_ARGS="-DWITH_CYCLES_CUDA_BINARIES=ON -DWITH_CYCLES_DEVICE_OPTIX=ON" make update ninja full