Coder Social home page Coder Social logo

CMake and compile error about pbrt-v4 HOT 12 CLOSED

mmp avatar mmp commented on June 17, 2024
CMake and compile error

from pbrt-v4.

Comments (12)

pierremoreau avatar pierremoreau commented on June 17, 2024

It looks like std::byte was added to GCC in 7.1. Apart from one paper, none of the changes to the standard library in C++17 are present in GCC 5.4, which is not too surprising given it was released in June 2016. I would have expected CMake to complain about the compiler not supporting C++17.
Could you please try adding the following, right after this line for example

target_compile_features(pbrt_lib PUBLIC cxx_std_17)

I'm curious whether it will work better in getting CMake to complain about the compiler.

Regarding the CUDA_ARCHITECTURES warning, you could add the following towards the beginning of the CMakeLists.txt to silence it:

cmake_policy(SET CMP0104 OLD)

Since the architecture flags are manually added to the command lines that need them, it is not a problem if that variable is empty.

from pbrt-v4.

UHFT avatar UHFT commented on June 17, 2024

Thanks @pierremoreau.

I've added both lines but still got error.

$ make
Scanning dependencies of target rgb2spec_opt
[ 0%] Building CXX object CMakeFiles/rgb2spec_opt.dir/src/pbrt/cmd/rgb2spec_opt.cpp.o
[ 1%] Linking CXX executable rgb2spec_opt
[ 1%] Built target rgb2spec_opt
Scanning dependencies of target soac
[ 1%] Building CXX object CMakeFiles/soac.dir/src/pbrt/cmd/soac.cpp.o
[ 1%] Linking CXX executable soac
[ 1%] Built target soac
Scanning dependencies of target pbrt_soa_generated
[ 1%] Generating pbrt_soa.h
[ 1%] Built target pbrt_soa_generated
[ 2%] Generating rgbspectrum_srgb.cpp
Optimizing sRGB spectra...
[ 2%] Generating rgbspectrum_dci_p3.cpp
Optimizing DCI_P3 spectra...
[ 2%] Generating rgbspectrum_rec2020.cpp
Optimizing REC2020 spectra...
[ 2%] Generating rgbspectrum_aces.cpp
Optimizing ACES2065_1 spectra...
Scanning dependencies of target pbrt_lib
[ 2%] Building CXX object CMakeFiles/pbrt_lib.dir/rgbspectrum_srgb.cpp.o
In file included from /user/inyu/work/pbrt-v4/build/rgbspectrum_srgb.cpp:1:0:
/user/inyu/work/pbrt-v4/src/pbrt/pbrt.h:163:52: error: ‘byte’ is not a member of ‘std’
using Allocator = pstd::pmr::polymorphic_allocatorstd::byte;
^
/user/work/pbrt-v4/src/pbrt/pbrt.h:163:52: error: ‘byte’ is not a member of ‘std’
/user/work/pbrt-v4/src/pbrt/pbrt.h:163:61: error: template argument 1 is invalid
using Allocator = pstd::pmr::polymorphic_allocatorstd::byte;
^
CMakeFiles/pbrt_lib.dir/build.make:102: recipe for target 'CMakeFiles/pbrt_lib.dir/rgbspectrum_srgb.cpp.o' failed
make[2]: *** [CMakeFiles/pbrt_lib.dir/rgbspectrum_srgb.cpp.o] Error 1
CMakeFiles/Makefile2:763: recipe for target 'CMakeFiles/pbrt_lib.dir/all' failed
make[1]: *** [CMakeFiles/pbrt_lib.dir/all] Error 2
Makefile:159: recipe for target 'all' failed
make: *** [all] Error 2

from pbrt-v4.

pierremoreau avatar pierremoreau commented on June 17, 2024

Ah, I guess it still does not complain about the compiler because it does support the flag even though it does not support all of C++17 features. I am not sure how this could be improved, besides testing all the used features individually or explicitly testing the compiler version; the latter would be easier to do but might result in some compiler being rejected despite supporting the required features. What do you think about it, @mmp?

@UHFT The bottom line is that you need to update your compiler: GCC 7.1 is the first version that has std::byte, but you'll probably want at least GCC 8.1 or possibly 9.1 to be sure to have all C++17 features supported by the compiler.

from pbrt-v4.

UHFT avatar UHFT commented on June 17, 2024

@pierremoreau
Thanks. I've upgraded to GCC g++9.3 and still got some errors.

