File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -157,19 +157,19 @@ class CudnnHolder {
157
157
158
158
void RunFunc (const std::function<void (void *)>& cudnn_func,
159
159
size_t required_workspace_len) {
160
- framework::RWLockGuard lock_guard (&rw_lock_,
161
- framework::RWLockGuard::Status::kRDLock );
160
+ std::lock_guard<std::mutex> lock (mtx_);
162
161
if (required_workspace_len > workspace_len_) {
163
- lock_guard.UnLock ();
164
- lock_guard.WRLock ();
165
162
ReallocateWorkspace (required_workspace_len);
166
- lock_guard.UnLock ();
167
- lock_guard.RDLock ();
168
163
}
169
164
cudnn_func (workspace_);
170
165
}
171
166
172
- ~CudnnHolder () { PADDLE_ENFORCE (dynload::cudnnDestroy (cudnn_handle_)); }
167
+ ~CudnnHolder () {
168
+ PADDLE_ENFORCE (dynload::cudnnDestroy (cudnn_handle_));
169
+ if (workspace_ != nullptr ) {
170
+ paddle::memory::Free (place_, workspace_);
171
+ }
172
+ }
173
173
174
174
private:
175
175
void ReallocateWorkspace (size_t required_workspace_len) {
@@ -194,7 +194,7 @@ class CudnnHolder {
194
194
const cudaStream_t* stream_; // not owned;
195
195
const CUDAPlace place_;
196
196
197
- framework::RWLock rw_lock_ ;
197
+ std::mutex mtx_ ;
198
198
};
199
199
200
200
CUDADeviceContext::CUDADeviceContext (CUDAPlace place)
You can’t perform that action at this time.
0 commit comments