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

How to control the number of threads when running sequential with Keras #4740

Closed
keddiezhao opened this issue Dec 16, 2016 · 2 comments
Closed

Comments

@keddiezhao
Copy link

I try to run sequential with Keras; I found that the thread running sequential model generated about 13 sub-threads. How to control the number of sub-threads?

part of my code:
model = Sequential()
model.add(...)
.....
model.compile(loss='binary_crossentropy', optimizer=params['optimizer'])
model.fit(.....)

Please help me with this problem. Thanks in advance!

@keddiezhao
Copy link
Author

More detail to be added, the backbench for my Keras is Tensor Flow.

@Hudler
Copy link

Hudler commented Dec 20, 2016

This is what I use.

from keras import backend as K
import tensorflow as tf

config = tf.ConfigProto(intra_op_parallelism_threads=args.jobs, \ 
                        inter_op_parallelism_threads=args.jobs, \
                        allow_soft_placement=True, \
                        device_count = {'CPU': args.jobs})
session = tf.Session(config=config)
K.set_session(session)

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

No branches or pull requests

2 participants