OpenCL error code detected:DeviceNotAvailable

Help
laterafter
2011-05-07
2012-12-21
  • laterafter
    laterafter
    2011-05-07

    Hello
    From time to time I have problem running simple application with Cloo. Exception is thrown on second line of this code:

    ComputeContextPropertyList cpl = new ComputeContextPropertyList(ComputePlatform.Platforms[0]);
                ComputeContext context = new ComputeContext(ComputeDeviceTypes.Gpu, cpl, null, IntPtr.Zero);
    

    Exception message: OpenCL error code detected: DeviceNotAvailable.

    I'm compiling with VisualStudio 2010, Cloo 0.9.0 on a laptop with Quadro 140M NVS and 260.99 notebook developer drivers.

     
  • nythrix
    nythrix
    2011-05-07

    According to Khronos this happens if: "…no devices that match device_type and property values specified in properties are currently available."

    I'm not sure how you would go about fixing this. Maybe you could try the following:

    ComputePlatform platform = ComputePlatform.Platforms[0];
    int i = 0;
    // keep checking until the device becomes available
    while (!platform.Devices[0].Available && i++ < 10)
        Thread.Sleep(10);
    if (i == 10) 
        /*do something*/;
    //else create context
    ComputeContext context = new ComputeContext(
        new ComputeDevice[]{platform.Devices[0]},
        new ComputeContextPropertyList(platform),
        null, IntPtr.Zero);
    

    The counter will enable you to quit the loop after some trying.