Properly use cudaGetLastError return code. (#18485)
authorEdward Yang <ezyang@fb.com>
Tue, 26 Mar 2019 19:17:31 +0000 (12:17 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 26 Mar 2019 19:26:44 +0000 (12:26 -0700)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18485

I don't know how (1) we landed the wrong version of the patch and (2) how
this passed the push blocking test

Reviewed By: pjh5

Differential Revision: D14621961

fbshipit-source-id: 0a3953d7adcdc79727a61c2acff65f436dcafe55

c10/cuda/CUDAFunctions.h

index 5597831..2af6925 100644 (file)
@@ -28,7 +28,8 @@ inline DeviceIndex device_count() noexcept {
     // Clear out the error state, so we don't spuriously trigger someone else.
     // (This shouldn't really matter, since we won't be running very much CUDA
     // code in this regime.)
-    cudaGetLastError();
+    cudaError_t last_err = cudaGetLastError();
+    (void)last_err;
     return 0;
   }
   return static_cast<DeviceIndex>(count);