Install Zivid in Docker

Prerequisites

The instructions for installing Zivid software in a Docker container depend on the hardware you are running on. Follow the instructions that apply to your setup.

Note

Windows is currently not supported, as OpenCL is not fully supported on Windows in a Docker container. These instructions are therefore for Ubuntu only.

Intel GPU drivers should already be installed on the host machine if you are using Intel. If not, download and install Intel drivers.

Download the following Dockerfile for a minimal Docker image using Zivid software on Ubuntu 22.04.

FROM ubuntu:22.04

RUN apt-get update && apt-get install --assume-yes \
    wget \
    intel-opencl-icd

RUN wget --quiet \
    https://downloads.zivid.com/sdk/releases/2.12.0+6afd4961-1/u22/zivid_2.12.0+6afd4961-1_amd64.deb \
    https://downloads.zivid.com/sdk/releases/2.12.0+6afd4961-1/u22/zivid-tools_2.12.0+6afd4961-1_amd64.deb \
    https://downloads.zivid.com/sdk/releases/2.12.0+6afd4961-1/u22/zivid-genicam_2.12.0+6afd4961-1_amd64.deb

RUN apt-get update
RUN apt-get install ./*.deb --assume-yes && rm ./*.deb

Navigate to the directory where you placed the Dockerfile, and build and run the container by running

sudo docker build -t <image> .
sudo docker run --interactive --tty --device=/dev/dri <image>

where <image> is your chosen name of the image, e.g. zivid. You should now be in an interactive session on Ubuntu with Zivid installed.

First, install NVIDIA drivers on the host machine if they are not installed. Then install the NVIDIA Container Toolkit on the host.

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
    sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
    sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list \
&& \
    sudo apt-get update

sudo apt-get install -y nvidia-container-toolkit

Then configure Docker to use the NVIDIA Container Runtime.

sudo nvidia-ctk runtime configure --runtime=docker

Restart the Docker daemon.

sudo systemctl restart docker

You should now be able to access your NVIDIA GPU through Docker. Download the following Dockerfile for a minimal Docker image using Zivid software on Ubuntu 22.04.

FROM ubuntu:22.04

RUN apt-get update && apt-get install --assume-yes \
    wget \
    ocl-icd-libopencl1

RUN mkdir -p /etc/OpenCL/vendors && \
    echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd

ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility

RUN wget --quiet \
    https://downloads.zivid.com/sdk/releases/2.12.0+6afd4961-1/u22/zivid_2.12.0+6afd4961-1_amd64.deb \
    https://downloads.zivid.com/sdk/releases/2.12.0+6afd4961-1/u22/zivid-tools_2.12.0+6afd4961-1_amd64.deb \
    https://downloads.zivid.com/sdk/releases/2.12.0+6afd4961-1/u22/zivid-genicam_2.12.0+6afd4961-1_amd64.deb

RUN apt-get update
RUN apt-get install ./*.deb --assume-yes && rm ./*.deb

Navigate to the directory where you placed the Dockerfile, and build and run the container by running

sudo docker build -t <image> .
sudo docker run --interactive --tty --device=/dev/dri --gpus=all <image>

where <image> is your chosen name of the image, e.g. zivid. You should now be in an interactive session on Ubuntu with Zivid installed.

To verify that the Zivid SDK works as expected in the Docker container, you can run

ZividListCameras

If there are no errors then Zivid SDK is working within the Docker container.

Note

You will only be able to find a camera with default static IP 172.28.60.5. To connect to one or multiple cameras with a custom IP, follow Connecting to camera(s) in Docker.