Skip to content

Commit c255a0f

Browse files
committed
move stream sync before free
1 parent 04a7307 commit c255a0f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ggml/src/ggml-cuda/cpy.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ static __global__ void cpy_q_f32(const char * cx, char * cdst_direct, const int
350350
void ggml_backend_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)
352352
if(cuda_graph->dest_ptrs_size < host_dest_ptrs_size) { // (re-)allocate GPU memory for destination pointers
353-
if (cuda_graph->dest_ptrs_d != nullptr) cudaFree(cuda_graph->dest_ptrs_d);
354353
cudaStreamSynchronize(stream);
354+
if (cuda_graph->dest_ptrs_d != nullptr) cudaFree(cuda_graph->dest_ptrs_d);
355355
cudaMalloc(&cuda_graph->dest_ptrs_d, host_dest_ptrs_size*sizeof(char *));
356356
cuda_graph->dest_ptrs_size = host_dest_ptrs_size;
357357
}

0 commit comments

Comments
 (0)