OpenShot/libopenshot

`cu->cuInit(0) failed -> CUDA_ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE` on Docker

Closed this issue · 1 comments

Hi, I'm currently trying to make libopenshot with GPU support to run on Docker. For some reason I can't make it work as expected.

This is my example code:

from openshot import FFmpegReader, FFmpegWriter, Settings
from contextlib import contextmanager
from typing import TypeVar, Generator

T = TypeVar('T')

@contextmanager
def openshot_closing(reader: T) -> Generator[T, None, None]:
    try:
        reader.Open()
        yield reader
    finally:
        if reader.IsOpen():
            reader.Close()

setting_instance = Settings.Instance()
setting_instance.HARDWARE_DECODER = 2 # setting encoder/decoder to cuda
setting_instance.HW_DE_DEVICE_SET = 0

with openshot_closing(FFmpegReader('video.mp4')) as reader:
    writer = FFmpegWriter('video_out.mp4')
    writer.SetVideoOptions(
        True,
        'libx265', reader.info.fps, reader.info.width, reader.info.height,
        reader.info.pixel_ratio, reader.info.interlaced_frame, reader.info.top_field_first, reader.info.video_bit_rate)
    with openshot_closing(writer) as c_writer:
        c_writer.WriteFrame(reader, 1, reader.info.video_length)

Error I got:

[AVHWDeviceContext @ 0x5e0293d1aa00] cu->cuInit(0) failed -> CUDA_ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE: forward compatibility was attempted on non supported HW

Set HARDWARE_DECODER to 0 works flawlessly. Confirmed that GPU works okay when I can run torch on this container.

My PC configuration:

GPU: NVIDIA GeForce RTX 3080
CPU: AMD Ryzen 9 5900X

Docker: Docker 26.1.1
NVIDIA Driver: version 535.171.04
CUDA version: 12.4
Docker `--gpu` flag: --gpus="all,'capabilities=compute,graphics,utility,video'"

Sorry, I mismatched CUDA version between Docker image and Driver. My driver is running at CUDA 12.1 but CUDA inside docker is 12.4