簡體   English   中英

OpenCL Cloo:資源不足錯誤

[英]OpenCL Cloo: Out of Resources Error

在OpenCL中運行某些測試代碼(使用Cloo C#)時,我開始從OpenCL中獲取這些OutOfResource錯誤,有時Unity會在我收到異常之前完全崩潰。 我基本上是用不同數量的全局/本地工作項反復調用內核函數來檢查時間。 我將參數保持不變,並以全局2x2x2和局部2x2x2開頭並向上迭代以僅檢查有效大小來向上調用內核。 有時它可以正常工作,但是大多數情況下,它完成約30或40個Execute()調用,然后在下一個Execute()調用時崩潰。

注意:“執行”是指計算機上的OpenCL.dll。 由於本機代碼,我假設Unity返回的堆棧跟蹤為NULL。

任何人都不知道是什么原因造成的嗎?

注意:此版本的Cloo是GitHub上的Cloo-Unity,我在Unity中使用它。 當我收到錯誤消息時調用的等效OpenCL函數是clEnqueueNDRangeKernel(),但在Cloo中被稱為Execute()。

代碼示例:

//Setup inputs one time...
foreach (var input in p_inputs)
{
     inputs.Add(input.Function, input);
     profiles.Add(input.Function, new RunProfile(input.Function, input.Weight));
     input.Input.Prepare(package[input.Function]);
}


//Profile...
DateTime start;
int g_state = 0;
int l_state = 0;
long[] g = new long[3] { 2, 2, 2 };
long[] l = new long[3] { 2, 2, 2 };
while(g[0] * g[1] * g[2] < Device.MaxWorkGroupSize)
{
       l[0] = 2; l[1] = 2; l[2] = 2; l_state = 0; //Reset locals
       bool proceed = true;
       while(proceed)
       {
           proceed = (l[0] != g[0] || l[1] != g[1] || l[2] != g[2]);

           if (CLUtilities.ValidateExecutionParameters(Device, g, l))
           {
               Debug.Log("Profiling Start: " + g.ToEnumeratedString() + " / " + l.ToEnumeratedString());
               foreach (var profile in profiles)
               {
                   start = DateTime.Now;
                   //Exception here when on (g=6x4x4, l=6x4x4) 
                   package.Execute(package[profile.Key], g, l);
                   package.Commands.Flush();
                   package.Commands.Finish();
                   float time = (float)(DateTime.Now - start).TotalMilliseconds;
                   profile.Value.AddRun(g, l, time);
               }
               Debug.Log("Profiling Ending: " + g.ToEnumeratedString() + " / " + l.ToEnumeratedString());
           }

           l[l_state] += 2;
           l_state = (l_state == 2) ? 0 : l_state + 1;
       }

    g[g_state] += 2;
    g_state = (g_state == 2) ? 0 : g_state + 1;
}

抱歉,我無法發表評論,且少於50次。 但是您使用哪個操作系統? gpu? 司機? 我使用過win10和Nvidia(x64),這是由opencl.dll引起的類似問題。 也可以看看https://social.technet.microsoft.com/Forums/zh-CN/85680348-c2c4-40bc-9f39-9dcfeea331c0/windows-10-opencldll-error?forum=win10itprogeneral

看來Win10中的內存壓縮存在/存在問題。

我的問題是由於將win7更新為win10而沒有更新nvidia驅動程序引起的。

我只是回過頭來發布此消息,但是事實證明,這個問題與我每次調用Execute()方法時都沒有記得Kernel.SetArgument()的事實有關。 我最初這樣做是因為我擔心它會重新復制緩沖區,但是事實證明,無論如何此方法都不會發生緩沖區復制(因此開銷很小)。

您的nvidia顯卡是否可以顯示? 如果nvidia是主圖形卡,則必須編輯注冊表以關閉看門狗。

對於Windows 7

system/current/control/graphicsdriver 
TdrLevel(DWORL) : 0

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM