Is there any method to only free device side for unified memory?

In our application, we use the unified memory for simplify. However, we would like to control the memory in some cases. For example, we would like the free the *S(point to a unified memory) only on the device side but remain the corresponding data on the host side.

  1. We free the *S on device side for device memory insufficient.
  2. We remain the *S on host side for we will use the data later and write back to disk may cause redundant disk IO.
    And we find cudaFree function will free the *S on device and host simultaneity.So if there are any method to free the device side with remaining the host side memory.Thanks!

There isn’t one that I know of. it would completely break the UM model.

If you are on a Pascal or Volta GPU on linux with the latest version of CUDA (9 or 9.1) this should be essentially unnecessary. The population of data on the device is by prefetching or demand-paging.

If you don’t use the data pointed to by *S on the device, it will eventually no longer be resident on the device or take up space in device memory, as subsequent prefetch or demand-paged data will displace it in device memory.

If you’re not in that regime, you could copy the data on the host from a managed to an unmanaged allocation, and then free up the *S pointer.