title: clCreateCommandQueue fails with CL_INVALID_DEVICE
body: <p>I've successfully created an OpenCL context by calling <code>clCreateContextFromType</code>:</p>
  
  <pre><code>const cl_context_properties context_props[] = {
      CL_CONTEXT_PLATFORM, (cl_context_properties)cl-&gt;platform,
      CL_GL_CONTEXT_KHR, (cl_context_properties)interop_context-&gt;glx_context,
      CL_GLX_DISPLAY_KHR, (cl_context_properties)interop_context-&gt;x11_display,
      0,
  };
  
  cl-&gt;context = clCreateContextFromType(context_props, CL_DEVICE_TYPE_GPU, cl_error_cb, NULL, NULL);
  if(!cl-&gt;context) {
      LOG_ERROR("Failed to create OpenCL context");
      free(cl);
      return NULL;
  }
  </code></pre>
  
  <p>Then I've queried said context for the actual device via a call to <code>clGetContextInfo</code> with <code>CL_CONTEXT_DEVICES</code> parameter, and used the first (and, on my computer, only) device id listed in the result:</p>
  
  <pre><code>clGetContextInfo(cl-&gt;context, CL_CONTEXT_DEVICES, num_devices * sizeof(cl_uint), cl_devices, NULL);
  cl-&gt;device = cl_devices[0];
  </code></pre>
  
  <p>Yet, when I try to create a command queue via a call to <code>clCreateCommandQueue</code> it fails with <code>CL_INVALID_DEVICE</code> error:</p>
  
  <pre><code>cl_command_queue_properties props = CL_QUEUE_PROFILING_ENABLE;
  
  cl_int error;
  cl_command_queue queue = clCreateCommandQueue(cl-&gt;context, cl-&gt;device, props, &amp;error);
  if(!queue) {
      LOG_ERROR("Failed to create CL command queue: %d", error);
      return NULL;
  }
  </code></pre>
  
  <p>OpenCL documentation clearly states that <code>CL_INVALID_DEVICE</code> is returned "if device is not a valid device or is not associated with context".</p>
  
  <p>The device id I pass to <code>clCreateCommandQueue</code> is the same id that was returned by <code>clGetContextInfo</code> call so it definitely should be valid for this context.</p>
  
  <p>Why am I getting this error then? Is there anything wrong with my code?</p>
  
  <p>I'm running this on Linux x86_64 with a NVIDIA GeForce GTX 1070 GPU and NVIDIA's proprietary driver version 375.26. <code>clinfo</code> runs fine and returns correct information about 1 OpenCL platform with 1 device (my GPU). I tried running some OpenCL code samples and they all worked.</p>