stereolabs / zed-python-api

Python API for the ZED SDK
https://www.stereolabs.com/docs/app-development/python/install/
MIT License
209 stars 95 forks source link

ModuleNotFoundError: No module named 'pyzed.sl' as non-root #220

Closed ArciAndres closed 1 year ago

ArciAndres commented 1 year ago

Preliminary Checks

Description

Hello! I am currently trying to integrate ZED SDK to an existing docker image, but I am experiencing some problems regarding the pyzed package. When I import it with the sl module as a non-root user, the following error is shown:

user@294679f21da6:/$ python3 
Python 3.8.10 (default, Jun 22 2022, 20:18:18) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyzed.sl as sl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyzed.sl'

But this error is not present when running as root or with sudo. This is a problem when integrating the library to other scripts that do not run as root.

Steps to Reproduce

It is assumed that the test is run on a system with a compatible Nvidia graphics card.

  1. Create a Dockerfile with the following content:
    
    FROM nvidia/cuda:11.7.0-runtime-ubuntu20.04

RUN apt-get update

RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata

RUN apt-get install -y sudo wget libgomp1 RUN apt-get install zstd RUN wget -O zed_sdk.run "https://download.stereolabs.com/zedsdk/3.8/cu117/ubuntu20" RUN bash zed_sdk.run -- silent skip_cuda RUN rm zed_sdk.run

RUN adduser user RUN usermod -aG sudo user RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers USER user

2. Build docker image with:

docker build -f Dockerfile -t zed:test .

3. Create the container and enter a command line console.

docker run -it --env="NVIDIA_DRIVER_CAPABILITIES=all" --runtime nvidia -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix zed:test bash

4 Try to import `pyzed.sl` inside the container.

python3 -c "import pyzed.sl as sl"

And the error described above should appear. 

### Expected Result

The command `import pyzed.sl as sl` runs successfully as a non-root user. 

### Actual Result

The command `import pyzed.sl as sl` throws an error.
`ModuleNotFoundError: No module named 'pyzed.sl'`

### ZED Camera model

ZED2i

### Environment

```shell
OS: Ubuntu 22.04
CPU: AMD64
GPU: GeForce RTX 3080
ZED  SDK version: v3.8
CUDA Version 11.7

Anything else?

It is presumed that the permissions of these folders are not correctly set:

/usr/local/zed
/usr/local/lib/python3.8/dist-packages/pyzed
/usr/local/lib/python3.8/dist-packages/pyzed-3.8.dist-info

The following command can be executed to actually test the camera and run the examples:

xhost +si:localuser:root  # allow containers to communicate with X server
fabrizioschiano commented 1 year ago

I was trying to understand this issue too. While reproducing it, if you have the problem:

docker: Error response from daemon: Unknown runtime specified nvidia.

while trying the following command specified by @ArciAndres

docker run -it --env="NVIDIA_DRIVER_CAPABILITIES=all" --runtime=nvidia -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix zed:test bash

You need to do

sudo apt install -y nvidia-docker2
sudo systemctl daemon-reload
sudo systemctl restart docker
github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment otherwise it will be automatically closed in 5 days