diff --git a/cpp/include/raft/core/cudart_utils.hpp b/cpp/include/raft/core/cudart_utils.hpp index ce0d2a7025..7fe6ecaf6b 100644 --- a/cpp/include/raft/core/cudart_utils.hpp +++ b/cpp/include/raft/core/cudart_utils.hpp @@ -35,6 +35,7 @@ #include #include #include +#include #include ///@todo: enable once logging has been enabled in raft @@ -302,10 +303,10 @@ void print_device_vector(const char* variable_name, size_t componentsCount, OutStream& out) { - T* host_mem = new T[componentsCount]; - CUDA_CHECK(cudaMemcpy(host_mem, devMem, componentsCount * sizeof(T), cudaMemcpyDeviceToHost)); - print_host_vector(variable_name, host_mem, componentsCount, out); - delete[] host_mem; + auto host_mem = std::make_unique(componentsCount); + CUDA_CHECK( + cudaMemcpy(host_mem.get(), devMem, componentsCount * sizeof(T), cudaMemcpyDeviceToHost)); + print_host_vector(variable_name, host_mem.get(), componentsCount, out); } /**