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);