How to check if a pointer points to allocated GPU memory?

I’m wondering if there is a way to determine if a pointer points to a memory allocated on GPU or CPU.
This seems like a trivial problem, but I can’t fine the appropriate API to do this beside try to read memory and catch the error.
Thanks!

__host__ ​cudaError_t cudaPointerGetAttributes ( cudaPointerAttributes* attributes, const void* ptr )

https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__UNIFIED.html#group__CUDART__UNIFIED_1gd89830e17d399c064a2f3c3fa8bb4390

Great, thanks!