'Returns the primary context for the device.
Note: it is not pushed to the CPU thread.'

def get_primary_context(self):

    if (self.primary_context is not None):
        return self.primary_context
    met_requirement_for_device(self)
    hctx = drvapi.cu_context()
    driver.cuDevicePrimaryCtxRetain(byref(hctx), self.id)
    ctx = Context(weakref.proxy(self), hctx)
    self.primary_context = ctx
    return ctx
