Why is theano running so slow?

半腔热情 提交于 2020-02-03 09:12:14

问题


I'm new to Theano and trying out some examples.

import numpy
import theano.tensor as T
from theano import function
import datetime
print datetime.datetime.now()
x = T.dscalar('x')
y = T.dscalar('y')
z = x + y
f = function([x, y], z)
print f(2, 3)
print numpy.allclose(f(16.3, 12.1), 28.4)
print datetime.datetime.now()

And it took 15 minutes to run this. I'm using a 2GB ram, and there aren't many processes running simultaneously.


回答1:


Check the Theano Flags first.

If you didnt run with : THEANO_FLAGS=mode=FAST_RUN or ran with not the default flag or if you changed the .theanorc , it might take some time.

--

However, read here:

http://deeplearning.net/software/theano/tutorial/using_gpu.html

You can also see more about Theano Flags here:

http://deeplearning.net/software/theano/library/config.html

Since you must be running from an IDE, you will have to edit the .theanorc

As described on the Theano Link above:

" It defaults to $HOME/.theanorc. On Windows, it defaults to $HOME/.theanorc:$HOME/.theanorc.txt to make Windows users’ life easier. "

The exact flag is this :

config.mode

String value: 'Mode', 'ProfileMode' (deprecated), 'DebugMode', 'FAST_RUN', 'FAST_COMPILE'

In case this doesnt help, be sure to update Theano to bleeding edge and edit your question with the theanorc settings!

pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git


You can also use OpenMP to use extra Threads/cores :

THEANO_FLAGS=mode=FAST_RUN THEANO_FLAGS='openmp=True' OMP_NUM_THREADS=4 python x.py



来源:https://stackoverflow.com/questions/37768735/why-is-theano-running-so-slow

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!