~/work/pbrt-v4/build$ cmake -DPBRT_OPTIX7_PATH=/opt/optix/SDK/ ../../pbrt-v4/
-- The CXX compiler identification is GNU 9.3.0
-- The C compiler identification is GNU 9.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Setting build type to 'Release' as none was specified.
-- Found Git: /usr/bin/git (found version "2.7.4")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8")
-- Configure ILMBASE Version: 2.5.3 Lib API: 25.0.2
CMake Warning (dev) at src/ext/openexr/IlmBase/config/IlmBaseSetup.cmake:56 (option):
Policy CMP0077 is not set: option() honors normal variables. Run "cmake
--help-policy CMP0077" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.

For compatibility with older versions of CMake, option is clearing the
normal variable 'BUILD_SHARED_LIBS'.
Call Stack (most recent call first):
src/ext/openexr/IlmBase/CMakeLists.txt:35 (include)
This warning is for project developers. Use -Wno-dev to suppress it.

-- Looking for include file ucontext.h
-- Looking for include file ucontext.h - found
-- Performing Test ILMBASE_HAVE_CONTROL_REGISTER_SUPPORT
-- Performing Test ILMBASE_HAVE_CONTROL_REGISTER_SUPPORT - Success
-- Looking for include file semaphore.h
-- Looking for include file semaphore.h - found
-- Looking for sem_init in pthread
-- Looking for sem_init in pthread - found
-- Configure OpenEXR Version: 2.5.3 Lib API: 25.0.2
-- Performing Test OPENEXR_IMF_HAVE_SYSCONF_NPROCESSORS_ONLN
-- Performing Test OPENEXR_IMF_HAVE_SYSCONF_NPROCESSORS_ONLN - Success
-- Performing Test OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
-- Performing Test OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX - Success
-- clang-format not found.
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Unable to find -lprofiler
-- Looking for a CUDA compiler
-- Looking for a CUDA compiler - /usr/local/cuda-11.1/bin/nvcc
-- Found CUDA: /usr/local/cuda-11.1 (found version "11.1")
-- Found CUDA: 11.1
-- The CUDA compiler identification is NVIDIA 11.1.74
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: /usr/local/cuda-11.1/bin/nvcc - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- CUDA Architecture: sm_61
-- Performing Test COMPILER_SUPPORTS_MARCH_NATIVE
-- Performing Test COMPILER_SUPPORTS_MARCH_NATIVE - Success
-- Performing Test HAVE_MMAP
-- Performing Test HAVE_MMAP - Success
-- Performing Test HAS_INTRIN_H
-- Performing Test HAS_INTRIN_H - Failed
-- Performing Test HAVE_DECLSPEC_NOINLINE
-- Performing Test HAVE_DECLSPEC_NOINLINE - Failed
-- Performing Test HAVE_ATTRIBUTE_NOINLINE
-- Performing Test HAVE_ATTRIBUTE_NOINLINE - Success
-- Performing Test HAVE__ALIGNED_MALLOC
-- Performing Test HAVE__ALIGNED_MALLOC - Failed
-- Performing Test HAVE_POSIX_MEMALIGN
-- Performing Test HAVE_POSIX_MEMALIGN - Success
-- Performing Test INT64_IS_OWN_TYPE
-- Performing Test INT64_IS_OWN_TYPE - Failed
-- Configuring done
-- Generating done
-- Build files have been written to: /user/inyu/work/pbrt-v4/build
~/work/pbrt-v4/build$ make
Scanning dependencies of target double-conversion
[ 0%] Building CXX object src/ext/double-conversion/CMakeFiles/double-conversion.dir/double-conversion/bignum.cc.o
[ 0%] Building CXX object src/ext/double-conversion/CMakeFiles/double-conversion.dir/double-conversion/bignum-dtoa.cc.o
[ 1%] Building CXX object src/ext/double-conversion/CMakeFiles/double-conversion.dir/double-conversion/cached-powers.cc.o
[ 1%] Building CXX object src/ext/double-conversion/CMakeFiles/double-conversion.dir/double-conversion/double-to-string.cc.o
[ 1%] Building CXX object src/ext/double-conversion/CMakeFiles/double-conversion.dir/double-conversion/fast-dtoa.cc.o
[ 1%] Building CXX object src/ext/double-conversion/CMakeFiles/double-conversion.dir/double-conversion/fixed-dtoa.cc.o
[ 2%] Building CXX object src/ext/double-conversion/CMakeFiles/double-conversion.dir/double-conversion/string-to-double.cc.o
[ 2%] Building CXX object src/ext/double-conversion/CMakeFiles/double-conversion.dir/double-conversion/strtod.cc.o
[ 2%] Linking CXX static library libdouble-conversion.a
[ 2%] Built target double-conversion
Scanning dependencies of target soac
[ 2%] Building CXX object CMakeFiles/soac.dir/src/pbrt/cmd/soac.cpp.o
[ 2%] Linking CXX executable soac
[ 2%] Built target soac
Scanning dependencies of target pbrt_soa_generated
[ 2%] Generating pbrt_soa.h
[ 2%] Generating gpu_workitems_soa.h
[ 2%] Built target pbrt_soa_generated
make[2]: *** No rule to make target 'CMakeFiles/optix.cu.dir/src/pbrt/gpu/optix.ptx', needed by 'src/pbrt/gpu/optix.cu.ptx_embedded.c'. Stop.
CMakeFiles/Makefile2:774: recipe for target 'CMakeFiles/pbrt_embedded_ptx_lib.dir/all' failed
make[1]: *** [CMakeFiles/pbrt_embedded_ptx_lib.dir/all] Error 2
Makefile:159: recipe for target 'all' failed
make: *** [all] Error 2

