8000 BUG: Segmentation fault when working with open3d · Issue #26853 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Segmentation fault when working with open3d #26853

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

Closed
AlterraFa opened this issue Jul 4, 2024 · 6 comments
Closed

BUG: Segmentation fault when working with open3d #26853

AlterraFa opened this issue Jul 4, 2024 · 6 comments
Labels

Comments

@AlterraFa
Copy link
AlterraFa commented Jul 4, 2024

Describe the issue:

I encountered a segmentation fault when drawing using open3d
There are 2 variables XYZ and XYZreformat
However XYZ give a segmentation fault, even when I reassign its data type to float64 by using XYZ = XYZ.astype(np.float64)
Only the code below works

Note: The older version seems to work but not with the version 2.0.0
depth.csv

Reproduce the code example:

import scipy.io.matlab as mat
import numpy as np
import open3d as o3d
import pandas as pd
import faulthandler
faulthandler.enable()

depth_arr = pd.read_csv('depth.csv').to_numpy()

sx = 32 / 1024 # Ratio between sensor width and total pixel. Assume sx = sy
fx = 24 / sx
fy = 24 / sx
Cx = 1024 // 2 - 1
Cy = 512 // 2 - 1

# x and y coordinates
x = np.arange(0, 1024, 1)
y = np.arange(0, 512, 1)

x, y = np.meshgrid(x, y, copy = True) # Meshgrid for x and y. This is 2D array
u, v = x - Cx, y - Cy # calculate distance from center the center   X\
    

Z = depth_arr / (((u / fy) ** 2 + (v / fx) ** 2 + 1) ** .5) # Calculate depth array
Zravel = Z.ravel() # convert from 2D to 1D array

kernel = np.array([[1 / fx, 0, -Cx / fx],
                   [0, 1 / fy, -Cy / fy],
                   [0, 0, 1]]) # Kernel or transfer function of vector [X / Z, Y / Z, 1]

xravel = x.ravel() # convert from 2D to 1D array
yravel = y.ravel() # convert from 2D to 1D array



# create an array containing x, y coordinates
# This will result in an array that looks like this:
# [[x1, x2, x3, ..., xn],
#  [y1, y2, y3, ..., yn],
#  [1, 1, 1, ..., 1]]
# Instead of doing for loop with
# [[X / Z],
#  [Y / Z],
#  [1]]
# = kernel dot product with
# [[x],

#  [y],
#  [1]]
# We can use the afformentioned array to instead calculate the dot product between kernel and the above array
xy_vector = np.array([xravel, yravel, np.ones_like(xravel)]) 
resultant_3d_vector = kernel @ xy_vector # @ is also the dot product operation
# print(resultant_3d_vector)
XYZ = (resultant_3d_vector * Zravel).T # transpose for compatibility with open3d input array [[X, Y, Z]]
XYZreformat = np.array(XYZ.tolist(), dtype = np.float64)


if __name__ == "__main__":
    pcd = o3d.geometry.PointCloud()
    pcd.points = o3d.utility.Vector3dVector(XYZ)
    o3d.visualization.draw_geometries([pcd])

Error message:

Fatal Python error: Segmentation fault

Current thread 0x00007ad4343be000 (most recent call first):
  File "/mnt/6208995F089932D1/Coding/Python/Realsense Example/pointcloudpractice.py", line 61 in <module>

