Skip to content

Multiple graphs in different threads #370

Closed

Description

@deadman2000

I've got this error:

Tensor tf.Tensor 'softmax_tensor:0' shape=(-1,2) dtype=TF_FLOAT is not an element of this graph.
   в Tensorflow.Graph._as_graph_element_locked(Object obj, Boolean allow_tensor, Boolean allow_operation)
   в Tensorflow._ElementFetchMapper..ctor(Object[] fetches, Func`2 contraction_fn)
   в Tensorflow._FetchMapper.for_fetch(Object fetch)
   в Tensorflow._FetchHandler..ctor(Graph graph, Object fetches, Dictionary`2 feeds, Action feed_handles)
   в Tensorflow.BaseSession._run(Object fetches, FeedItem[] feed_dict)
   в Tensorflow.BaseSession.run(Tensor fetche, FeedItem[] feed_dict)

Because _ElementFetchMapper getting default graph:

var g = ops.get_default_graph()

Activity

  1. added
    bug
    on Aug 30, 2019
  2. Nucs commented on Aug 30, 2019

    @Nucs
    Member

    We have been discussing multi-threading a lot lately,
    When initializing a model - it has to be done from a single-thread because there are a lot of tf.* methods that access graph by getting the default.
    You can later on use session.run(..) from multiple threads as Session class holds a reference to a graph internally.

    In the near future we plan to make get_default_graph and get_default_session as thread-wide (right now it is process-wide).

  3. deadman2000 commented on Aug 30, 2019

    @deadman2000
    Author

    My suggestion is deprecate get_default_graph and get_default_session

  4. Nucs commented on Aug 30, 2019

    @Nucs
    Member

    We wanted that too but this will force the user to pass graph or session to every single tf.* call and as a result break the ability to easily port python code to C#.

  5. Oceania2018 commented on Aug 30, 2019

    @Oceania2018
    Member

    Right, when users develop a model or training model, they want to share some global variables. It’s hard to change at this moment.

  6. Nucs commented on Aug 31, 2019

    @Nucs
    Member

    @deadman2000, I've added support for multithreading in PR #371
    It'll be released to nuget in a day or two as version 0.11.2.
    You can read more in-depth details in our wiki here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions