Skip to content

Commit

Permalink
Fix issue with limit resource adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
viclafargue committed Oct 30, 2023
1 parent c34bcf0 commit 082ec5a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions cpp/src/umap/knn_graph/algo.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,17 @@ inline void launcher(const raft::handle_t& handle,
const ML::UMAPParams* params,
cudaStream_t stream)
{
size_t free_mem, total_mem;
cudaMemGetInfo(&free_mem, &total_mem);
double factor = 4.0;
raft::resources tmp_handle(handle);
raft::resource::set_workspace_resource(tmp_handle);
size_t free_size = raft::resource::get_workspace_free_bytes(tmp_handle);

double factor = 4.0;
size_t index_batch_size = inputsA.n;
size_t query_batch_size = inputsB.n;
size_t requirements = factor * sizeof(float) * index_batch_size * query_batch_size;
if (requirements > free_mem){
index_batch_size = free_mem / (query_batch_size * factor * sizeof(float));
size_t requirements = factor * sizeof(float) * index_batch_size * query_batch_size;

if (requirements > free_size) {
index_batch_size = free_size / (query_batch_size * factor * sizeof(float));
}

raft::sparse::selection::brute_force_knn(inputsA.indptr,
Expand Down

0 comments on commit 082ec5a

Please sign in to comment.