stereolabs / zed-docker

Docker images for the ZED SDK
https://hub.docker.com/r/stereolabs/zed/
MIT License
49 stars 19 forks source link

Import pyzed failed with numpy 2.0.0 compatibility errors #57

Open Techlorine opened 1 month ago

Techlorine commented 1 month ago

Preliminary Checks

Description

I pulled the docker image stereolabs/zed:4.1-runtime-cuda11.8-ubuntu22.04 and failed to ran my python script on my device. The output was ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject. I couldn't import pyzed.sl in my python interactive console either.

P.S.: The pyzed and my script works well after manually downgrade numpy by pip install numpy<=2.

Steps to Reproduce

  1. sudo docker pull stereolabs/zed:4.1-runtime-cuda11.8-ubuntu22.04
  2. sudo docker run --gpus all -it --privileged -v /path/to/depth_capture:/depth --network=host stereolabs/zed:4.1-runtime-cuda11.8-ubuntu22.04
  3. python3
  4. from pyzed import sl ...

Expected Result

root@92293044a15a:/depth/zed# python3
Python 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyzed import sl
>>>

Actual Result

root@92293044a15a:/depth/zed# python3
Python 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyzed import sl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pyzed/sl.pyx", line 1, in init pyzed.sl
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

ZED Camera model

ZED2i

Environment

OS: Ubuntu 22.04.4 LTS x86_64
CPU: 13th Gen Intel i7-13700K (24) @ 5.300GHz 
GPU: NVIDIA GeForce RTX 3090
ZED SDK version: 4.1
Docker Image: stereolabs/zed:4.1-runtime-cuda11.8-ubuntu22.04


### Anything else?

_No response_
ElliotHYLee commented 1 month ago

same issue.

The maintainer didn't update that the numpy updated to v2.

To save potential poor souls wasting several hours like myself, I ended up using dockerfile like below

FROM stereolabs/zed:4.1-devel-cuda12.1-ubuntu22.04
#FROM stereolabs/zed:3.7-devel-cuda11.7-ubuntu22.04
#FROM stereolabs/zed:4.0-devel-cuda12.1-ubuntu22.04

COPY  ZED_SDK_Ubuntu22_cuda12.1_v4.1.3.zstd.run /home/ZED_SDK_Ubuntu22_cuda12.1_v4.1.3.zstd.run
RUN apt-get update && apt-get install ffmpeg libsm6 libxext6  -y
#RUN pip3 uninstall numpy -y
RUN rm -rf /usr/local/lib/python3.10/dist-packages/numpy*
RUN pip3 install numpy==1.26.4 opencv-python==4.6.0.66 opencv-contrib-python
#RUN python3 /usr/local/zed/get_python_api.py