Skip to content

Commit fd88d2b

Browse files
committed
check for errors
1 parent 61622c0 commit fd88d2b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ggml/src/ggml-cuda/cpy.cu

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,16 @@ static __global__ void cpy_q_f32(const char * cx, char * cdst_direct, const int
349349

350350
void ggml_cuda_cpy_dest_ptrs_copy(ggml_cuda_graph * cuda_graph, char ** host_dest_ptrs, const int host_dest_ptrs_size, cudaStream_t stream) {
351351
#if defined(GGML_CUDA_USE_GRAPHS) || defined(GGML_HIP_GRAPHS)
352-
if(cuda_graph->dest_ptrs_size < host_dest_ptrs_size) { // (re-)allocate GPU memory for destination pointers
353-
cudaStreamSynchronize(stream);
354-
if (cuda_graph->dest_ptrs_d != nullptr) cudaFree(cuda_graph->dest_ptrs_d);
355-
cudaMalloc(&cuda_graph->dest_ptrs_d, host_dest_ptrs_size*sizeof(char *));
352+
if (cuda_graph->dest_ptrs_size < host_dest_ptrs_size) { // (re-)allocate GPU memory for destination pointers
353+
CUDA_CHECK(cudaStreamSynchronize(stream));
354+
if (cuda_graph->dest_ptrs_d != nullptr) {
355+
CUDA_CHECK(cudaFree(cuda_graph->dest_ptrs_d));
356+
}
357+
CUDA_CHECK(cudaMalloc(&cuda_graph->dest_ptrs_d, host_dest_ptrs_size*sizeof(char *)));
356358
cuda_graph->dest_ptrs_size = host_dest_ptrs_size;
357359
}
358360
// copy destination pointers to GPU
359-
cudaMemcpyAsync(cuda_graph->dest_ptrs_d, host_dest_ptrs, host_dest_ptrs_size*sizeof(char *), cudaMemcpyHostToDevice, stream);
361+
CUDA_CHECK(cudaMemcpyAsync(cuda_graph->dest_ptrs_d, host_dest_ptrs, host_dest_ptrs_size*sizeof(char *), cudaMemcpyHostToDevice, stream));
360362
cuda_graph->graph_cpynode_index = 0; // reset index
361363
#endif
362364
}

0 commit comments

Comments
 (0)