Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions c_api/gpu/DeviceUtils_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,12 @@ int faiss_gpu_sync_all_devices() {
}
CATCH_AND_HANDLE
}

/// Returns the free memory (in bytes) on the specified device
int faiss_get_free_memory(int device, size_t* p_free_bytes) {
try {
size_t freeBytes = faiss::gpu::getFreeMemory(device);
*p_free_bytes = freeBytes;
}
CATCH_AND_HANDLE
}
3 changes: 3 additions & 0 deletions c_api/gpu/DeviceUtils_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ int faiss_gpu_profiler_stop();
/// cudaDeviceSynchronize for each device)
int faiss_gpu_sync_all_devices();

/// Returns the free memory (in bytes) on the specified device
int faiss_get_free_memory(int device, size_t* p_free_bytes);

#ifdef __cplusplus
}
#endif
Expand Down