def get_cai_ptr(X):
    """
    Function gets the pointer from an object that supports the
    __cuda_array_interface__. Raises TypeError if `X` does not support it.
    """
    if hasattr(X, '__cuda_array_interface__'):
        return X.__cuda_array_interface__['data'][0]
    else:
        raise TypeError("X must support `__cuda_array_interface__`")