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

Keras use only single thread #1245

Closed
jalused opened this issue Dec 11, 2015 · 10 comments
Closed

Keras use only single thread #1245

jalused opened this issue Dec 11, 2015 · 10 comments

Comments

@jalused
Copy link

jalused commented Dec 11, 2015

I have installed keras on a redhat 6 server, it is really a attractive framework cause it is really easy to build a deep neural network. However, I found my keras use only single thread(or single core). I ran examples given in the source code package, such as "mnist_mlp.py", and used "top" command, found the usage of CPU is 100%, never more than CPU, I have 6 cores, each with four threads, no GPU, so hope keras can make efficient use of all cores, however, it use only one thread.
I don't know whether this is caused by my theano or blas.
Below is some information about my keras:

System: redhat 6
Theano: 0.7.0
numpy: 1.10.1
scipy: 0.16.1
BLAS: atlas 3.8.4-1.el6
keras: 0.2.0

Does anyone know how to fix this? I will appreciate any suggestion. Thanks very much.

ps: I can not make keras run with multithreads on Ubuntu 15.10 either.

@dandxy89
Copy link

Try switching the backend to Tensorflow

@SeverinAlexB
Copy link
Contributor

This enables multithreading in theano:
import theano
theano.config.openmp = True

@jalused
Copy link
Author

jalused commented Dec 11, 2015

@dandxy89 I switched backend to Tensoflow by modifying ~/.keras/keras.json, but it didn't work, thank for your reply anyway, any other idea?

@jalused
Copy link
Author

jalused commented Dec 11, 2015

@Sebubu I add "import theano theano.config.openmp = True" in the keras example "mnist_mlp.py", but it didn't work, thanks anyway. Any other idea?

@dandxy89
Copy link

@Jallet do any of the examples work for you, after you had switched the backend to "Tensorflow"?

@jalused
Copy link
Author

jalused commented Dec 11, 2015

@dandxy89 Yes, the example works, although still with one thread, I added "{"epsilon": 1e-07, "floatx": "float32", "backend": "tensorflow"}" in ~/.keras/keras.json according to the keras document.

@jalused
Copy link
Author

jalused commented Dec 11, 2015

@dandxy89 By the way, when I run "OMP_NUM_THREADS=2 python theano/misc/check_blas.py -q", the cpu usage of python is still at most 100%, never more than 100, and found only one core is being in use by command "htop", does this mean there is something wrong with my blas or openmp?
ps: If everyting is fine, when running keras' s example, should it use multi cores, or the cpu usage more than 100%

@nouiz
Copy link
Contributor

nouiz commented Dec 11, 2015

if check_blas.py only use one cores, it mean your BLAS is an single core
blas. Try to change it.

On Fri, Dec 11, 2015 at 8:52 AM, Liang Jiang notifications@github.com
wrote:

@dandxy89 https://github.com/dandxy89 By the way, when I run
"OMP_NUM_THREADS=2 python theano/misc/check_blas.py -q", the cpu usage of
python is still at most 100%, never more than 100, and found only one core
is being in use by command "htop", does this mean there is something wrong
with my blas or openmp?
ps: If everyting is fine, when running keras' s example, should it use
multi cores, or the cpu usage more than 100%


Reply to this email directly or view it on GitHub
#1245 (comment).

@fchollet
Copy link
Member

Try OpenBlas.

@georgegak
Copy link

import theano
theano.config.openmp = True

then after that write OMP_NUM_THREADS=4 python script_name.py and u re good to go

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

6 participants