Extension modules: numpy._core._multiarray_umath, numpy._core._multiarray_tests, numpy.linalg._umath_linalg, scipy._lib._ccallback_c, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, charset_normalizer.md, scipy.sparse._sparsetools, _csparsetools, scipy.sparse._csparsetools, scipy.linalg._fblas, scipy.linalg._flapack, scipy.linalg.cython_lapack, scipy.linalg._cythonized_array_utils, scipy.linalg._solve_toeplitz, scipy.linalg._decomp_lu_cython, scipy.linalg._matfuncs_sqrtm_triu, scipy.linalg.cython_blas, scipy.linalg._matfuncs_expm, scipy.linalg._decomp_update, scipy.sparse.linalg._dsolve._superlu, scipy.sparse.linalg._eigen.arpack._arpack, scipy.sparse.linalg._propack._spropack, scipy.sparse.linalg._propack._dpropack, scipy.sparse.linalg._propack._cpropack, scipy.sparse.linalg._propack._zpropack, scipy.sparse.csgraph._tools, scipy.sparse.csgraph._shortest_path, scipy.sparse.csgraph._traversal, scipy.sparse.csgraph._min_spanning_tree, scipy.sparse.csgraph._flow, scipy.sparse.csgraph._matching, scipy.sparse.csgraph._reordering, scipy.io.matlab._mio_utils, scipy.io.matlab._streams, scipy.io.matlab._mio5_utils, markupsafe._speedups, zmq.backend.cython._zmq, tornado.speedups, psutil._psutil_linux, psutil._psutil_posix, _brotli, simplejson._speedups, pandas._libs.tslibs.ccalendar, pandas._libs.tslibs.np_datetime, pandas._libs.tslibs.dtypes, pandas._libs.tslibs.base, pandas._libs.tslibs.nattype, pandas._libs.tslibs.timezones, pandas._libs.tslibs.fields, pandas._libs.tslibs.timedeltas, pandas._libs.tslibs.tzconversion, pandas._libs.tslibs.timestamps, pandas._libs.properties, pandas._libs.tslibs.offsets, pandas._libs.tslibs.strptime, pandas._libs.tslibs.parsing, pandas._libs.tslibs.conversion, pandas._libs.tslibs.period, pandas._libs.tslibs.vectorized, pandas._libs.ops_dispatch, pandas._libs.missing, pandas._libs.hashtable, pandas._libs.algos, pandas._libs.interval, pandas._libs.lib, pandas._libs.ops, pandas._libs.hashing, pandas._libs.arrays, pandas._libs.tslib, pandas._libs.sparse, pandas._libs.internals, pandas._libs.indexing, pandas._libs.index, pandas._libs.writers, pandas._libs.join, pandas._libs.window.aggregations, pandas._libs.window.indexers, pandas._libs.reshape, pandas._libs.groupby, pandas._libs.json, pandas._libs.parsers, pandas._libs.testing (total: 90)
Segmentation fault (core dumped)

Python and NumPy Versions:

2.0.0
3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]

Runtime Environment:

[{'numpy_version': '2.0.0',
'python': '3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]',
'uname': uname_result(system='Linux', node='alterraonix-LOQ', release='6.5.0-41-generic', version='#41~22.04.2-Ubuntu SMP PREEMPT_DYNAMIC Mon Jun 3 11:32:55 UTC 2', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2'],
'not_found': ['AVX512F',
'AVX512CD',
'AVX512_KNL',
'AVX512_KNM',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL']}},
{'architecture': 'Haswell',
'filepath': '/home/alterraonix/.local/lib/python3.10/site-packages/numpy.libs/libscipy_openblas64_-99b71e71.so',
'internal_api': 'openblas',
'num_threads': 12,
'prefix': 'libscipy_openblas',
'threading_layer': 'pthreads',
'user_api': 'blas',
'version': '0.3.27'}]

Context for the issue:

This might lead to other problems since this is a segmentation fault with another library so I reported it

@seberg
Copy link
Member
seberg commented Jul 4, 2024

This is not an issue with NumPy, please search the issues at open3d (or open one there). You can try downgrading NumPy to numpy<2 if you think that is a new issue. But it would be strange if it makes a difference (i.e. compiled for NumPy 2, even though it is not yet supported).

@seberg seberg closed this as not planned Won't fix, can't repro, duplicate, stale Jul 4, 2024
@Wendyiii
Copy link

Have you solved this problem? I'm also having the same issue, can you tell me what to do?Thank you veeeeeery much

@AlterraFa
Copy link
Author

Have you solved this problem? I'm also having the same issue, can you tell me what to do?Thank you veeeeeery much

Yeah, by downgrading it to numpy < 2.0.0

@Wendyiii
Copy link

Great, this method worked, thank you again!!!

@antoinekeller
Copy link

Same here, downgrading to numpy==1.26.4 solved my issue

@mattip
Copy link
Member
mattip commented Aug 29, 2024

A quick search for "numpy" and "segmentation" leads to many open issues in that project. Unless we can get a clearer reproducer, I am going to assume the crash is in open3d. This issue is closed, please do not add more comments here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants
0