 
         cuda_internal::CudnnPoolingDescriptor pool_desc{cudnn_pooling_mode_, CUDNN_NOT_PROPAGATE_NAN, kernel_size_, pad_, stride_};
 
-        CheckCudnnError(cudnnPoolingBackward(
-                cudnn_handle_,
-                *pool_desc,
-                cuda_internal::GetValuePtr<1>(x_.dtype()),
-                *y_desc,
-                internal::GetRawOffsetData<void>(y_cont),
-                *gout_desc,
-                internal::GetRawOffsetData<void>(gout_cont),
-                *x_desc,
-                internal::GetRawOffsetData<void>(x_cont),
-                cuda_internal::GetValuePtr<0>(x_.dtype()),
-                *gx_desc,
-                internal::GetRawOffsetData<void>(gx)));
+        {
+            std::lock_guard<std::mutex> lock{device_.cudnn_handle_mutex()};
+            CheckCudnnError(cudnnPoolingBackward(
+                    device_.cudnn_handle(),
+                    *pool_desc,
+                    cuda_internal::GetValuePtr<1>(x_.dtype()),
+                    *y_desc,
+                    internal::GetRawOffsetData<void>(y_cont),
+                    *gout_desc,
+                    internal::GetRawOffsetData<void>(gout_cont),
+                    *x_desc,
+                    internal::GetRawOffsetData<void>(x_cont),
+                    cuda_internal::GetValuePtr<0>(x_.dtype()),
+                    *gx_desc,
+                    internal::GetRawOffsetData<void>(gx)));
+        }
 
         return gx;
     }

        const StackVector<int64_t, kMaxNdim>& stride,
        const StackVector<int64_t, kMaxNdim>& pad,
        AveragePoolPadMode pad_mode) {
    return std::make_unique<CudaAveragePoolForwardBackward>(cudnn_handle(), kernel_size, stride, pad, pad_mode);
}

}  // namespace cuda

class CudaMaxPoolForwardBackward : public chainerx::MaxPoolForwardBackward {
public:
    explicit CudaMaxPoolForwardBackward(
            CudaDevice& device,
            const StackVector<int64_t, kMaxNdim>& kernel_size,
            const StackVector<int64_t, kMaxNdim>& stride,
            const StackVector<int64_t, kMaxNdim>& pad,
            bool cover_all)
        : pool_impl_{device, kernel_size, stride, pad, cover_all, CUDNN_POOLING_MAX} {}

    Array Forward(const Array& x) override { return pool_impl_.Forward(x); }

