From 18a05d269516a5e33d8460291c2f93e73d95adce Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期二, 26 十二月 2023 10:45:31 +0800
Subject: [PATCH] GetYUV format is NV12

---
 csrc/common/gpu/info.cpp |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/csrc/common/gpu/info.cpp b/csrc/common/gpu/info.cpp
index d19de83..3deada7 100644
--- a/csrc/common/gpu/info.cpp
+++ b/csrc/common/gpu/info.cpp
@@ -380,7 +380,7 @@
         int mem_idle = need;
         for(int i = 0; i < gpu_info.device_count; i++){
             if (i != lastChoice){
-                int mem_free = gpu_info.devices[i].memory_free >> 20;
+                int mem_free = (gpu_info.devices[i].memory_free >> 20) - reserved;
                 if(mem_free > mem_idle){
                     mem_idle = mem_free;
                     suitable_gpu = i;
@@ -412,6 +412,27 @@
 
     return -1;
 }
+
+bool satisfy(const int index, const int need, const int reserved){
+    nvGpuInfo_t gpu_info;
+
+    int ret = get_gpu_info(&gpu_info);
+    if(!ret){
+        if (gpu_info.device_count == 0) return -1;
+
+        for(int i = 0; i < gpu_info.device_count; i++){
+            if (i == index){
+                int mem_free = (gpu_info.devices[i].memory_free >> 20) - reserved - need;
+                if(mem_free > 0){
+                    return true;
+                }
+            }
+        }
+    }
+
+    return false;
+}
+
 int test(void)
 {
     nvGpuInfo_t gpu_buf;

--
Gitblit v1.8.0