From 0aeaeffb6c59d514d080db00078c6a59ef77d4e4 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Tue, 26 Mar 2019 12:17:31 -0700 Subject: [PATCH] Properly use cudaGetLastError return code. (#18485) 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/c10/cuda/CUDAFunctions.h b/c10/cuda/CUDAFunctions.h index 5597831..2af6925 100644 --- a/c10/cuda/CUDAFunctions.h +++ b/c10/cuda/CUDAFunctions.h @@ -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(count); -- 2.7.4