Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when installing open3d for conda environment, missing libomp, seg fault when installed #6196

Open
3 tasks done
ebruun opened this issue Jun 3, 2023 · 6 comments · May be fixed by #6626
Open
3 tasks done

Error when installing open3d for conda environment, missing libomp, seg fault when installed #6196

ebruun opened this issue Jun 3, 2023 · 6 comments · May be fixed by #6626
Assignees
Labels
bug Not a build issue, this is likely a bug. build/install Build or installation issue

Comments

@ebruun
Copy link

ebruun commented Jun 3, 2023

Checklist

Steps to reproduce the issue

I first create a new conda environement with python 3.10:

conda create -n o3d_test python=3.10

Then, I install open3d:

pip install open3d

Then, I verify installation:

python -c "import open3d as o3d; print(o3d.__version__)"

Error message

Full terminal output:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/homebrew/anaconda3/envs/o3d_test/lib/python3.10/site-packages/open3d/__init__.py", line 93, in <module>
    from open3d.cpu.pybind import (core, camera, data, geometry, io, pipelines,
ImportError: dlopen(/opt/homebrew/anaconda3/envs/o3d_test/lib/python3.10/site-packages/open3d/cpu/pybind.cpython-310-darwin.so, 0x0002): Library not loaded: /opt/homebrew/opt/libomp/lib/libomp.dylib
  Referenced from: /opt/homebrew/anaconda3/envs/o3d_test/lib/python3.10/site-packages/open3d/cpu/pybind.cpython-310-darwin.so
  Reason: tried: '/opt/homebrew/opt/libomp/lib/libomp.dylib' (no such file), '/usr/local/lib/libomp.dylib' (no such file), '/usr/lib/libomp.dylib' (no such file)

Open3D, Python and System information

- Operating system: macOS 12.0.1
- Python version: Python 3.10.11
- Open3D version: 0.17.0
- System architecture: apple-silicon
- Is this a remote workstation?: no
- How did you install Open3D?: pip
- Compiler version (if built from source): N/A

Additional information

No response

@ebruun ebruun added the build/install Build or installation issue label Jun 3, 2023
@ebruun ebruun changed the title Summarize the issue and your environments (e.g., "Cannot compile on Ubuntu 20.04 with OpenBLAS") Error when installing open3d for conda environemtn Jun 3, 2023
@ebruun ebruun changed the title Error when installing open3d for conda environemtn Error when installing open3d for conda environment Jun 3, 2023
@cwreynolds
Copy link

cwreynolds commented Jun 3, 2023

(“Wait, I understood that reference” — some superhero movie)

I ran into the same thing on my first Open3d install on macOS (see #6032). Try this:

brew install libomp

and see if your build works, like mine did after that. You might have to install Homebrew first if you have not already.

@ebruun
Copy link
Author

ebruun commented Jun 3, 2023

hmm okay so doing the above suggested seems to work when I run it in a bare-bones conda environment that is built from just the following environment.yml

name: o3d_test
channels:
  - r
  - conda-forge
  - defaults
dependencies:
  - python==3.10.11
  - pip:
    - open3d==0.17.0
prefix: /opt/homebrew/anaconda3/envs/o3d_test

But if I create the conda environment with another package, e.g. compas-fab, things seem to break

name: o3d_test
channels:
  - r
  - conda-forge
  - defaults
dependencies:
  - python==3.10.11
  - compas_fab==0.27.0
  - pip:
    - open3d==0.17.0
prefix: /opt/homebrew/anaconda3/envs/o3d_test

now I get a seg fault:

zsh: segmentation fault  python -c "import open3d as o3d; print(o3d.__version__)"

@ebruun ebruun changed the title Error when installing open3d for conda environment Error when installing open3d for conda environment, missing libomp, seg fault when installed Jun 3, 2023
@poppigy
Copy link

poppigy commented Jun 15, 2023

Is there any workaround here? It worked a few days ago, but now I always have segfaults. I recreated a conda env and reinstalled open3d (version 0.17.0).

pip show open3d
Name: open3d
Version: 0.17.0
python -c "import open3d; print(open3d.__version__)"
[1]    4431 segmentation fault  python -c "import open3d; print(open3d.__version__)"

upd: have decided to try open3d==0.15.1, and now I can run it

@theNded theNded added the bug Not a build issue, this is likely a bug. label Aug 10, 2023
@cielixer
Copy link

cielixer commented Sep 4, 2023

Hi, i have been recently digging this problem for days, and found out some temporary solution.

I did lldb python and run -c "import open3d", found out that libomp causes the problem in multi thread settings.

Process 11193 stopped
* thread #11, stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
    frame #0: 0x0000000101e08f50 libomp.dylib`void __kmp_suspend_64<false, true>(int, kmp_flag_64<false, true>*) + 48
libomp.dylib`__kmp_suspend_64<false, true>:
->  0x101e08f50 <+48>: ldr    x19, [x8, w0, sxtw #3]
    0x101e08f54 <+52>: mov    x0, x19
    0x101e08f58 <+56>: bl     0x101e08694               ; __kmp_suspend_initialize_thread
    0x101e08f5c <+60>: mov    x0, x19
  thread #12, stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
    frame #0: 0x0000000101e08f50 libomp.dylib`void __kmp_suspend_64<false, true>(int, kmp_flag_64<false, true>*) + 48
libomp.dylib`__kmp_suspend_64<false, true>:
->  0x101e08f50 <+48>: ldr    x19, [x8, w0, sxtw #3]
    0x101e08f54 <+52>: mov    x0, x19
    0x101e08f58 <+56>: bl     0x101e08694               ; __kmp_suspend_initialize_thread
    0x101e08f5c <+60>: mov    x0, x19
  thread #13, stop reason = EXC_BAD_ACCESS (code=1, address=0x18)
    frame #0: 0x0000000101e08f50 libomp.dylib`void __kmp_suspend_64<false, true>(int, kmp_flag_64<false, true>*) + 48
libomp.dylib`__kmp_suspend_64<false, true>:
->  0x101e08f50 <+48>: ldr    x19, [x8, w0, sxtw #3]
    0x101e08f54 <+52>: mov    x0, x19
    0x101e08f58 <+56>: bl     0x101e08694               ; __kmp_suspend_initialize_thread
    0x101e08f5c <+60>: mov    x0, x19
  thread #14, stop reason = EXC_BAD_ACCESS (code=1, address=0x20)
    frame #0: 0x0000000101e08f50 libomp.dylib`void __kmp_suspend_64<false, true>(int, kmp_flag_64<false, true>*) + 48
libomp.dylib`__kmp_suspend_64<false, true>:
->  0x101e08f50 <+48>: ldr    x19, [x8, w0, sxtw #3]
    0x101e08f54 <+52>: mov    x0, x19
    0x101e08f58 <+56>: bl     0x101e08694               ; __kmp_suspend_initialize_thread
    0x101e08f5c <+60>: mov    x0, x19
  thread #15, stop reason = EXC_BAD_ACCESS (code=1, address=0x28)
    frame #0: 0x0000000101e08f50 libomp.dylib`void __kmp_suspend_64<false, true>(int, kmp_flag_64<false, true>*) + 48
libomp.dylib`__kmp_suspend_64<false, true>:
->  0x101e08f50 <+48>: ldr    x19, [x8, w0, sxtw #3]
    0x101e08f54 <+52>: mov    x0, x19
    0x101e08f58 <+56>: bl     0x101e08694               ; __kmp_suspend_initialize_thread
    0x101e08f5c <+60>: mov    x0, x19
  thread #16, stop reason = EXC_BAD_ACCESS (code=1, address=0x30)
    frame #0: 0x0000000101e08f50 libomp.dylib`void __kmp_suspend_64<false, true>(int, kmp_flag_64<false, true>*) + 48
libomp.dylib`__kmp_suspend_64<false, true>:
->  0x101e08f50 <+48>: ldr    x19, [x8, w0, sxtw #3]
    0x101e08f54 <+52>: mov    x0, x19
    0x101e08f58 <+56>: bl     0x101e08694               ; __kmp_suspend_initialize_thread
    0x101e08f5c <+60>: mov    x0, x19
Target 0: (python) stopped.

It's not a perfect solution, when setting the openmp's number of threads to 1 solved the problem.

export OMP_NUM_THREADS=1

This worked for me in Ventura 13.4.1 with Apple M1 Pro in conda environment, i am using python=3.10.12 and open3d=1.16.1.

@bschindler
Copy link

The issue is that open3d ships its own libopenmp, but conda has its own version. So 2 versions of openmp get loaded and things explode.
I found a fix for the conda case, but its less than ideal, to put it mildly. In my case, I cannot switch to the available conda builds because they don't have GUI mode...

install_name_tool -change "@loader_path/../libomp.dylib" "@rpath/libomp.dylib" /path/to/conda/env/lib/python3.8/site-packages/open3d/cpu/pybind.cpython-38-darwin.so

@ssheorey
Copy link
Member

Should be fixed by #6626

@ssheorey ssheorey linked a pull request Mar 15, 2024 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not a build issue, this is likely a bug. build/install Build or installation issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants