Open3D icon indicating copy to clipboard operation
Open3D copied to clipboard

Segmentation Fault issue with numpy v2.0.0

Open Helm-droid opened this issue 1 year ago • 16 comments

Checklist

My Question

I am trying to run the vis_pred.py in the example folder and I kept encountering the 'segmentation fault' error. It was running just fine for a few minutes and could complete a few tasks up to 100% before the issue came out. I am not sure why this is happening. I am currently running it on conda environment in WSL2.

Helm-droid avatar Jun 23 '24 09:06 Helm-droid

I encountered the same issue in a Python 3.11 environment, including both Windows 11 and Ubuntu 24

yckm avatar Jun 24 '24 07:06 yckm

I encountered the same issue in a conda environment with Python 3.11 and open3d 0.18.

  1. I report the command "glxinfo | grep "OpenGL"" result:

OpenGL vendor string: AMD OpenGL renderer string: RENOIR (renoir, LLVM 15.0.7, DRM 3.54, 6.5.0-41-generic) OpenGL core profile version string: 4.6 (Core Profile) Mesa 23.2.1-1ubuntu3.1~22.04.2 OpenGL core profile shading language version string: 4.60 OpenGL core profile context flags: (none) OpenGL core profile profile mask: core profile OpenGL core profile extensions: OpenGL version string: 4.6 (Compatibility Profile) Mesa 23.2.1-1ubuntu3.1 22.04.2 OpenGL shading language version string: 4.60 OpenGL context flags: (none) OpenGL profile mask: compatibility profile OpenGL extensions: OpenGL ES profile version string: OpenGL ES 3.2 Mesa 23.2.1-1ubuntu3.1 22.04.2 OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20 OpenGL ES profile extensions:

  1. lscpu

Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 48 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 16 On-line CPU(s) list: 0-15 Vendor ID: AuthenticAMD Model name: AMD Ryzen 7 PRO 5850U with Radeon Graphics CPU family: 25 Model: 80 Thread(s) per core: 2 Core(s) per socket: 8 Socket(s): 1 Stepping: 0 CPU max MHz: 4507.0000 CPU min MHz: 400.0000 BogoMIPS: 3792.89 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdp e1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw i bs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmm call fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_ llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd cppc arat npt lbrv svm_lock nrip_save tsc_sca le vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqd q rdpid overflow_recov succor smca fsrm Virtualization features: Virtualization: AMD-V Caches (sum of all):
L1d: 256 KiB (8 instances) L1i: 256 KiB (8 instances) L2: 4 MiB (8 instances) L3: 16 MiB (1 instance) NUMA:
NUMA node(s): 1 NUMA node0 CPU(s): 0-15 Vulnerabilities:
Gather data sampling: Not affected Itlb multihit: Not affected L1tf: Not affected Mds: Not affected Meltdown: Not affected Mmio stale data: Not affected Retbleed: Not affected Spec rstack overflow: Vulnerable: Safe RET, no microcode Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Spectre v2: Mitigation; Retpolines; IBPB conditional; IBRS_FW; STIBP always-on; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected Srbds: Not affected Tsx async abort: Not affected

  1. If I run the test code I get Segmentation Fault:

python -c "import open3d as o3d;
mesh = o3d.geometry.TriangleMesh.create_sphere();
mesh.compute_vertex_normals();
o3d.visualization.draw(mesh, raw_mode=True)"

  1. I tried to create my own code but when I run these line I get the same Segmentation Fault:

o3d.geometry.TriangleMesh.create_coordinate_frame() axis_x.translate() axis_x.rotate()

margal5 avatar Jun 24 '24 09:06 margal5

This could be a numpy issue if you have installed numpy 2.0.0. Try installing numpy 1.26.4 and it might be fixed.

ed-cho avatar Jun 24 '24 12:06 ed-cho

This could be a numpy issue if you have installed numpy 2.0.0. Try installing numpy 1.26.4 and it might be fixed.

it works for me !!!!

LeeC20 avatar Jun 25 '24 02:06 LeeC20

As pointed out by @ed-cho. It looks like its coming from an incompatibility with numpy 2.0.0.

To reproduce the error:

Running the command provided in the README, i.e.:

python -c "import open3d as o3d; \
           mesh = o3d.geometry.TriangleMesh.create_sphere(); \
           mesh.compute_vertex_normals(); \
           o3d.visualization.draw(mesh, raw_mode=True)"

This setup works:

python==3.9
open3d==0.18.0
numpy==1.26.4

This setup leads to a segfault:

python==3.9
open3d==0.18.0
numpy==2.0.0

So if you encounter the same issue, force the version of numpy to use 1.26.4

pip install numpy==1.26.4

cjaverliat avatar Jun 25 '24 08:06 cjaverliat

Thanks @ed-cho, but the problem is another. I already use version 1.26.3 of Numpy.

