-
-
Notifications
You must be signed in to change notification settings - Fork 993
Container
This page covers the usage of Video2X's container image.
- Docker, Podman, or another OCI-compatible runtime
- A GPU that supports the Vulkan API
- Check the Vulkan Hardware Database to see if your GPU supports Vulkan
This section documents how to upscale a video to 720p with waifu2x. Replace $TAG
with the latest tag, which can be found here (e.g., 6.0.0-beta.3).
Make sure your host has the proper GPU and Vulkan libraries and drivers, then use the following command to launch the container:
docker run --gpus all -it --rm -v $PWD/data:/host ghcr.io/k4yt3x/video2x:$TAG -i standard-test.mp4 -o output.mp4 -f realesrgan -r 4 -m realesr-animevideov3
In addition to installing the proper drivers on your host, nvidia-docker2
(NVIDIA Container Toolkit) must also be installed on the host to use NVIDIA GPUs in containers. Below are how to install it for some of the popular Linux distributions:
- Debian/Ubuntu
- Follow the official guide to install
nvidia-docker2
- Follow the official guide to install
- Arch/Manjaro
- Install
nvidia-container-toolkit
from the AUR yay -S nvidia-container-toolkit
- Install
Once all the prerequisites are installed, you can launch the container:
docker run --gpus all -it --rm -v $PWD:/host ghcr.io/k4yt3x/video2x:$TAG -i standard-test.mp4 -o output.mp4 -f realesrgan -r 4 -m realesr-animevideov3
Depending on the version of your nvidia-docker and some other mysterious factors, you can also try setting no-cgroups = true
in /etc/nvidia-container-runtime/config.toml
and adding the NVIDIA devices into the container:
docker run --gpus all --device=/dev/nvidia0 --device=/dev/nvidiactl --runtime nvidia -it --rm -v $PWD:/host ghcr.io/k4yt3x/video2x:$TAG -i standard-test.mp4 -o output.mp4 -f realesrgan -r 4 -m realesr-animevideov3
If you are still getting a vkEnumeratePhysicalDevices failed -3
error at this point, try adding the --privileged
flag to give the container the same level of permissions as the host:
docker run --gpus all --privileged -it --rm -v $PWD:/host ghcr.io/k4yt3x/video2x:$TAG -i standard-test.mp4 -o output.mp4 -f realesrgan -r 4 -m realesr-animevideov3
docker run -it --rm \ # remove the container when done
--device=/dev/dri \ # mount and enable the GPU (AMD only)
-v $PWD:/host \ # bind the current directory as the container's /host
ghcr.io/k4yt3x/video2x:$TAG \ # the container image's URL and tag (e.g., 5.0.0-cuda)
-i standard-test.mp4 \ # input file name
-o output.mp4 \ # output file name
-f realesrgan \ # filter to use
-r 4 \ # scaling ratio
-m realesr-animevideov3 # model to use
More detailed information will be added later.
Note
Information below are outdated.
NVIDIA GPUs With Old Drivers (Credit: @plambe)
The following is an example with nvidia driver version 460.91.03. Improvise based on what's on your system.
First find the exact driver version on your host OS by using nvidia-smi
:
[..]
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.91.03 Driver Version: 460.91.03 CUDA Version: 11.2 |
|-------------------------------+----------------------+----------------------+
[..]
In the example above, it's 460.91.03
. Then the exact name of the package within the container OS is needed. To get that, the following command can be used:
docker build - -t temporary_container_to_get_apt_list << EOF
FROM docker.io/nvidia/vulkan:1.2.133-450 AS builder
ENV DEBIAN_FRONTEND=noninteractive
RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-keyring_1.0-1_all.deb && dpkg -i cuda-keyring_1.0-1_all.deb
RUN rm /etc/apt/sources.list.d/cuda.list && apt-key del 7fa2af80 && apt-get update && apt search nvidia-driver-460 && apt policy nvidia-driver-460
EOF
docker image rm temporary_container_to_get_apt_list:latest
In short, the above creates a similar docker image, which is based on the same image as video2x's image, specifically docker.io/nvidia/vulkan:1.2.133-450
, applies some patches, gets some data and deletes this image as it's no longer necessary. Here's the relevant part of the output of the above command:
[..]
Sorting...
Full Text Search...
nvidia-driver-460/unknown 460.106.00-0ubuntu1 amd64
NVIDIA driver metapackage
nvidia-driver-460-server/focal-updates,focal-security 470.103.01-0ubuntu0.20.04.1 amd64
Transitional package for nvidia-driver-470-server
nvidia-headless-460/unknown 460.106.00-0ubuntu1 amd64
NVIDIA headless metapackage
nvidia-headless-no-dkms-460/unknown 460.106.00-0ubuntu1 amd64
NVIDIA headless metapackage - no DKMS
xserver-xorg-video-nvidia-460/unknown 460.106.00-0ubuntu1 amd64
NVIDIA binary Xorg driver
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
nvidia-driver-460:
Installed: (none)
Candidate: 460.106.00-0ubuntu1
Version table:
470.103.01-0ubuntu0.20.04.1 500
500 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages
500 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages
460.106.00-0ubuntu1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 Packages
460.91.03-0ubuntu1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 Packages
460.73.01-0ubuntu1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 Packages
460.32.03-0ubuntu1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 Packages
460.27.04-0ubuntu1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 Packages
[..]
By default 460.106.00-0ubuntu1 would be installed, however we need specifically 460.91.03. A lot of packages within the container need to be downgraded to achieve this.
Below is an example Dockerfile, note the variables NVIDIA_DRIVER_MAJOR_VERSION=460
and NVIDIA_DRIVER_VERSION=460.91.03
, you can probably change them to suite your needs based on the information you just gathered:
# Name: Video1X Dockerfile
# Creator: K4YT3X
# Date Created: February 3, 2022
# Last Modified: March 28, 2022
# Patched by plambeto: April 10, 2022
# stage 1: build the python components into wheels
FROM docker.io/nvidia/vulkan:1.2.133-450 AS builder
ENV DEBIAN_FRONTEND=noninteractive
ENV DISTRO=ubuntu1804
ENV ARCH=x86_64
COPY . /video2x
WORKDIR /video2x
RUN wget https://developer.download.nvidia.com/compute/cuda/repos/$DISTRO/$ARCH/cuda-keyring_1.0-1_all.deb && \
dpkg -i cuda-keyring_1.0-1_all.deb
RUN rm /etc/apt/sources.list.d/cuda.list && \
apt-key del 7fa2af80 && \
apt-get update && \
apt search nvidia-driver-460 && \
apt policy nvidia-driver-460 && \
apt-get install -y --no-install-recommends \
python3.8 python3-pip python3-opencv python3-pil \
python3.8-dev libvulkan-dev glslang-dev glslang-tools \
build-essential swig \
&& pip wheel -w /wheels wheel pdm-pep517 .
# stage 2: install wheels into the final image
FROM docker.io/nvidia/vulkan:1.2.133-450
LABEL maintainer="K4YT3X <i@k4yt3x.com>" \
org.opencontainers.image.source="https://github.com/k4yt3x/video2x" \
org.opencontainers.image.description="A lossless video/GIF/image upscaler"
ENV DEBIAN_FRONTEND=noninteractive
ENV VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json\
:/usr/share/vulkan/icd.d/radeon_icd.x86_64.json\
:/usr/share/vulkan/icd.d/intel_icd.x86_64.json
ENV NVIDIA_DRIVER_MAJOR_VERSION=460
ENV NVIDIA_DRIVER_VERSION=460.91.03
ENV DISTRO=ubuntu1804
ENV ARCH=x86_64
COPY --from=builder /var/lib/apt/lists* /var/lib/apt/lists/
COPY --from=builder /wheels /wheels
COPY . /video2x
WORKDIR /video2x
RUN wget https://developer.download.nvidia.com/compute/cuda/repos/$DISTRO/$ARCH/cuda-keyring_1.0-1_all.deb && \
dpkg -i cuda-keyring_1.0-1_all.deb
RUN rm /etc/apt/sources.list.d/cuda.list && \
apt-key del 7fa2af80 && \
apt-get update && \
apt install -y --allow-downgrades \
cuda-drivers-${NVIDIA_DRIVER_MAJOR_VERSION}=${NVIDIA_DRIVER_VERSION}-1 nvidia-driver-${NVIDIA_DRIVER_MAJOR_VERSION}=${NVIDIA_DRIVER_VERSION}-0ubuntu1 \
libnvidia-gl-${NVIDIA_DRIVER_MAJOR_VERSION}=${NVIDIA_DRIVER_VERSION}-0ubuntu1 nvidia-dkms-${NVIDIA_DRIVER_MAJOR_VERSION}=${NVIDIA_DRIVER_VERSION}-0ubuntu1 \
nvidia-kernel-source-${NVIDIA_DRIVER_MAJOR_VERSION}=${NVIDIA_DRIVER_VERSION}-0ubuntu1 libnvidia-compute-${NVIDIA_DRIVER_MAJOR_VERSION}=${NVIDIA_DRIVER_VERSION}-0ubuntu1 \
libnvidia-extra-${NVIDIA_DRIVER_MAJOR_VERSION}=${NVIDIA_DRIVER_VERSION}-0ubuntu1 nvidia-compute-utils-${NVIDIA_DRIVER_MAJOR_VERSION}=${NVIDIA_DRIVER_VERSION}-0ubuntu1 \
libnvidia-decode-${NVIDIA_DRIVER_MAJOR_VERSION}=${NVIDIA_DRIVER_VERSION}-0ubuntu1 libnvidia-encode-${NVIDIA_DRIVER_MAJOR_VERSION}=${NVIDIA_DRIVER_VERSION}-0ubuntu1 \
nvidia-utils-${NVIDIA_DRIVER_MAJOR_VERSION}=${NVIDIA_DRIVER_VERSION}-0ubuntu1 xserver-xorg-video-nvidia-${NVIDIA_DRIVER_MAJOR_VERSION}=${NVIDIA_DRIVER_VERSION}-0ubuntu1 \
libnvidia-cfg1-${NVIDIA_DRIVER_MAJOR_VERSION}=${NVIDIA_DRIVER_VERSION}-0ubuntu1 libnvidia-ifr1-${NVIDIA_DRIVER_MAJOR_VERSION}=${NVIDIA_DRIVER_VERSION}-0ubuntu1 \
libnvidia-fbc1-${NVIDIA_DRIVER_MAJOR_VERSION}=${NVIDIA_DRIVER_VERSION}-0ubuntu1 libnvidia-common-${NVIDIA_DRIVER_MAJOR_VERSION}=${NVIDIA_DRIVER_VERSION}-0ubuntu1 \
nvidia-kernel-common-${NVIDIA_DRIVER_MAJOR_VERSION}=${NVIDIA_DRIVER_VERSION}-0ubuntu1 && \
apt-get install -y --no-install-recommends \
python3-pip python3.8-dev \
python3-opencv python3-pil \
mesa-vulkan-drivers ffmpeg \
&& pip install --no-cache-dir --no-index -f /wheels . \
&& apt-get clean \
&& rm -rf /wheels /video2x /var/lib/apt/lists/*
WORKDIR /host
ENTRYPOINT ["/usr/bin/python3.8", "-m", "video2x"]