From ca71f59b9cd502f9d1651b418b53d1b2b537b2ab Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Thu, 29 Aug 2024 11:49:32 +0200 Subject: [PATCH] vcomp/cmpto_j2k: disable CUDA buffers with |GPU|>1 Disable copying to CUDA buffers if there is more CUDA devices configured, it does cause the following error: ``` [J2K enc.] Setting image samples: Cannot configure input samples in CUDA buffer because argument 'device_id' doesn't match the configured CUDA device in encoder. Single CUDA encoder must be configured. ``` --- src/video_compress/cmpto_j2k.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/video_compress/cmpto_j2k.cpp b/src/video_compress/cmpto_j2k.cpp index 535e8ea91..ee4ecf451 100644 --- a/src/video_compress/cmpto_j2k.cpp +++ b/src/video_compress/cmpto_j2k.cpp @@ -44,8 +44,7 @@ * the GPU encoder. * * @todo - * - check multiple CUDA devices - now the data are always copied to - * the first CUDA device + * - check support for multiple CUDA devices with CUDA buffers */ #ifdef HAVE_CONFIG_H @@ -220,13 +219,17 @@ static bool configure_with(struct state_video_compress_j2k *s, struct video_desc s->pool_in_device_memory = false; #ifdef HAVE_CUDA - if (s->convertFunc == nullptr) { + if (s->convertFunc == nullptr && cuda_devices_count == 1) { s->pool_in_device_memory = true; s->pool = video_frame_pool( s->max_in_frames, cmpto_j2k_enc_cuda_buffer_data_allocator< cuda_wrapper_malloc, cuda_wrapper_free>()); } else { + if (cuda_devices_count > 1) { + MSG(WARNING, "More than 1 CUDA device will use CPU " + "buffers. Please report...\n"); + } s->pool = video_frame_pool( s->max_in_frames, cmpto_j2k_enc_cuda_buffer_data_allocator< @@ -438,10 +441,6 @@ static struct module * j2k_compress_init(struct module *parent, const char *c_cf CHECK_OK(cmpto_j2k_enc_ctx_cfg_add_cuda_device(ctx_cfg, cuda_devices[i], mem_limit, tile_limit), "Setting CUDA device", goto error); } - if (cuda_devices_count > 1) { - MSG(WARNING, "More than one CUDA device is not tested and may " - "not work. Please report...\n"); - } CHECK_OK(cmpto_j2k_enc_ctx_create(ctx_cfg, &s->context), "Context create", goto error);