From eb9591b7479a916c24114f513b1fbe397dbbc963 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Thu, 31 Mar 2022 09:48:00 +0000 Subject: [PATCH] Make nvjpeg handle creation once_flag static --- torchvision/csrc/io/image/cuda/decode_jpeg_cuda.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchvision/csrc/io/image/cuda/decode_jpeg_cuda.cpp b/torchvision/csrc/io/image/cuda/decode_jpeg_cuda.cpp index 0ca8fc46678..ee7d432f30d 100644 --- a/torchvision/csrc/io/image/cuda/decode_jpeg_cuda.cpp +++ b/torchvision/csrc/io/image/cuda/decode_jpeg_cuda.cpp @@ -71,7 +71,7 @@ torch::Tensor decode_jpeg_cuda( at::cuda::CUDAGuard device_guard(device); // Create global nvJPEG handle - std::once_flag nvjpeg_handle_creation_flag; + static std::once_flag nvjpeg_handle_creation_flag; std::call_once(nvjpeg_handle_creation_flag, []() { if (nvjpeg_handle == nullptr) { nvjpegStatus_t create_status = nvjpegCreateSimple(&nvjpeg_handle);