Install Zivid in Docker
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.
Prerequisites
Intel을 사용하는 경우 호스트 컴퓨터에 Intel GPU 드라이버가 이미 설치되어 있어야 합니다. 그렇지 않은 경우 Intel drivers 를 다운로드하여 설치하세요.
Zivid 소프트웨어를 사용하여 Ubuntu 24.04에서 최소 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 드라이버 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
그런 다음 Docker를 구성하여 NVIDIA Container Runtime을 사용합니다.
sudo nvidia-ctk runtime configure --runtime=docker
Docker daemon을 다시 시작합니다.
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로 하나 또는 여러 대의 카메라에 연결하려면 Connecting to camera(s) in Docker 를 참고하세요.
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.
Prerequisites
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 Connecting to camera(s) in 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.
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. |