Docker に Zivid をインストールする

The instructions for installing Zivid software in a Docker container depend on your operating system and hardware. Follow the instructions that apply to your setup.

On Windows, Docker Desktop runs Linux containers through the WSL backend.

The Intel path uses the OpenCL compute backend. On WSL, OpenCL is not available to Docker containers, so the OpenCL backend cannot be used on Windows. Use the CUDA backend instead, as shown in the NVIDIA tab. This requires an NVIDIA GPU, so running Zivid in Docker on Windows is not possible with an Intel GPU.

On WSL, the NVIDIA GPU driver exposes CUDA to Docker containers, so the CUDA backend is used.

前提条件

  • Docker Desktop with the WSL 2 based engine enabled.

  • An NVIDIA GPU with a recent driver, verified by running nvidia-smi.

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

FROM nvidia/cuda:12.5.1-runtime-ubuntu24.04

RUN apt-get update && apt-get install --assume-yes \
    wget

ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility

RUN wget --quiet \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-cuda_2.18.0+1b44dbef-1_amd64.deb \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-tools_2.18.0+1b44dbef-1_amd64.deb \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-genicam_2.18.0+1b44dbef-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 from a Windows terminal by running

docker build -t <image> .
docker run --interactive --tty --gpus all <image>

where <image> is your chosen name of the image, e.g. zivid. The image already targets the CUDA backend, so no further configuration is needed.

To verify that the Zivid SDK works, connect to the camera by its IP address. Docker Desktop runs containers in the WSL virtual machine, which does not reach cameras on the LAN through mDNS discovery, so ZividListCameras will not find the camera on Windows. A direct connection by IP address does work.

Create a small program that connects to the camera, replacing 172.28.60.5 with your camera's IP address.

#include <Zivid/Zivid.h>
#include <iostream>

int main()
{
    Zivid::Application zivid;
    auto camera = zivid.connectCamera(Zivid::CameraAddress{ "172.28.60.5" });
    std::cout << "Connected to " << camera.info().serialNumber() << std::endl;
}

Build and run it inside the container. If it prints the camera serial number, the Zivid SDK is working. See Docker でカメラに接続する for more on connecting by IP address or hostname.

注釈

A camera can only be connected to from one place at a time. Disconnect the camera in Zivid Studio, or any other application, before connecting from the container. Otherwise the connection times out waiting for the camera to respond.

前提条件

Intel を使用している場合は、Intel GPU ドライバーがホストマシンに既にインストールされているはずです。インストールされていない場合は、 Intel drivers をダウンロードしてインストールしてください。

Ubuntu 24.04 上で Zivid ソフトウェアを使用する最小限の Docker イメージについては、次の Dockerfile をダウンロードしてください。

FROM ubuntu:24.04

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

RUN wget --quiet \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-opencl_2.18.0+1b44dbef-1_amd64.deb \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-tools_2.18.0+1b44dbef-1_amd64.deb \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-genicam_2.18.0+1b44dbef-1_amd64.deb

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

Dockerfile を配置したディレクトリに移動し、次のコマンドを実行してコンテナを構築して実行します。

sudo docker build -t <image> .
sudo docker run --interactive --tty --device=/dev/dri --network=host <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. The --network=host argument lets the container discover cameras on the host network.

まず、ホストマシンに NVIDIA drivers がインストールされていない場合はインストールしてください。次に、NVIDIA Container Toolkit をホストにインストールします。

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

次に、NVIDIA Container Runtime を使用するように Docker を構成します。

sudo nvidia-ctk runtime configure --runtime=docker

Docker デーモンを再起動します。

sudo systemctl restart docker

これで、Docker を介して NVIDIA GPU にアクセスできるようになります。Ubuntu 24.04 上で Zivid ソフトウェアを使用する最小限の Docker イメージについては、次の Dockerfile をダウンロードしてください。

FROM nvidia/cuda:12.5.1-runtime-ubuntu24.04

RUN apt-get update && apt-get install --assume-yes \
    wget

ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility

RUN wget --quiet \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-cuda_2.18.0+1b44dbef-1_amd64.deb \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-tools_2.18.0+1b44dbef-1_amd64.deb \
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u24/amd64/zivid-genicam_2.18.0+1b44dbef-1_amd64.deb

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

Dockerfile を配置したディレクトリに移動し、次のコマンドを実行してコンテナを構築して実行します。

sudo docker build -t <image> .
sudo docker run --interactive --tty --device=/dev/dri --gpus=all --network=host <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. The --network=host argument lets the container discover cameras on the host network.

To verify that the Zivid SDK works, run the following inside the container.

ZividListCameras

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

注釈

デフォルトの静的 IP アドレス 172.28.60.5 を持つカメラのみを見つけることができます。カスタム IP アドレスを持つ 1 つまたは複数のカメラに接続するには、 Docker でカメラに接続する を参照してください。

前提条件

  • Docker Engine

  • JetPack, which bundles the NVIDIA Container Runtime.

注釈

Because the NVIDIA Container Runtime is bundled with JetPack, you do not need to install the NVIDIA Container Toolkit.

The Dockerfiles provided on this page target x86 Ubuntu and are not compatible with Jetson, which is ARM64.

Choose the base image based on your JetPack version:

  • JetPack 5 and JetPack 6: use NVIDIA L4T Base (nvcr.io/nvidia/l4t-base). Select the tag that matches your installed JetPack, which you can find by running cat /etc/nv_tegra_release (for example, R36 (release), REVISION: 3.0 corresponds to tag r36.3.0).

  • JetPack 7 and later: use the same NVIDIA CUDA containers (nvcr.io/nvidia/cuda) as the NVIDIA tab.

A minimal Dockerfile looks like this, where <base-image> is the base image chosen above.

FROM <base-image>

RUN apt-get update && apt-get install --assume-yes \\
    wget

RUN wget --quiet \\
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u22/arm64/zivid-cuda_2.18.0+1b44dbef-1_arm64.deb \\
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u22/arm64/zivid-tools_2.18.0+1b44dbef-1_arm64.deb \\
    https://downloads.zivid.com/sdk/releases/2.18.0+1b44dbef-1/u22/arm64/zivid-genicam_2.18.0+1b44dbef-1_arm64.deb

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

Match the Ubuntu version in the package URLs (u22 or u24) to your JetPack version, as listed in Jetson Linux に Zivid をインストールする.

Run the container by running

sudo docker run --interactive --tty --runtime=nvidia --gpus=all --network=host <image>

where <image> is your chosen name of the image, e.g. zivid. The --network=host argument lets the container discover cameras on the host network.

To verify that the Zivid SDK works, run the following inside the container.

ZividListCameras

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

Version History

SDK

Changes

2.18.0

Added support for running Zivid in Docker on Windows, through the WSL backend with the CUDA compute backend.