Open3D icon indicating copy to clipboard operation
Open3D copied to clipboard

Import fails with segmentation fault on MacOS within Anaconda environment

Open flolu opened this issue 1 year ago • 13 comments

Checklist

Steps to reproduce the issue

I first cloned Open3D by:

conda env create -n open3d-test
conda activate opend3d-test
pip install open3d==0.17.0
python
import open3d

Error message

[5]    35067 segmentation fault  python


### Open3D, Python and System information

```markdown
- Operating system: macOS Ventura 13.3.1
- Python version: Python 3.10.10
- System architecture: apple-silicon
- Is this a remote workstation?: no
- How did you install Open3D?: pip within conda

Additional information

It works fine when running outside Anaconda like this:

pip install open3d==0.17.0
python
import open3d

flolu avatar Apr 16 '23 18:04 flolu

This is not an answer to your issue, but just as a point of reference: I recently installed Open3D 0.17.0, with pip into a conda env, on my macOS 12.6.3 M1 laptop. See: https://github.com/isl-org/Open3D/discussions/6032

cwreynolds avatar Apr 16 '23 20:04 cwreynolds

I made some test with this problem. It seems som incompatibility with other libraries. In a clean environment, only installing python=3.10 and open3D=0.17, all works perfectly. Then, for my project requeriments I need to install pandas=2.0.3. After the installation, the segmentation fault appears when "import open3d" is called. These are the libraries installed alongside with pandas:

libblas conda-forge/osx-arm64::libblas-3.9.0-17_osxarm64_openblas libcblas conda-forge/osx-arm64::libcblas-3.9.0-17_osxarm64_openblas libcxx conda-forge/osx-arm64::libcxx-16.0.6-h4653b0c_0 libgfortran conda-forge/osx-arm64::libgfortran-5.0.0-12_2_0_hd922786_31 libgfortran5 conda-forge/osx-arm64::libgfortran5-12.2.0-h0eea778_31 liblapack conda-forge/osx-arm64::liblapack-3.9.0-17_osxarm64_openblas libopenblas conda-forge/osx-arm64::libopenblas-0.3.23-openmp_hc731615_0 llvm-openmp conda-forge/osx-arm64::llvm-openmp-16.0.6-h1c12783_0 numpy conda-forge/osx-arm64::numpy-1.25.0-py310haa1e00c_0 pandas conda-forge/osx-arm64::pandas-2.0.3-py310h1cdf563_0 python-dateutil conda-forge/noarch::python-dateutil-2.8.2-pyhd8ed1ab_0 python-tzdata conda-forge/noarch::python-tzdata-2023.3-pyhd8ed1ab_0 python_abi conda-forge/osx-arm64::python_abi-3.10-3_cp310 pytz conda-forge/noarch::pytz-2023.3-pyhd8ed1ab_0 six conda-forge/noarch::six-1.16.0-pyh6c4a22f_0

any idea? It's a very annoying problem!

Thanks!

ferranOCT avatar Jul 06 '23 07:07 ferranOCT

I was not able to find the package responsable of the segmentation fault. However, I used Rosetta2 to run all the code in order to execute them with a intel_x86 virtualised chipset. To do this, is mandatory to remove all libraries, both from Homebrew and Anaconda and also remove both frameworks. Then, install Rosetta2 and execute the terminal with the flag "use with Rosetta" activated. Then, I re-installed all in this situation, which automatically take the sources not from arm64 but from x86_64. Following these steps, finally I'm able to run the code with only a warning about some deprecated compatibility.

Here some references:

Install Rosetta2 -> https://osxdaily.com/2020/12/04/how-install-rosetta-2-apple-silicon-mac/ Install Miniconda with x86_64 support -> https://towardsdatascience.com/how-to-install-miniconda-x86-64-apple-m1-side-by-side-on-mac-book-m1-a476936bfaf0

I hope this could help.

ferranOCT avatar Jul 11 '23 11:07 ferranOCT

open3d

Thank you so much! Solved this issue by creating a brand new conda environment with python 3.10, and installing open3d first!

Crear12 avatar Aug 07 '23 18:08 Crear12

I'm running into this issue now on an M2 machine running Ventura. I was able to install open3d successfully and then once I installed numpy, I started getting the seg fault error. Does using Rosetta2 impact the performance of the library due to the emulation? What if I didn't want to convert my entire miniforge setup to use rosetta?

brentonmallen1 avatar Oct 23 '23 03:10 brentonmallen1

I don't have any problem more than some warnings appearing in the console during the execution. About the performance I don't have a trustable comparison, but I was working in Ubuntu with a Intel i7 + 16gb RAM few months ago with the same code and I didn't notice substantial differences in the execution time. Regarding the question about converting your entire setup, you always can have two different console (i.e. Alacritty and Terminal), one running with Rosseta and the other one without.

ferranOCT avatar Oct 24 '23 09:10 ferranOCT

@ferranOCT were you installing anything along side Open3D, like numpy, pandas, etc?

brentonmallen1 avatar Nov 23 '23 23:11 brentonmallen1

Yes, a lot of libraries :P. Although is not 100% sure, the error rises when I install numpy after open3D.

ferranOCT avatar Nov 25 '23 06:11 ferranOCT

Okay, that's validating :) I was trying to build from source but there doesn't seem to be any documentation about how to set the dependency versions for things like numpy. :( I'll keep trying though. thank you!

brentonmallen1 avatar Nov 25 '23 16:11 brentonmallen1

I encountered the same issue. If I only use pip-installed libraries and not any conda-installed ones in the venv, I don't have any issues.

Unfortunately, I have to use other conda-installed libraries. Any suggestions?

cemoke avatar Dec 14 '23 19:12 cemoke

I encountered the same issue. If I only use pip-installed libraries and not any conda-installed ones in the venv, I don't have any issues.

Unfortunately, I have to use other conda-installed libraries. Any suggestions?

Unfortunately no...I have multiple computers, both Mac and Windows, and this happens too frequently. I simply added a platform detector to decide if the Open3D-related functions need to be imported. I quite like what Open3D has brought, but can't waste more time on installing/configuring the environment.

Crear12 avatar Dec 14 '23 20:12 Crear12

Okay, that's validating :) I was trying to build from source but there doesn't seem to be any documentation about how to set the dependency versions for things like numpy. :( I'll keep trying though. thank you!

I tried to build from source based on this: https://www.open3d.org/docs/release/arm.html But it doesn't help at all. It even asks me to use "apt-get" on my Mac.

Crear12 avatar Feb 03 '24 04:02 Crear12