isl-org / Open3D

Open3D: A Modern Library for 3D Data Processing
http://www.open3d.org
Other
11.09k stars 2.26k forks source link

Segmentation Fault issue with numpy v2.0.0 #6840

Open Helm-droid opened 2 months ago

Helm-droid commented 2 months ago

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.

yckm commented 2 months ago

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

margal5 commented 2 months ago

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 shani 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()

ed-cho commented 2 months ago

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.

LeeC20 commented 2 months ago

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 !!!!

cjaverliat commented 2 months ago

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
margal5 commented 2 months ago

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

MatousKundrik commented 2 months ago

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 ?? ()
SchellenMarius commented 2 months ago

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.

panovr commented 2 months ago

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

Helm-droid commented 2 months ago

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.

margal5 commented 2 months ago

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.

SchmidL commented 1 month ago

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

ssheorey commented 1 month ago

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 commented 1 month ago

Verified fixed by upgrading pybind11 to 2.13.1

nimarezaeian commented 4 weeks ago

confirmed

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

knightx12 commented 3 weeks ago

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