mitsuba2 icon indicating copy to clipboard operation
mitsuba2 copied to clipboard

[🔨 compilation issue] gpu_autodiff compilation error on Windows10, CUDA 11

Open Agent-INF opened this issue 2 years ago • 9 comments

Summary

Hi, I have compilation issues with the following system settings:

  • Platform: Windows 10, CUDA 11.1
  • Compiler: Cmake 3.21.1.0, MSVC 2019
  • Python version: 3.8
  • Mitsuba 2 version: 4e7628c
  • Compiled variants:
    • scalar_rgb
    • scalar_spectral
    • gpu_autodiff_rgb
    • gpu_autodiff_spectral

Steps to reproduce

  1. git clone --recursive https://github.com/mitsuba-renderer/mitsuba2
  2. copy and modify the compiling variants in the mitsuba.conf file
  3. cmake -G "Visual Studio 16 2019" -A x64, gives the following output:
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
-- The C compiler identification is MSVC 19.29.30138.0
-- The CXX compiler identification is MSVC 19.29.30138.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: C:/Users/linjiangke/Miniconda3/python.exe (found version "3.9.5")
-- Found PythonLibs: C:/Users/linjiangke/Miniconda3/libs/Python39.lib
-- Building the following variants of Mitsuba:
--  * scalar_rgb
--  * scalar_spectral
--  * gpu_autodiff_rgb
--  * gpu_autodiff_spectral
-- Mitsuba: building the Python plugin.
-- 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: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.1/bin/nvcc.exe - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- Enoki: building the CUDA backend.
-- Enoki: building the autodiff backend.
-- Enoki: building the Python plugin.
-- pybind11 v2.4.dev4
-- Performing Test HAS_MSVC_GL_LTCG
-- Performing Test HAS_MSVC_GL_LTCG - Success
-- LTO enabled
CMake Deprecation Warning at ext/zlib/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - failed
-- Looking for fseeko
-- Looking for fseeko - not found
-- Looking for unistd.h
-- Looking for unistd.h - not found
CMake Deprecation Warning at ext/libpng/CMakeLists.txt:9 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Found ZLIB: D:/Codes/mitsuba2/ext_build/zlib/$<CONFIGURATION>/zlib.lib
CMake Deprecation Warning at ext/libjpeg/CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Looking for stdlib.h
-- Looking for stdlib.h - found
CMake Deprecation Warning at ext/openexr/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Deprecation Warning at ext/openexr/IlmBase/CMakeLists.txt:2 (CMAKE_MINIMUM_REQUIRED):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Deprecation Warning at ext/openexr/OpenEXR/CMakeLists.txt:1 (CMAKE_MINIMUM_REQUIRED):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Performing Test HAVE_GCC_INLINE_ASM_AVX
-- Performing Test HAVE_GCC_INLINE_ASM_AVX - Failed
-- Performing Test HAVE_SYSCONF_NPROCESSORS_ONLN
-- Performing Test HAVE_SYSCONF_NPROCESSORS_ONLN - Failed
-- The ASM_MASM compiler identification is MSVC
-- Found assembler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/ml64.exe
-- Performing Test SUPPORTS_VOLATILE_FLAG
-- Performing Test SUPPORTS_VOLATILE_FLAG - Success
-- Performing Test __CxxFlag__arch_AVX
-- Performing Test __CxxFlag__arch_AVX - Success
-- Performing Test __CxxFlag__arch_AVX2
-- Performing Test __CxxFlag__arch_AVX2 - Success
-- Performing Test __CxxFlag__std_c__latest
-- Performing Test __CxxFlag__std_c__latest - Success
-- Performing Test __CxxFlag__std_c__14
-- Performing Test __CxxFlag__std_c__14 - Success
-- Mitsuba: using builtin implementation for CPU ray tracing.
-- Mitsuba: using OptiX for GPU ray tracing.
-- Mitsuba: LTO support enabled.
-- Mitsuba: sampling profiler disabled.
CMake Warning at src/cmake/tests.cmake:8 (message):
  Running the tests requires pytest.  Please install it manually:

  $ C:/Users/linjiangke/Miniconda3/python.exe -m pip install pytest
  pytest-xdist
