Open hradec opened 1 year ago
It seems this problem could be related to AVX instructions set that is not availabel in Xeon X5675. I've found this forum where embree was crashing if built with AVX support on servers that lack the instruction set in their cpu: https://discourse.paraview.org/t/embree-problem-with-illegal-instruction-in-paraview-5-6-1/2070/2
Also, I found the same problem in this old bug: https://github.com/isl-org/Open3D/issues/5682
So I've modified 3rdparty/embree/embree.cmake
to check if the CPU has AVX support using lscpu
:
diff --git a/3rdparty/embree/embree.cmake b/3rdparty/embree/embree.cmake
index 4e93eadf1..48c1abeb8 100644
--- a/3rdparty/embree/embree.cmake
+++ b/3rdparty/embree/embree.cmake
@@ -36,17 +36,30 @@ elseif(LINUX_AARCH64)
set(ISA_LIBS "")
set(ISA_BUILD_BYPRODUCTS "")
else() # Linux(x86) and WIN32
- set(ISA_ARGS -DEMBREE_ISA_AVX=ON
- -DEMBREE_ISA_AVX2=ON
- -DEMBREE_ISA_AVX512=OFF
- -DEMBREE_ISA_SSE2=OFF
- -DEMBREE_ISA_SSE42=OFF
- )
- # order matters. link libs with increasing ISA order.
- set(ISA_LIBS embree_avx embree_avx2)
- set(ISA_BUILD_BYPRODUCTS "<INSTALL_DIR>/${Open3D_INSTALL_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}embree_avx${CMAKE_STATIC_LIBRARY_SUFFIX}"
- "<INSTALL_DIR>/${Open3D_INSTALL_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}embree_avx2${CMAKE_STATIC_LIBRARY_SUFFIX}"
- )
+ execute_process(COMMAND lscpu | grep -i flags | grep -i avx OUTPUT_VARIABLE HAS_AVX)
+ if(HAS_AVX)
+ set(ISA_ARGS -DEMBREE_ISA_AVX=ON
+ -DEMBREE_ISA_AVX2=ON
+ -DEMBREE_ISA_AVX512=OFF
+ -DEMBREE_ISA_SSE2=OFF
+ -DEMBREE_ISA_SSE42=OFF
+ )
+ # order matters. link libs with increasing ISA order.
+ set(ISA_LIBS embree_avx embree_avx2)
+ set(ISA_BUILD_BYPRODUCTS "<INSTALL_DIR>/${Open3D_INSTALL_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}embree_avx${CMAKE_STATIC_LIBRARY_SUFFIX}"
+ "<INSTALL_DIR>/${Open3D_INSTALL_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}embree_avx2${CMAKE_STATIC_LIBRARY_SUFFIX}"
+ )
+ else()
+ set(ISA_ARGS -DEMBREE_ISA_AVX=OFF
+ -DEMBREE_ISA_AVX2=OFF
+ -DEMBREE_ISA_AVX512=OFF
+ -DEMBREE_ISA_SSE2=ON
+ -DEMBREE_ISA_SSE42=ON
+ )
+ # order matters. link libs with increasing ISA order.
+ set(ISA_LIBS embree_sse42)
+ set(ISA_BUILD_BYPRODUCTS "<INSTALL_DIR>/${Open3D_INSTALL_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}embree_sse42${CMAKE_STATIC_LIBRARY_SUFFIX}" )
+ endif()
endif()
After this change and a clean build, Open3d
ran fine (no illegal instruction anymore) as well as import open3d
in python!!
So it seems the problem is Open3D builds embree assuming AVX as minimum instruction set on Linux X86* systems.
I'm not very good with cmake and git pull requests, but I'll try to change cmake to add an option to disable AVX when building on Linux for old CPUs that don't support it. (btw, I saw AVX is already disabled in 3rdparty/embree/embree.cmake
when building on OSX)
Checklist
master
branch).Describe the issue
For the pip install binary, I tried running in my standard arch distro, and then in a Ubuntu 20.04 docker container... same Illegal instruction error on all of then.
I then build it from source successfully in my arch distro, and got the same Illegal instruction on booth
Open3D
app and pythonimport open3d
My CPU is and old Xeon X5675, so maybe I need change some compiling flags and rebuild from source to build a binary compatible with my cpu instructions?
I'm building with LLVM 11, standard build options. (just running
cmake ..
in a build sub-folder)this is my lscpu output:
Steps to reproduce the bug
Error message
running
Open3D
app ingdb
, this is the output I get:I've looked for
*collider.cpp
files, and foundembree/src/ext_embree/kernels/bvh/bvh_collider.cpp
, so this could be an issue withembree
building?Expected behavior
Just being able to run
Open3D
orimport open3d
in python.Open3D, Python and System information
Additional information
I've tried building with
-DCMAKE_BUILD_TYPE=Debug
, but had to remove-Werror
strings fromcmake/Open3DShowAndAbortOnWarning.cmake
to be able to finish building.Got the same error with debug version, and didn't get any proper debug output in
gdb
.