Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ee4c4e21
提交
ee4c4e21
authored
10月 05, 2016
作者:
Frédéric Bastien
提交者:
GitHub
10月 05, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4961 from nke001/ccw4102_cpy
ccw4102
上级
624164fc
524c623f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
56 行增加
和
19 行删除
+56
-19
profilemode.py
theano/compile/profilemode.py
+17
-0
profiling.py
theano/compile/profiling.py
+39
-19
没有找到文件。
theano/compile/profilemode.py
浏览文件 @
ee4c4e21
...
...
@@ -693,6 +693,23 @@ Test them first, as they are not guaranteed to always provide a speedup.""")
" generator supported on the GPU."
)
break
# tip 6
import
theano.sandbox.cuda
as
cuda
from
theano.tensor.nnet
import
LogSoftmax
import
theano.tensor.signal.pool
as
pool
import
theano.gpuarray
for
a
,
t
in
iteritems
(
apply_time
):
node
=
a
[
1
]
if
(
isinstance
(
node
.
op
,
pool
.
Pool
)):
if
(
not
cuda
.
dnn
.
dnn_available
()
and
not
theano
.
gpuarray
.
dnn
.
dnn_present
()):
print
(
"Install CuDNN to do pooling faster"
"this allows the operation to run on GPU"
)
if
(
isinstance
(
node
.
op
,
LogSoftmax
)):
if
(
not
cuda
.
dnn
.
dnn_available
()
and
not
theano
.
gpuarray
.
dnn
.
dnn_present
()):
print
(
"Install CuDNN to do LogSoftmax faster"
"this allows the operation to run on GPU"
)
if
not
printed_tip
:
print
(
" Sorry, no tip for today."
)
...
...
theano/compile/profiling.py
浏览文件 @
ee4c4e21
...
...
@@ -123,14 +123,14 @@ class ProfileStats(object):
"""
def
reset
(
self
):
""" Ignore previous function call"""
#self.compile_time = 0.
#
self.compile_time = 0.
self
.
fct_call_time
=
0.
self
.
fct_callcount
=
0
self
.
vm_call_time
=
0.
self
.
apply_time
=
{}
self
.
apply_callcount
=
{}
# self.apply_cimpl = None
#self.messge = None
#
self.messge = None
#
# Note on implementation:
# Class variables are used here so that each one can be
...
...
@@ -717,10 +717,10 @@ class ProfileStats(object):
max_sum_size
=
0
# statistics with the old and new order
stats
=
[[[
0
,
0
,
0
],
[
0
,
0
,
0
],
0
,
0
],
# old, with dmap
[[
0
,
0
,
0
],
[
0
,
0
,
0
],
0
,
0
],
# old, without dmap
[[
0
,
0
,
0
],
[
0
,
0
,
0
],
0
,
0
],
# new, with dmap
[[
0
,
0
,
0
],
[
0
,
0
,
0
],
0
,
0
]]
# new, without dmap
stats
=
[[[
0
,
0
,
0
],
[
0
,
0
,
0
],
0
,
0
],
# old, with dmap
[[
0
,
0
,
0
],
[
0
,
0
,
0
],
0
,
0
],
# old, without dmap
[[
0
,
0
,
0
],
[
0
,
0
,
0
],
0
,
0
],
# new, with dmap
[[
0
,
0
,
0
],
[
0
,
0
,
0
],
0
,
0
]]
# new, without dmap
# track min peak memory usage
min_max_peak
=
0
...
...
@@ -1072,6 +1072,7 @@ class ProfileStats(object):
# Store the max of some stats by any function in this profile.
max_sum_size
=
max
(
max_sum_size
,
sum_size
)
def
compute_max_stats
(
running_memory
,
stats
):
(
max_node_memory_size
,
max_running_max_memory_size
,
...
...
@@ -1108,7 +1109,7 @@ class ProfileStats(object):
(
order
,
True
),
(
new_order
,
False
),
(
new_order
,
True
)]):
running_memory
=
count_running_memory
(
running_memory
=
count_running_memory
(
ord
,
fgraph
,
nodes_mem
,
ignore_dmap
=
ignore_dmap
)
stats
[
i
]
=
compute_max_stats
(
running_memory
,
stats
[
i
])
...
...
@@ -1261,8 +1262,9 @@ class ProfileStats(object):
def
print_tips
(
self
,
file
):
print
(
"""Here are tips to potentially make your code run faster
(if you think of new ones, suggest them on the mailing list).
Test them first, as they are not guaranteed to always provide a speedup."""
,
file
=
file
)
Test them first, as they are not guaranteed to always provide a speedup."""
,
file
=
file
)
import
theano
RandomFunction
=
theano
.
tensor
.
raw_random
.
RandomFunction
scal
=
theano
.
scalar
T
=
theano
.
tensor
...
...
@@ -1310,7 +1312,7 @@ class ProfileStats(object):
return
True
elif
s_op
.
__class__
not
in
scalar_op_amdlibm_no_speed_up
:
print
(
"We don't know if amdlibm will accelerate "
"this scalar op."
,
s_op
,
file
=
file
)
"this scalar op."
,
s_op
,
file
=
file
)
return
False
def
exp_float32_op
(
op
):
...
...
@@ -1323,7 +1325,7 @@ class ProfileStats(object):
printed_tip
=
False
# tip 1
if
config
.
floatX
==
'float64'
:
print
(
" - Try the Theano flag floatX=float32"
,
file
=
file
)
print
(
" - Try the Theano flag floatX=float32"
,
file
=
file
)
printed_tip
=
True
# tip 2
...
...
@@ -1331,7 +1333,7 @@ class ProfileStats(object):
in
self
.
apply_time
]):
print
(
" - Try installing amdlibm and set the Theano flag "
"lib.amdlibm=True. This speeds up only some Elemwise "
"operation."
,
file
=
file
)
"operation."
,
file
=
file
)
printed_tip
=
True
# tip 3
...
...
@@ -1340,7 +1342,7 @@ class ProfileStats(object):
for
a
in
self
.
apply_time
]):
print
(
" - With the default gcc libm, exp in float32 is slower "
"than in float64! Try Theano flag floatX=float64, or "
"install amdlibm and set the theano flags lib.amdlibm=True"
,
file
=
file
)
"install amdlibm and set the theano flags lib.amdlibm=True"
,
file
=
file
)
printed_tip
=
True
# tip 4
...
...
@@ -1353,7 +1355,7 @@ class ProfileStats(object):
" dot22 (which is faster). Make sure the inputs are "
"float32 or float64, and are the same for both inputs. "
"Currently they are:
%
s"
%
[
i
.
type
for
i
in
node
.
inputs
],
file
=
file
)
[
i
.
type
for
i
in
node
.
inputs
],
file
=
file
)
printed_tip
=
True
# tip 5
...
...
@@ -1364,24 +1366,42 @@ class ProfileStats(object):
print
(
" - Replace the default random number generator by "
"'from theano.sandbox.rng_mrg import MRG_RandomStreams "
"as RandomStreams', as this is is faster. It is still "
"experimental, but seems to work correctly."
,
file
=
file
)
"experimental, but seems to work correctly."
,
file
=
file
)
if
config
.
device
.
startswith
(
"gpu"
):
print
(
" - MRG_RandomStreams is the only random number"
" generator supported on the GPU."
,
file
=
file
)
" generator supported on the GPU."
,
file
=
file
)
break
# tip 6
for
a
in
self
.
apply_time
:
node
=
a
if
(
isinstance
(
node
.
op
,
T
.
Dot
)
and
len
(
set
(
i
.
dtype
for
i
in
node
.
inputs
))
!=
1
):
if
(
isinstance
(
node
.
op
,
T
.
Dot
)
and
len
(
set
(
i
.
dtype
for
i
in
node
.
inputs
))
!=
1
):
print
(
" - You have a dot operation that has different dtype "
" for inputs (
%
s). Make sure that the inputs have same "
" dtype."
%
[
i
.
type
for
i
in
node
.
inputs
],
file
=
file
)
" dtype."
%
[
i
.
type
for
i
in
node
.
inputs
],
file
=
file
)
printed_tip
=
True
# tip 7
import
theano.sandbox.cuda
as
cuda
from
theano.tensor.nnet
import
LogSoftmax
import
theano.tensor.signal.pool
as
pool
import
theano.gpuarray
for
a
in
self
.
apply_time
:
node
=
a
if
(
isinstance
(
node
.
op
,
pool
.
Pool
)):
if
(
not
cuda
.
dnn
.
dnn_available
()
and
not
theano
.
gpuarray
.
dnn
.
dnn_present
()):
print
(
"Install CuDNN to do pooling faster"
"this allows the operation to run on GPU"
)
printed_tip
=
True
if
(
isinstance
(
node
.
op
,
LogSoftmax
)):
if
(
not
cuda
.
dnn
.
dnn_available
()
and
not
theano
.
gpuarray
.
dnn
.
dnn_present
()):
print
(
"Install CuDNN to do LogSoftmax faster"
"this allows the operation to run on GPU"
)
printed_tip
=
True
if
not
printed_tip
:
print
(
" Sorry, no tip for today."
,
file
=
file
)
print
(
" Sorry, no tip for today."
,
file
=
file
)
class
ScanProfileStats
(
ProfileStats
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论