Call Stack (most recent call first):
  src/CMakeLists.txt:39 (include)


-- Found Sphinx: C:/ProgramData/Anaconda3/Scripts/sphinx-build.exe
-- Configuring done
CMake Warning (dev) in ext/enoki/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 "enoki-cuda".
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) in ext/enoki/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 "enoki-cuda".
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) in ext/enoki/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 "enoki-cuda".
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) in ext/enoki/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 "enoki-cuda".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: D:/Codes/mitsuba2
  1. I have tried building the mitsuba.sln within Visual Studio 2019, and run cmake --build . or make in the command line, but all of them give the similar error (I omitted some log here, but you can view the attached log.txt for all output):
...
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xutility(1309): error :
 expected a "(" [D:\Codes\mitsuba2\ext_build\enoki\enoki-cuda.vcxproj]
            detected during instantiation of "void std::_Adl_verify_range(const _Iter &, const _Sentinel &) [with _Iter
  =const char *, _Sentinel=const char *]"
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xlocale(1990): here
...
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xmemory(62): error : ex
pected a "(" [D:\Codes\mitsuba2\ext_build\enoki\enoki-cuda.vcxproj]
            detected during:
              instantiation of "size_t std::_Get_size_of_n<_Ty_size>(size_t) [with _Ty_size=16ULL]"
  (839): here
              instantiation of "_Ty *std::allocator<_Ty>::allocate(size_t) [with _Ty=std::_Container_proxy]"
  (1341): here
              instantiation of "std::_Container_proxy_ptr12<_Alloc>::_Container_proxy_ptr12(_Alloc &, std::_Container_b
  ase12 &) [with _Alloc=std::_Rebind_alloc_t<std::_Rebind_alloc_t<std::allocator<char>, char>, std::_Container_proxy>]"
...
  31 errors detected in the compilation of "D:/Codes/mitsuba2/ext/enoki/src/cuda/common.cu".