margal5 avatar Jun 25 '24 09:06 margal5

As pointed out by @ed-cho. It looks like its coming from an incompatibility with numpy 2.0.0.

To reproduce the error:

Running the command provided in the README, i.e.:

python -c "import open3d as o3d; \
           mesh = o3d.geometry.TriangleMesh.create_sphere(); \
           mesh.compute_vertex_normals(); \
           o3d.visualization.draw(mesh, raw_mode=True)"

This setup works:

python==3.9
open3d==0.18.0
numpy==1.26.4

This setup leads to a segfault:

python==3.9
open3d==0.18.0
numpy==2.0.0

So if you encounter the same issue, force the version of numpy to use 1.26.4

pip install numpy==1.26.4

Thanks for this, worked for me! Was experiencing segfault while running KDTreeFlann search_knn_vector_3d which was fixed by downgrading numpy.

Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()

MatousKundrik avatar Jun 25 '24 14:06 MatousKundrik

Had a similar problem with:

o3d.utility.Vector3dVector(np.array)

Received a segmentation fault, using:

python==3.10.12 open3d==0.18.0 numpy==2.0.0

Same function/code works with setup:

python==3.10.12 open3d==0.18.0 numpy==1.24.3

Issue came up, when I set up a new venv last week, after numpy 2.0.0 was launched, by just using pip install numpy... Took me 4 days to figure out what the reason was. Hopefully this helps other people earlier.

SchellenMarius avatar Jun 26 '24 20:06 SchellenMarius

I confirmed the segmentation fault issue solved with numpy 1.26.4, open3d installed with pip on windows 11.

panovr avatar Jun 27 '24 01:06 panovr

I have tried running the examples a couple of times and found out that the issue (at least in my case) is related to 'visualize' command line in the script. It didn't give me the error (Segmentation Fault) when I commented the line out. For example in the file, vis_pred.py #line 153 v.visualize(pcs_with_pred). Similar thing happened when I tried running the visualize.py example. Not sure if it has something to do with memory or incompatibility issues.

Helm-droid avatar Jun 27 '24 06:06 Helm-droid

I confirm that with a conda env based on: python==3.10.12 open3d==0.18.0 numpy==1.24.3

I no longer get the Segmentation Fault error.

margal5 avatar Jun 27 '24 20:06 margal5

Here another case for caussing the segmentation fault:

import open3d as o3d
import numpy as np

def main():
    # Generate some random 3D points
    points_center_source = np.random.rand(100, 3)

    # Ensure the array is of type float64
    points_center_source = points_center_source.astype(np.float64)
    print("Points generated and converted to float64.")

    # Create an Open3D PointCloud object
    pcd = o3d.geometry.PointCloud()
    pcd.points = o3d.utility.Vector3dVector(points_center_source)
    print("PointCloud created.")

    # Build the KDTree
    try:
        center_tree = o3d.geometry.KDTreeFlann(pcd)
        print("KDTree constructed successfully.")
    except Exception as e:
        print(f"Error constructing KDTree: {e}")
        return

    # Query the KDTree
    try:
        for i in range(len(points_center_source)):
            [k, idx, _] = center_tree.search_knn_vector_3d(points_center_source[i, :], 1)
            print(f"Point {i} - Nearest neighbor index: {idx}, Distance: {k}")
    except Exception as e:
        print(f"Error querying KDTree: {e}")

if __name__ == "__main__":
    main()

is fixed with downgrading to numpy 1.26.4

SchmidL avatar Jun 28 '24 12:06 SchmidL

Thanks for reporting and debugging. We've merged a PR explicitly requiring numpy < 2 for now. Will add support for numpy v2 for the next release.

ssheorey avatar Jul 13 '24 02:07 ssheorey

Verified fixed by upgrading pybind11 to 2.13.1

ssheorey avatar Jul 16 '24 19:07 ssheorey

confirmed

I ran into the same issue, and switching to python 1.26.4 as pointed out by others above it works.

nima-rezaeian-ai avatar Jul 29 '24 03:07 nima-rezaeian-ai

I also faced the same issue ,switching to numpy==1.26.4 as pointed out by others fixed it. I tested it on python==3.11 open3d==0.18.0 numpy==1.26.4

knightx12 avatar Jul 31 '24 06:07 knightx12

This could be a numpy issue if you have installed numpy 2.0.0. Try installing numpy 1.26.4 and it might be fixed.

I encountered a similar issue that I couldn't run o3d.utility.Vector3dVector() after using numpy to transform points read from .las files via laspy. I was using higher version like 2.24 or something ( couldn't find the log) and I downgraded numpy to 1.26.4 and now it works!

abysee avatar Oct 28 '24 07:10 abysee

Numpy 2 is supported with Open3D v0.19

ssheorey avatar Jan 18 '25 07:01 ssheorey