Skip to content

Commit 6abe03b

Browse files
authored
Merge pull request #13317 from velconia/fix_python35_CI_random_fail
Fix manylinux ci random fail problem
2 parents 41de582 + dc863aa commit 6abe03b

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

paddle/fluid/framework/parallel_executor.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,10 @@ void ParallelExecutor::FeedAndSplitTensorIntoLocalScopes(
352352
ParallelExecutor::~ParallelExecutor() {
353353
if (member_->own_local_scope_) {
354354
for (size_t i = 1; i < member_->local_scopes_.size(); ++i) {
355-
member_->global_scope_->DeleteScope(member_->local_scopes_[i]);
355+
Scope *local_scope = member_->local_scopes_[i];
356+
if (member_->global_scope_->HasKid(local_scope)) {
357+
member_->global_scope_->DeleteScope(local_scope);
358+
}
356359
}
357360
}
358361
}

paddle/fluid/framework/scope.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ void Scope::DropKids() {
7272
kids_.clear();
7373
}
7474

75+
bool Scope::HasKid(const Scope* scope) const {
76+
std::unique_lock<std::mutex> lock(mutex_);
77+
auto it = std::find(this->kids_.begin(), this->kids_.end(), scope);
78+
return it != this->kids_.end();
79+
}
80+
7581
std::vector<std::string> Scope::LocalVarNames() const {
7682
std::unique_lock<std::mutex> lock(mutex_);
7783
std::vector<std::string> known_vars;

paddle/fluid/framework/scope.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ class Scope {
7171
/// Drop all kids scopes belonged to this scope.
7272
void DropKids();
7373

74+
/// Find if a scope exists in the kid scopes
75+
bool HasKid(const Scope* scope) const;
76+
7477
// enumerate all the variables current contains.
7578
std::vector<std::string> LocalVarNames() const;
7679

python/paddle/fluid/tests/book/high-level-api/image_classification/test_image_classification_resnet.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,4 @@ def main(use_cuda, parallel):
178178
for parallel in (False, True):
179179
if use_cuda and not core.is_compiled_with_cuda():
180180
continue
181-
# TODO(minqiyang): remove this line after fixing the deletion
182-
# order problem of Scope in ParallelExecutor in manylinux
183-
if six.PY2:
184-
main(use_cuda=use_cuda, parallel=parallel)
181+
main(use_cuda=use_cuda, parallel=parallel)

python/paddle/fluid/tests/book/high-level-api/image_classification/test_image_classification_vgg.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,4 @@ def main(use_cuda, parallel):
152152
for parallel in (False, True):
153153
if use_cuda and not core.is_compiled_with_cuda():
154154
continue
155-
# TODO(minqiyang): remove this line after fixing the deletion
156-
# order problem of Scope in ParallelExecutor in manylinux
157-
if six.PY2:
158-
main(use_cuda=use_cuda, parallel=parallel)
155+
main(use_cuda=use_cuda, parallel=parallel)

python/paddle/fluid/tests/book/high-level-api/recognize_digits/test_recognize_digits_conv.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,4 @@ def main(use_cuda, parallel):
155155
for parallel in (False, True):
156156
if use_cuda and not core.is_compiled_with_cuda():
157157
continue
158-
# TODO(minqiyang): remove this line after fixing the deletion
159-
# order problem of Scope in ParallelExecutor in manylinux
160-
if six.PY2:
161-
main(use_cuda=use_cuda, parallel=parallel)
158+
main(use_cuda=use_cuda, parallel=parallel)

python/paddle/fluid/tests/book/high-level-api/recognize_digits/test_recognize_digits_mlp.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,4 @@ def main(use_cuda, parallel):
137137
for parallel in (False, True):
138138
if use_cuda and not core.is_compiled_with_cuda():
139139
continue
140-
# TODO(minqiyang): remove this line after fixing the deletion
141-
# order problem of Scope in ParallelExecutor in manylinux
142-
if six.PY2:
143-
main(use_cuda=use_cuda, parallel=parallel)
140+
main(use_cuda=use_cuda, parallel=parallel)

0 commit comments

Comments
 (0)