From a1d11bb175cf46bc45c1e56077696b0d566eecd7 Mon Sep 17 00:00:00 2001 From: nhzlx Date: Mon, 25 Mar 2019 04:22:39 +0000 Subject: [PATCH] fix ci bug: cudnn handler in multi card test=develop --- paddle/fluid/platform/device_context.cc | 3 +-- paddle/fluid/platform/device_context.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/platform/device_context.cc b/paddle/fluid/platform/device_context.cc index 961e8271e18..48002a76202 100644 --- a/paddle/fluid/platform/device_context.cc +++ b/paddle/fluid/platform/device_context.cc @@ -212,6 +212,7 @@ class EigenCudaStreamDevice : public Eigen::StreamInterface { CudnnHolder::CudnnHolder(const cudaStream_t* stream, const CUDAPlace& place) : workspace_(nullptr), stream_(stream), place_(place) { + PADDLE_ENFORCE(cudaSetDevice(place_.device)); PADDLE_ENFORCE(dynload::cudnnCreate(&cudnn_handle_)); PADDLE_ENFORCE(dynload::cudnnSetStream(cudnn_handle_, *stream_)); } @@ -233,8 +234,6 @@ void CudnnHolder::ReallocateWorkspace(size_t required_workspace_len) { paddle::memory::Allocator::kScratchpad); } -std::once_flag CUDADeviceContext::init_cudnn_; - CUDADeviceContext::CUDADeviceContext(CUDAPlace place) : place_(place), cudnn_holder_(nullptr) { CUDADeviceGuard guard(place_.device); diff --git a/paddle/fluid/platform/device_context.h b/paddle/fluid/platform/device_context.h index 296ecfc6f07..778f6613bd4 100644 --- a/paddle/fluid/platform/device_context.h +++ b/paddle/fluid/platform/device_context.h @@ -292,7 +292,7 @@ class CUDADeviceContext : public DeviceContext { private: CUDAPlace place_; - static std::once_flag init_cudnn_; + mutable std::once_flag init_cudnn_; std::unique_ptr eigen_device_; std::unique_ptr eigen_stream_; -- GitLab