Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are RNNs thread-safe? #1335

Open
FilippoC opened this issue Mar 29, 2018 · 1 comment
Open

Are RNNs thread-safe? #1335

FilippoC opened this issue Mar 29, 2018 · 1 comment
Labels
minor bug Bugs that aren't too bad, only concern documentation, or have easy work-arounds

Comments

@FilippoC
Copy link
Contributor

Hi,

as far as I understand, we are allowed to create one computational graph per thread (or we can use the dynet multi-processing API).

Of course, parameters are shared (but not expressions).
However, the RNN API, using builder.new_graph(cg), does not seems thread-safe (ie. states are shared between threads).

In the example provided:

  1. this function is called for each thread https://github.com/clab/dynet/blob/master/examples/multiprocessing/rnnlm.h#L35
  2. one expression is created in each thread for each parameter, for example : https://github.com/clab/dynet/blob/master/examples/multiprocessing/rnnlm.h#L39
  3. however, the RNN internal expressions are shared https://github.com/clab/dynet/blob/master/examples/multiprocessing/rnnlm.h#L37
@neubig
Copy link
Contributor

neubig commented Apr 20, 2018

DyNet is not threadsafe yet, but this PR is aiming to make it so: #1064

Once this is merged, we can examine this issue further.

@neubig neubig added the minor bug Bugs that aren't too bad, only concern documentation, or have easy work-arounds label Apr 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor bug Bugs that aren't too bad, only concern documentation, or have easy work-arounds
Projects
None yet
Development

No branches or pull requests

2 participants