Skip to content

Commit ab33f7a

Browse files
authored
cuda : clear error after buffer allocation failure (#7376)
1 parent e23b974 commit ab33f7a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

ggml-cuda.cu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,8 @@ GGML_CALL static ggml_backend_buffer_t ggml_backend_cuda_buffer_type_alloc_buffe
539539
void * dev_ptr;
540540
cudaError_t err = cudaMalloc(&dev_ptr, size);
541541
if (err != cudaSuccess) {
542+
// clear the error
543+
cudaGetLastError();
542544
GGML_CUDA_LOG_ERROR("%s: allocating %.2f MiB on device %d: cudaMalloc failed: %s\n", __func__, size / 1024.0 / 1024.0, buft_ctx->device, cudaGetErrorString(err));
543545
return nullptr;
544546
}

0 commit comments

Comments
 (0)