cuda : clear error after buffer allocation failure (#7376)

This commit is contained in:
slaren 2024-05-19 14:19:37 +02:00 committed by GitHub
parent e23b974f4c
commit ab33f7a338
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -539,6 +539,8 @@ GGML_CALL static ggml_backend_buffer_t ggml_backend_cuda_buffer_type_alloc_buffe
void * dev_ptr;
cudaError_t err = cudaMalloc(&dev_ptr, size);
if (err != cudaSuccess) {
// clear the error
cudaGetLastError();
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));
return nullptr;
}