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

Can we disable tensorflow's theading? #11066

Closed
ghost opened this issue Jun 26, 2017 · 10 comments
Closed

Can we disable tensorflow's theading? #11066

ghost opened this issue Jun 26, 2017 · 10 comments
Labels
type:support Support issues

Comments

@ghost
Copy link

ghost commented Jun 26, 2017

I'm running tensorflow in a simulator that does not support mult-threading. Is it possible to disable tensorflow's multi-threading?

@alextp
Copy link
Contributor

alextp commented Jun 26, 2017

No. It is possible to use a single executor thread and a single eigen thread, but the API as designed is likely to deadlock if you have no threads.

@aselle aselle added stat:awaiting response Status - Awaiting response from author type:support Support issues labels Jun 26, 2017
@ghost
Copy link
Author

ghost commented Jun 26, 2017

Can you elaborate on how to use a single executor thread and a single eigen thread? I tracked down the error and the deepest failure point i can find is "impl_.reset(new ThreadPool::Impl(env, thread_options, "tf_" + name, num_threads, low_latency_hint));"

@alextp
Copy link
Contributor

alextp commented Jun 26, 2017

The ConfigProto you pass to the first session you build in a process lets you specify how many dispatch and compute threads to use.

@ghost
Copy link
Author

ghost commented Jun 26, 2017

I forgot to mention I'm using C++., Do you know how to do that in C++? Also to confirm, you mean it is impossible to have no thread, at least two treads, one executor and one eigen are needed, right?

@alextp
Copy link
Contributor

alextp commented Jun 26, 2017

In C++ you can also use a configproto in sessionoptions: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/public/session_options.h

The minimum I know you can have is 3 threads: the two you mentioned and the one which is calling tf code.

@aselle aselle removed the stat:awaiting response Status - Awaiting response from author label Jun 26, 2017
@ghost
Copy link
Author

ghost commented Jun 27, 2017

I changed num_threads at line 116 in threadpool.cc to 0 and I bypassed the threading error but of course when I do sesson.run() I got pointer pointing to invalid address.

@ghost ghost changed the title Can we disable tensorflow's ttheading? Can we disable tensorflow's theading? Jun 27, 2017
@alextp
Copy link
Contributor

alextp commented Jun 27, 2017 via email

@mrlzla
Copy link

mrlzla commented Jun 28, 2017

try this:

tensorflow::SessionOptions GetSessionOptions()
{
	tensorflow::SessionOptions sessionOptions;
	tensorflow::ConfigProto& config = sessionOptions.config;
	config.set_intra_op_parallelism_threads(1);
	config.set_inter_op_parallelism_threads(1);
	return sessionOptions;
}
std::unique_ptr<tensorflow::Session> session;
session.reset(tensorflow::NewSession(GetSessionOptions()));

@ghost
Copy link
Author

ghost commented Jun 28, 2017

I've tried that. Any non zero value would cause my simulator to crash.

@ali01
Copy link

ali01 commented Jun 30, 2017

This question is better asked on StackOverflow since it is not a bug or feature request. There is also a larger community that reads questions there. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:support Support issues
Projects
None yet
Development

No branches or pull requests

4 participants