* In the function , add the cuda error bypass.
* remove excessive codes and prints
---------
Co-authored-by: liang <redacted>
void * ptr = nullptr;
cudaError_t err = cudaMallocHost((void **) &ptr, size);
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",
size/1024.0/1024.0, cudaGetErrorString(err));
return nullptr;