from pbrt-v4.

pierremoreau avatar pierremoreau commented on June 17, 2024

Weird… I'll need to reproduce it locally to investigate what is going on there, cause there is a rule to generate that ptx file.

@UHFT Could you please run a find . -iname "*.ptx", both inside the source and build folder, and paste the results here (assuming the results are not too large)? I wonder if the ptx might have been created somewhere else, but that would be very strange given we retrieve the path directly from the library itself which is supposed to create the file.

from pbrt-v4.

UHFT avatar UHFT commented on June 17, 2024

not much information found.

~/work/pbrt-v4$ find . -iname "*.ptx"
./build/CMakeFiles/3.18.3/CompilerIdCUDA/tmp/CMakeCUDACompilerId.ptx
./build/CMakeFiles/CheckCUDA/CMakeFiles/3.18.3/CompilerIdCUDA/tmp/CMakeCUDACompilerId.ptx

~/work/pbrt-v4$ cat ./build/CMakeFiles/3.18.3/CompilerIdCUDA/tmp/CMakeCUDACompilerId.ptx
//
// Generated by NVIDIA NVVM Compiler
//
// Compiler Build ID: CL-29069683
// Cuda compilation tools, release 11.1, V11.1.74
// Based on LLVM 3.4svn
//

.version 7.1
.target sm_52
.address_size 64

$ cat ./build/CMakeFiles/CheckCUDA/CMakeFiles/3.18.3/CompilerIdCUDA/tmp/CMakeCUDACompilerId.ptx
//
// Generated by NVIDIA NVVM Compiler
//
// Compiler Build ID: CL-29069683
// Cuda compilation tools, release 11.1, V11.1.74
// Based on LLVM 3.4svn
//

.version 7.1
.target sm_52
.address_size 64

from pbrt-v4.

pierremoreau avatar pierremoreau commented on June 17, 2024

I see, thanks. So just the ptx files that CMake uses to identify the compiler.

from pbrt-v4.

UHFT avatar UHFT commented on June 17, 2024

by the way, I set these environment variables as guided.

$ export PATH=$PATH:/usr/local/cuda-11.1/bin
$ export CUDADIR=/usr/local/cuda-11.1
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.1/lib64

$ export PATH=$PATH:/opt/optix/SDK/build/bin
$ export PBRT_OPTIX7_PATH=/opt/optix/SDK/
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/optix/SDK/build/lib

$ cmake -DPBRT_OPTIX7_PATH=/opt/optix/SDK/ ../../pbrt-v4/

$ make

from pbrt-v4.

pierremoreau avatar pierremoreau commented on June 17, 2024

Could you please try whether it builds properly when using #57?

from pbrt-v4.

UHFT avatar UHFT commented on June 17, 2024

@pierremoreau

Finally. It works. Thanks.
It is a great performance boost. 1212 seconds (CPU) to 63 seconds(GPU)

However, it only uses one GPU out of two available. Is there any way to support multi-GPU ??
Here is nvidia-smi result

$ nvidia-smi
Fri Oct  9 09:11:10 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 455.23.05    Driver Version: 455.23.05    CUDA Version: 11.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GTX 1080    Off  | 00000000:02:00.0 Off |                  N/A |
| 38%   60C    P2   116W / 180W |   1703MiB /  8111MiB |    100%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
|   1  GeForce GTX 1080    Off  | 00000000:04:00.0 Off |                  N/A |
| 28%   40C    P8     7W / 180W |      2MiB /  8119MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

from pbrt-v4.

pierremoreau avatar pierremoreau commented on June 17, 2024

Awesome!

There is no multi-GPU support AFAIK, and I have no idea whether it is on @mmp's roadmap.

from pbrt-v4.

mmp avatar mmp commented on June 17, 2024

Another one fixed by #57--yaay!

I haven't looked into multi-GPU and so it isn't really on the roadmap at this point--it might be nice to add at some point, but it's not on the critical path for finishing the book...

from pbrt-v4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.