Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

用C接口初始化一个模型,然后多线程去调用这个模型出bug #18476

Open
p517332051 opened this issue Jun 3, 2020 · 1 comment
Labels
Bug Thread Safety v1.x Targeting v1.x branch

Comments

@p517332051
Copy link

Description

(A clear and concise description of what the bug is.)
用C接口初始化一个模型,然后多线程去调用这个模型出bug。
后面查出来是这个文件下src/executor/graph_executor.cc的 1398行
/*
rshape = graph_.MoveCopyAttrmxnet::ShapeVector("shape");
/
他会把shape这个这个属性给erase掉,然后别的线程再跑到这行就报错,目前已经把1398行改成
/

if(is_train){
rshape = graph_.MoveCopyAttrmxnet::ShapeVector("shape");
}
else{
rshape = graph_.CopyAttrmxnet::ShapeVector("shape");
}

template
inline T Graph::CopyAttr(const std::string& attr_name) {
auto it = attrs.find(attr_name);
CHECK(it != attrs.end())
<< "Cannot find attribute " << attr_name << " in the graph";
std::shared_ptr sptr = it->second;
// attrs.erase(it);
if (sptr.unique()) {
return std::move(nnvm::get(*sptr));
} else {
return nnvm::get(*sptr);
}
}

*/

Error Message

(Paste the complete error message. Please also include stack trace by setting environment variable DMLC_LOG_STACK_TRACE_DEPTH=10 before running your script.)

To Reproduce

(If you developed your own code, please provide a short script that reproduces the error. For existing examples, please provide link.)

Steps to reproduce

(Paste the commands you ran that produced the error.)

What have you tried to solve it?

Environment

We recommend using our script for collecting the diagnositc information. Run the following command and paste the outputs below:

curl --retry 10 -s https://raw.githubusercontent.com/dmlc/gluon-nlp/master/tools/diagnose.py | python

# paste outputs here
@p517332051 p517332051 added the Bug label Jun 3, 2020
@szha szha added Thread Safety v1.x Targeting v1.x branch labels Aug 9, 2020
@szha
Copy link
Member

szha commented Aug 9, 2020

@p517332051 thread safety is not yet guaranteed on all C APis and executors. In 2.0 we dropped support for graph executor in favor of the cached op as the only executor. There is a thread-safe version of it from #16431

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Thread Safety v1.x Targeting v1.x branch
Projects
None yet
Development

No branches or pull requests

2 participants