ingowald / optix7course

Apache License 2.0
452 stars 80 forks source link

Compile error #20

Closed btilmon closed 3 years ago

btilmon commented 3 years ago

Thank you for this excellent course. I am trying to compile with the following specs:

Ubuntu = 20.04.2 LTS CUDA = 11.3 Driver = 465.19.01 GPU = Geforce GTX 1080 Ti

I get the following error when I run make after cmake ..

nvcc fatal : The version ('9.0') of the host compiler ('clang') is not supported CMake Error at cuda_compile_ptx_1_generated_devicePrograms.cu.ptx.Release.cmake:212 (message): Error generating /home/focus/Documents/optix7course/build/example02_pipelineAndRayGen/cuda_compile_ptx_1_generated_devicePrograms.cu.ptx

make[2]: [example02_pipelineAndRayGen/CMakeFiles/ex02_pipelineAndRayGen.dir/build.make:69: example02_pipelineAndRayGen/cuda_compile_ptx_1_generated_devicePrograms.cu.ptx] Error 1 make[1]: [CMakeFiles/Makefile2:445: example02_pipelineAndRayGen/CMakeFiles/ex02_pipelineAndRayGen.dir/all] Error 2 make: *** [Makefile:84: all] Error 2

I get this error for OptiX 5 and 6 releases too even when adjusting CUDA versions to the correct release. Any help is greatly appreciated.

ingowald commented 3 years ago

Hey - it's exactly as the error message tells you - your host compiler is too old: CUDA always works in conjunction with a host compiler (gcc/clang), and if that one is too old it won't work. Newer versions of Linux already have a newer version of gcc installed that'll work just fine; if you are using a linux version that doesn't have a new enough version of gcc/clang, do the following:

a) install the "g++-8" package: apt install g++-8 b) in cmake, set the host compiler to /usr/bin/gcc-8

What's confusing is that you seem to already have a new enough linux : my 20.04 has gcc-9(!) by default (not even gcc-8, let along gcc 7!); and my default clang is version 10!)... yet for some reason your cmake seems to be picking up a version of clang that's older. Did oyu maybe install a older versoin of clang by hand? If so, try setting CUDA_HOST_COMPILER to either /usr/bin/gcc-8 or /usr/bin/gcc-9 by hand.

btilmon commented 3 years ago

This worked! Oddly, it would not accept anything newer than gcc-7, so I did your steps for gcc-7 and it works.