Problems building latest headless CUDA on linux: can't find acceptable g++ version

Hi folks; I’m trying to build the latest master e4932d1167f on linux WSL Ubuntu 18.04, using the recommended CUDA toolkit v10.2.
I want to build headless with CUDA support for Cycles. So in CMakeLists.txt I turn on WITH_CYCLES_CUDA_BINARIES and run make headless (after removing previous build).
The problem I’m having is related to gcc/g++ versions.

If I use gcc/g++ 7.x or 8.x, I get this error during initial config:

CMake Error at build_files/cmake/platform/platform_unix.cmake:42 (message):
  GCC version must be at least 9.3 for precompiled libraries, found 8.4.0

but if I use gcc/g++ 9.x, I get this error instead, during the build:

error: -- unsupported GNU version! gcc versions later than 8 are not supported!

Seems like I can’t win! This doc says to use CUDA toolkit 10.1 or 10.2, “later versions may not work” so I didn’t try 11 yet.

I’ve updated my deps (make update), cleaned out everything I can think of. Anyone doing this successfully and have a recipe for me?

Try building Blender with gcc 9 and CUDA with gcc 8.
For Blender, do the usual version switch to gcc 9. For Cuda, change the gcc version only in its CMakeCache.txt file.

Thanks – I’m not sure exactly which CMakeCache.txt you mean. I can see one failure is when it’s trying to build intern/cycles/kernel/filter_sm_30.cubin for instance.
I believe that’s built using ../build_linux_headless/intern/cycles/kernel/CMakeFiles/cycles_kernel_cuda.dir/build.make but I don’t see a related cache file for that – I’m not a cmake expert at all (though I’ve done CUDA development for a few years); maybe you can walk me through it?

Right now I’ve set gcc-9 as the default using sudo update-alternatives --config gcc.

I picked that from the third link I posted.

I’m guessing there is an entry for path to Cuda compiler in the CMakeCache.txt file in the build folder. If it points to gcc-9, change the path manually to 8.

If doesn’t work, try the second link (last post in that thread) or the fourth one which use symlink
ln -sf /usr/bin/gcc-8 /usr/local/cuda/bin/gcc

1 Like

The symlink should work I think.

Other possible solutions are to set WITH_CYCLES_CUBIN_COMPILER to ON, or to modify CUDA_NVCC_EXECUTABLE and use the -ccbin argument to point to a specific g++ version.

1 Like

The way CUDA_NVCC_EXECUTABLE is set up, you can’t add args to it without causing errors. And WITH_CYCLES_CUBIN_COMPILER gives the same error about gcc version.
But the symlink seems to be working – what a hack, but OK!
Going to try adding Optix next…

qq: is there a build option to see the actual compile/link command lines being executed? A bit hard to debug without those.

It can be seen with Ninja generator by building with ninja -v.