This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

The following commit(s) were added to refs/heads/master by this push:
     new a077da895b avfilter/dnn_backend_torch: add CUDA/ROCm device support
a077da895b is described below

commit a077da895b489852ceb948f077796e250ff48b78
Author:     stevxiao <[email protected]>
AuthorDate: Thu Feb 5 11:07:10 2026 -0500
Commit:     Guo Yejun <[email protected]>
CommitDate: Sat Mar 21 16:25:40 2026 +0800

    avfilter/dnn_backend_torch: add CUDA/ROCm device support
    
    Add support for CUDA and ROCm (AMD GPU) devices in the LibTorch DNN
    backend.
    
    This works for both NVIDIA CUDA and AMD ROCm, as PyTorch exposes ROCm
    through the CUDA-compatible API.
    
    Usage:
    
    ./ffmpeg -i input.mp4 -vf 
scale=224:224,format=rgb24,dnn_processing=dnn_backend=torch:model=sr_model_torch.pt:device=cuda
 output.mp4
    
    Reviewed-by: Guo Yejun <[email protected]>
    Signed-off-by: younengxiao <[email protected]>
---
 libavfilter/dnn/dnn_backend_torch.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavfilter/dnn/dnn_backend_torch.cpp 
b/libavfilter/dnn/dnn_backend_torch.cpp
index 99f55165f2..24a202f493 100644
--- a/libavfilter/dnn/dnn_backend_torch.cpp
+++ b/libavfilter/dnn/dnn_backend_torch.cpp
@@ -439,6 +439,13 @@ static DNNModel *dnn_load_model_th(DnnContext *ctx, 
DNNFunctionType func_type, A
 #else
         at::detail::getXPUHooks().initXPU();
 #endif
+    } else if (device.is_cuda()) {
+        // CUDA device - works for both NVIDIA CUDA and AMD ROCm (which uses 
CUDA-compatible API)
+        if (!torch::cuda::is_available()) {
+            av_log(ctx, AV_LOG_ERROR, "CUDA/ROCm is not available\n");
+            goto fail;
+        }
+        av_log(ctx, AV_LOG_INFO, "Using CUDA/ROCm device: %s\n", device_name);
     } else if (!device.is_cpu()) {
         av_log(ctx, AV_LOG_ERROR, "Not supported device:\"%s\"\n", 
device_name);
         goto fail;

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to