Просмотр исходного кода

Fixed WSL cuda's OOM error (#1594)

* In the function , add the cuda error bypass.

* remove excessive codes and prints

---------

Co-authored-by: liang <liangmanlai@126.com>
Kyle Liang 2 лет назад
Родитель
Сommit
12b063f0ec
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      ggml-cuda.cu

+ 3 - 0
ggml-cuda.cu

@@ -1105,6 +1105,9 @@ void * ggml_cuda_host_malloc(size_t size) {
     void * ptr = nullptr;
     void * ptr = nullptr;
     cudaError_t err = cudaMallocHost((void **) &ptr, size);
     cudaError_t err = cudaMallocHost((void **) &ptr, size);
     if (err != cudaSuccess) {
     if (err != cudaSuccess) {
+        // The allocation error can be bypassed. A null ptr will assigned out of this function.
+        // This can fixed the OOM error in WSL.
+        cudaGetLastError();
         fprintf(stderr, "WARNING: failed to allocate %.2f MB of pinned memory: %s\n",
         fprintf(stderr, "WARNING: failed to allocate %.2f MB of pinned memory: %s\n",
             size/1024.0/1024.0, cudaGetErrorString(err));
             size/1024.0/1024.0, cudaGetErrorString(err));
         return nullptr;
         return nullptr;