cuPointerGetAttribute() fails with CUDA_ERROR_INVALID_DEVICE

I am trying to pin the device memory (using the kernel api nvidia_p2p_get_pages). However, I always get CUDA_ERROR_INVALID_DEVICE in the process of getting the tokens using cuPointerGetAttribute(). I use Geforce 670 (and tried it using 650) and cuda 6.0 toolkit. I see that unified addressing capability is enabled in these cards. Here is the snippet of code that tries to fetch the tokens.

checkCudaErrors(cuMemAlloc(&mem, size));
checkCudaErrors(cuPointerGetAttribute(&tokens, CU_POINTER_ATTRIBUTE_P2P_TOKENS, mem));

Any pointers on why I receive this error would be really helpful.