How to debug script being stuck upon specific import?

77 Views Asked by At

I have a problem with a certain import and would like to receive some debugging advice. When I run the following script, there are no problems:

import kornia.feature as KF

print("Before matcher creation")
matcher = KF.LoFTR(pretrained='outdoor')
print("After matcher creation")

However, when I run the following script, the script gets stuck upon the initialisation of the LoFTR object (the last print is never called).

import open3d
import kornia.feature as KF

print("Before matcher creation")
matcher = KF.LoFTR(pretrained='outdoor')
print("After matcher creation")

I also figured out that if i import kornia.feature first and open3d second, I get the following error:

OMP: Error #179: Function pthread_mutex_init failed:
OMP: System error #22: Invalid argument
zsh: abort      python3 script.py

What are some approaches to debugging this? I have never encountered such a problem.

Edit: Only importing open3d doesn't lead to an error.

1

There are 1 best solutions below

4
Gag Baghdasaryan On

Here are some things you can try to find the problem.

  1. The order in which you import libraries can be mattered because they may change the state of the runtime environment in incompatible ways. Try to delay the import of open3d
  2. If you're on MacOS, there have been known issues with the default clang compiler not supporting OpenMP out of the box. Installing a version of GCC with OpenMP support or using Homebrew to install libomp may resolve this issue.
  3. Try to run the code that uses kornia and open3d separately in different scripts to check if they work fine in isolation. This can help determine if the issue is with the libraries themselves or the interaction between them.

Let me know if any of these points would give more info.