Skip to content

Commit

Permalink
Fix OOM and cudaContext crash in C++ benchmarks (rapidsai#4594)
Browse files Browse the repository at this point in the history
Fix rapidsai#4525 as well as a hard crash in c++ benchmarks due to some recent changes in raft.

Authors:
  - Rory Mitchell (https://github.com/RAMitchell)

Approvers:
  - Dante Gama Dessavre (https://github.com/dantegd)

URL: rapidsai#4594
  • Loading branch information
RAMitchell authored Feb 24, 2022
1 parent 6b7c8ec commit 80c5379
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
7 changes: 7 additions & 0 deletions cpp/bench/prims/distance_common.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ struct Distance : public Fixture {
workspace.resize(worksize, stream);
}

void deallocateBuffers(const ::benchmark::State& state) override
{
x.release();
y.release();
out.release();
workspace.release();
}
void runBenchmark(::benchmark::State& state) override
{
loopOnState(state, [this]() {
Expand Down
7 changes: 6 additions & 1 deletion cpp/bench/prims/gram_matrix.cu
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ struct GramMatrix : public Fixture {
r.uniform(A.data(), params.m * params.k, T(-1.0), T(1.0), stream);
r.uniform(B.data(), params.k * params.n, T(-1.0), T(1.0), stream);
}

void deallocateBuffers(const ::benchmark::State& state) override
{
A.release();
B.release();
C.release();
}
void runBenchmark(::benchmark::State& state) override
{
if (!this->kernel) { state.SkipWithError("Kernel matrix is not initialized"); }
Expand Down
5 changes: 5 additions & 0 deletions cpp/bench/prims/make_blobs.cu
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ struct MakeBlobs : public Fixture {
labels.resize(params.rows, stream);
}

void deallocateBuffers(const ::benchmark::State& state) override
{
data.release();
labels.release();
}
void runBenchmark(::benchmark::State& state) override
{
loopOnState(state, [this]() {
Expand Down
2 changes: 1 addition & 1 deletion cpp/bench/sg/benchmark.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Fixture : public MLCommon::Bench::Fixture {
void SetUp(const ::benchmark::State& state) override
{
auto stream_pool = std::make_shared<rmm::cuda_stream_pool>(NumStreams);
handle.reset(new raft::handle_t{stream, stream_pool});
handle.reset(new raft::handle_t{rmm::cuda_stream_per_thread, stream_pool});
MLCommon::Bench::Fixture::SetUp(state);
}

Expand Down

0 comments on commit 80c5379

Please sign in to comment.