为什么 theano 运行这么慢? [英] Why is theano running so slow?

查看:32
本文介绍了为什么 theano 运行这么慢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Theano 的新手,正在尝试一些示例.

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()

运行这个需要 15 分钟.我使用的是 2GB 内存,同时运行的进程并不多.

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

推荐答案

首先检查 Theano 标志.

Check the Theano Flags first.

如果您没有使用:THEANO_FLAGS=mode=FAST_RUN 运行,或者没有使用默认标志运行,或者如果您更改了 .theanorc ,则可能需要一些时间.

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.

--

但是,请阅读此处:

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

您还可以在此处查看有关 Theano Flags 的更多信息:

You can also see more about Theano Flags here:

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

由于您必须从 IDE 运行,因此您必须编辑 .theanorc

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

如上面 Theano 链接所述:

As described on the Theano Link above:

"它默认为 $HOME/.theanorc.在 Windows 上,它默认为 $HOME/.theanorc:$HOME/.theanorc.txt 以使 Windows 用户的生活更轻松."

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

确切的标志是这样的:

config.mode

字符串值:'Mode'、'ProfileMode'(不推荐使用)、'DebugMode'、'FAST_RUN'、'FAST_COMPILE'

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

如果这没有帮助,请务必将 Theano 更新到前沿使用 theanorc 设置编辑您的问题

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

您还可以使用 OpenMP 来使用额外的线程/内核:

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

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

这篇关于为什么 theano 运行这么慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