在OpenCL中运行一些测试代码(使用Cloo C#)时,我开始从OpenCL中获取这些OutOfResource错误,有时,在获得异常之前,Unity就会完全崩溃。我基本上是一次又一次地调用一个内核函数,使用不同数量的全局/本地工作项来检查时间。我将参数保持不变,并调用内核,从2x2x2全局和2x2x2本地和迭代开始,只检查有效的大小。它偶尔可以正常工作,但大多数情况下,它完成大约30或40个Execute()调用,然后在下一个Execute()调用上崩溃。
注意:执行指计算机上的OpenCL.dll。由于本机代码,堆栈跟踪统一返回的值为NULL。
有人知道是什么导致了这一切吗?
注意:这个版本的Cloo是来自GitHub的,我正在使用它。得到错误时调用的等效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;
}发布于 2016-04-22 19:01:24
我只是重新发布了这篇文章,但这个问题与我每次调用Execute()方法时都不记得Kernel.SetArgument()这个事实有关。我最初这样做是因为我担心它会重新复制缓冲区,但是事实证明,缓冲区副本无论如何都不会在这个方法中出现(所以开销还是很小)。
发布于 2016-04-07 09:35:18
对不起,我不能评论少于50名代表的原因。但是您使用的是哪个操作系统呢?gpu?司机?opencl.dll引起了类似的问题,我使用了win10和Nvidia (x64)。也请看一下https://social.technet.microsoft.com/Forums/en-US/85680348-c2c4-40bc-9f39-9dcfeea331c0/windows-10-opencldll-error?forum=win10itprogeneral
win10中的内存压缩似乎存在/曾经存在问题。
我的问题是在没有更新nvidia驱动程序的情况下,将win7更新为win10造成的。
发布于 2016-04-29 04:14:12
你的nvidia显卡可以显示吗?如果nvidia是主要的显卡,你必须编辑注册表关闭看门狗。
对于windows 7
system/current/control/graphicsdriver
TdrLevel(DWORL) : 0https://stackoverflow.com/questions/36288766
复制相似问题