...
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xutility(1232): error :
 class "std::iterator_traits<<error-type>>" has no member "reference" [D:\Codes\mitsuba2\ext_build\enoki\enoki-cuda.vcx
proj]
            detected during:
              instantiation of type "std::_Iter_ref_t<<error-type>>"
  (4536): here
              instantiation of "const __nv_bool std::_Fill_memset_is_safe [with _FwdIt=<error-type>, _Ty=std::condition
  al_t<false, std::_List_unchecked_const_iterator<std::_List_val<std::conditional_t<true, std::_List_simple_types<std::
  pair<const uint32_t, enoki::Variable>>, std::_List_iter_types<std::pair<const uint32_t, enoki::Variable>, size_t, ptr
  diff_t, std::pair<const uint32_t, enoki::Variable> *, const std::pair<const uint32_t, enoki::Variable> *, std::pair<c
  onst uint32_t, enoki::Variable> &, const std::pair<const uint32_t, enoki::Variable> &, std::_List_node<std::pair<cons
  t uint32_t, enoki::Variable>, void *> *>>>, std::_Iterator_base0>, std::_List_unchecked_iterator<std::_List_val<std::
  conditional_t<true, std::_List_simple_types<std::pair<const uint32_t, enoki::Variable>>, std::_List_iter_types<std::p
  air<const uint32_t, enoki::Variable>, size_t, ptrdiff_t, std::pair<const uint32_t, enoki::Variable> *, const std::pai
  r<const uint32_t, enoki::Variable> *, std::pair<const uint32_t, enoki::Variable> &, const std::pair<const uint32_t, e
  noki::Variable> &, std::_List_node<std::pair<const uint32_t, enoki::Variable>, void *> *>>>>>, <unnamed>=false]"
  (4583): here
              instantiation of "void std::fill(_FwdIt, _FwdIt, const _Ty &) [with _FwdIt=std::conditional_t<false, std:
  :_List_unchecked_const_iterator<std::_List_val<std::conditional_t<true, std::_List_simple_types<std::pair<const uint3
  2_t, enoki::Variable>>, std::_List_iter_types<std::pair<const uint32_t, enoki::Variable>, size_t, ptrdiff_t, std::pai
  r<const uint32_t, enoki::Variable> *, const std::pair<const uint32_t, enoki::Variable> *, std::pair<const uint32_t, e
  noki::Variable> &, const std::pair<const uint32_t, enoki::Variable> &, std::_List_node<std::pair<const uint32_t, enok
  i::Variable>, void *> *>>>, std::_Iterator_base0>, std::_List_unchecked_iterator<std::_List_val<std::conditional_t<tr
  ue, std::_List_simple_types<std::pair<const uint32_t, enoki::Variable>>, std::_List_iter_types<std::pair<const uint32
  _t, enoki::Variable>, size_t, ptrdiff_t, std::pair<const uint32_t, enoki::Variable> *, const std::pair<const uint32_t
  , enoki::Variable> *, std::pair<const uint32_t, enoki::Variable> &, const std::pair<const uint32_t, enoki::Variable>
  &, std::_List_node<std::pair<const uint32_t, enoki::Variable>, void *> *>>>>> *, _Ty=std::conditional_t<false, std::_
  List_unchecked_const_iterator<std::_List_val<std::conditional_t<true, std::_List_simple_types<std::pair<const uint32_
  t, enoki::Variable>>, std::_List_iter_types<std::pair<const uint32_t, enoki::Variable>, size_t, ptrdiff_t, std::pair<
  const uint32_t, enoki::Variable> *, const std::pair<const uint32_t, enoki::Variable> *, std::pair<const uint32_t, eno
  ki::Variable> &, const std::pair<const uint32_t, enoki::Variable> &, std::_List_node<std::pair<const uint32_t, enoki:
  :Variable>, void *> *>>>, std::_Iterator_base0>, std::_List_unchecked_iterator<std::_List_val<std::conditional_t<true
  , std::_List_simple_types<std::pair<const uint32_t, enoki::Variable>>, std::_List_iter_types<std::pair<const uint32_t
  , enoki::Variable>, size_t, ptrdiff_t, std::pair<const uint32_t, enoki::Variable> *, const std::pair<const uint32_t,
  enoki::Variable> *, std::pair<const uint32_t, enoki::Variable> &, const std::pair<const uint32_t, enoki::Variable> &,
   std::_List_node<std::pair<const uint32_t, enoki::Variable>, void *> *>>>>>]"
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xhash(1128): here
              instantiation of "void std::_Hash<_Traits>::clear() [with _Traits=std::_Umap_traits<uint32_t, enoki::Vari
  able, std::_Uhash_compare<uint32_t, std::hash<uint32_t>, std::equal_to<uint32_t>>, std::allocator<std::pair<const uin
  t32_t, enoki::Variable>>, false>]"
  D:/Codes/mitsuba2/ext/enoki/src/cuda/jit.cu(237): here
