Description
Using the Python API inside a docker container with a NON-root user, I get the following output when trying to open the camera object:
CAMERA FAILED TO SETUP
When the same attempt is performed with root, the output is SUCCESS
.
Steps to reproduce
- Create a docker image from the official stereolabs zed image, and add a user with sudo priviledges. Then add permissions for the zed folder and python libraries.
The following Dockerfile is suggested.
FROM stereolabs/zed:3.8-devel-cuda11.7-ubuntu20.04
ARG USERNAME=user
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
RUN chmod -R 777 /usr/local/zed/
RUN chmod -R 777 /usr/local/lib/python3.8/dist-packages/
WORKDIR /home/user
USER user
Save in a file called Dockerfile
and build with:
docker build -f Dockerfile -t zed:test .
- Then open the console in the docker container with GPU capabilities:
In host PC:
xhost +si:localuser:root
Then:
docker run --gpus all -it --privileged zed:test
- Execute the following script in
python3
:
import pyzed.sl as sl
zed = sl.Camera()
init_params = sl.InitParameters()
err = zed.open(init_params)
print(err)
Expected result:
SUCCESS
Actual result:
CAMERA FAILED TO SETUP
Setup
- Camera model: ZED2i
- OS: Ubuntu 22.04
- CPU: AMD64
- GPU: GeForce RTX 3080
- CUDA Version 11.7