"invalid device pointer" error when calling cudaFree
Recently, I bumped into an error when calling cudaFree:  
invalid device pointer
After some debugging, I find the reason is program calls cudaDeviceReset before cudaFree. Since cudaDeviceReset will release all resources, invoking cudaFree will again generate error.