...
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xutility(1236): error :
 class "std::iterator_traits<<error-type>>" has no member "value_type" [D:\Codes\mitsuba2\ext_build\enoki\enoki-cuda.vc
xproj]
            detected during:
              instantiation of type "std::_Iter_value_t<<error-type>>"
  (4544): here
              instantiation of "const __nv_bool std::_Fill_zero_memset_is_safe [with _FwdIt=<error-type>, _Ty=std::cond
  itional_t<false, std::_List_unchecked_const_iterator<std::_List_val<std::conditional_t<true, std::_List_simple_types<
  std::pair<const uint32_t, enoki::Variable>>, std::_List_iter_types<std::pair<const uint32_t, enoki::Variable>, size_t
  , ptrdiff_t, std::pair<const uint32_t, enoki::Variable> *, const std::pair<const uint32_t, enoki::Variable> *, std::p
  air<const uint32_t, enoki::Variable> &, const std::pair<const uint32_t, enoki::Variable> &, std::_List_node<std::pair
  <const uint32_t, enoki::Variable>, void *> *>>>, std::_Iterator_base0>, std::_List_unchecked_iterator<std::_List_val<
  std::conditional_t<true, std::_List_simple_types<std::pair<const uint32_t, enoki::Variable>>, std::_List_iter_types<s
  td::pair<const uint32_t, enoki::Variable>, size_t, ptrdiff_t, std::pair<const uint32_t, enoki::Variable> *, const std
  ::pair<const uint32_t, enoki::Variable> *, std::pair<const uint32_t, enoki::Variable> &, const std::pair<const uint32
  _t, enoki::Variable> &, std::_List_node<std::pair<const uint32_t, enoki::Variable>, void *> *>>>>>, <unnamed>=false]"
...

Agent-INF avatar Jan 04 '22 07:01 Agent-INF

Did you manage to figure this out? Or find a different CUDA version etc. that worked? I'm getting the same error with CUDA 11.2

anderslanglands avatar Apr 25 '22 07:04 anderslanglands

In case anyone else hits this, CUDA 11.6 works for me.

anderslanglands avatar Apr 25 '22 20:04 anderslanglands

With cuda 11.6 I can compile but then I get this error when I run mitsuba.exe

cuda_check(): runtime API error = 0222 "cudaErrorUnsupportedPtxVersion" in D:\MACHINE_LEARNING\Rendering\mitsuba2\ext\enoki\src\cuda\jit.cu:279.

davebs avatar Jul 15 '22 16:07 davebs

Hello @davebs,

Could you check that the architecture version specified on this line is compatible with your GPU?

https://github.com/mitsuba-renderer/mitsuba2/blob/f3e846718182ad00c485695f9708ab78c866c915/resources/ptx/Makefile#L10

You can try increasing or decreasing it based on your hardware, and re-generating optix_rt.ptx using that makefile. After that, you can compile the main project again.

merlinND avatar Jul 16 '22 12:07 merlinND

I tried changing the line to

-O3 -gencode arch=compute_86,code=[sm_86,compute_86] --ptx

and

-O3 -gencode arch=compute_86,code=compute_86 --ptx

and get the same error. I'm concerned it was not recompiling properly but I did rebuild and the dist files do seem to be newly generated, so I think I am rebuilding properly. I'm on an RTX 3070. Very strange.

davebs avatar Jul 19 '22 10:07 davebs

Ok, I see you are suggesting to re-generate optix_rt.ptx using the edited Makefile, I am probably missing something but running cmake inside the directory doesn't work, how do I re-generate that file?

davebs avatar Jul 19 '22 10:07 davebs

Hi @davebs,

If you haven't used Mitsuba 2 yet, I suggest starting with Mitsuba 3 which will be released extremely soon. Mitsuba 3 comes with many improvements, and importantly, will be much easier to install (pip install mitsuba).

merlinND avatar Jul 20 '22 08:07 merlinND

Thanks, I will try it out when it does, it looks like a really cool project but I couldn't quite get it to build 😢 👍

davebs avatar Aug 02 '22 19:08 davebs

Hi @davebs,

Mitsuba 3 is out, and the nice thing is that it comes with pre-built wheels. In principle it should be as simple as: python3 -m pip install mitsuba. Feel free to open an issue on the Mitsuba 3 repo if you encounter any problem.

merlinND avatar Aug 02 '22 20:08 merlinND

Thanks, I will try it out when it does, it looks like a really cool project but I couldn't quite get it to build 😢 👍

That may be the issue of CMake, here solved the problem for me. The CMake version I used is 3.21.0-rc3.

winterwindwang avatar Sep 02 '22 07:09 winterwindwang