Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c732789b
提交
c732789b
authored
2月 03, 2016
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3966 from nouiz/dnn
add flag dnn.enabled
上级
d521a6c8
178d7932
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
60 行增加
和
10 行删除
+60
-10
config.txt
doc/library/config.txt
+14
-0
dnn.txt
doc/library/sandbox/cuda/dnn.txt
+17
-4
configdefaults.py
theano/configdefaults.py
+8
-0
dnn.py
theano/sandbox/cuda/dnn.py
+12
-6
dnn.py
theano/sandbox/gpuarray/dnn.py
+9
-0
没有找到文件。
doc/library/config.txt
浏览文件 @
c732789b
...
...
@@ -567,6 +567,20 @@ import theano and print the config variable, as in:
A directory with bin/, lib/, include/ folders containing cuda utilities.
.. attribute:: dnn.enabled
String value: ``auto``, ``True``, ``False``
Default ``auto``
If ``auto``, auto detect if cudnn is there, if not, do not use it,
but do not raise an error.
If ``True``, if we can't use cudnn, raise an error.
If ``False``, do not test if cudnn is there and don't use it.
Useful to disable it completely when the auto detection crashes.
.. attribute:: config.dnn.conv.workmem
Deprecated, use dnn.conv.algo_fwd.
...
...
doc/library/sandbox/cuda/dnn.txt
浏览文件 @
c732789b
...
...
@@ -38,7 +38,10 @@ By default, Theano will detect if it can use cuDNN. If so, it will use
it. If not, Theano optimizations will not introduce cuDNN ops. So
Theano will still work if the user did not introduce them manually.
To get an error if Theano can not use cuDNN, use this Theano flag:
The recently added Theano flag :attr:`dnn.enabled
<config.dnn.enabled>` allows to change the default behavior to force
it or disable it. Older Theano version do not support this flag. To
get an error when CuDNN can not be used with them, use this flag:
``optimizer_including=cudnn``.
.. note::
...
...
@@ -63,6 +66,8 @@ To get an error if Theano can not use cuDNN, use this Theano flag:
* ``large`` : use a sometimes faster implementation with large memory usage
* ``fft`` : use the Fast Fourrier Transform implementation of convolution
(very high memory usage)
* ``fft_tiling`` : use the Fast Fourrier Transform implementation of convolution
with tiling (high memory usage, but less then fft)
* ``guess_once`` : the first time a convolution is executed, the
implementation to use is chosen according to CuDNN's heuristics and reused
for every subsequent execution of the convolution.
...
...
@@ -76,9 +81,10 @@ To get an error if Theano can not use cuDNN, use this Theano flag:
implementation selected every time the shapes of the inputs and kernels
don't match the shapes from the last execution.
The Theano flag ``dnn.conv.algo_bwd`` allows to specify the CuDNN
convolution implementation that Theano should use for gradient convolutions.
Possible values include :
The Theano flag ``dnn.conv.algo_bwd_filter`` and
``dnn.conv.algo_bwd_data`` allows to specify the CuDNN
convolution implementation that Theano should use for gradient
convolutions. Possible values include :
* ``none`` (default) : use the default non-deterministic convolution
implementation
...
...
@@ -98,6 +104,13 @@ To get an error if Theano can not use cuDNN, use this Theano flag:
implementation selected every time the shapes of the inputs and kernels
don't match the shapes from the last execution.
* (algo_bwd_data only) ``fft_tiling`` : use the Fast Fourrier
Transform implementation of convolution with tiling (high memory
usage, but less then fft)
* (algo_bwd_data only) ``small`` : use a convolution implementation
with small memory usage
``guess_*`` and ``time_*`` flag values take into account the amount of
available memory when selecting an implementation. This means that slower
implementations might be selected if not enough memory is available for the
...
...
theano/configdefaults.py
浏览文件 @
c732789b
...
...
@@ -329,6 +329,14 @@ AddConfigVar('dnn.library_path',
"Location of the cudnn header (defaults to the cuda root)"
,
StrParam
(
default_dnn_path
(
'lib64'
)))
AddConfigVar
(
'dnn.enabled'
,
"'auto', use CuDNN if available, but silently fall back"
" to not using it if not present."
" If True and CuDNN can not be used, raise an error."
" If False, disable cudnn"
,
StrParam
(
"auto"
,
"True"
,
"False"
),
in_c_key
=
False
)
# This flag determines whether or not to raise error/warning message if
# there is a CPU Op in the computational graph.
AddConfigVar
(
...
...
theano/sandbox/cuda/dnn.py
浏览文件 @
c732789b
...
...
@@ -36,11 +36,13 @@ from theano.tensor.nnet.abstract_conv import (AbstractConv2d,
def
dnn_available
():
if
dnn_available
.
avail
is
None
:
if
not
theano
.
sandbox
.
cuda
.
cuda_available
:
dnn_available
.
msg
=
"CUDA not available"
dnn_available
.
avail
=
False
return
False
if
config
.
dnn
.
enabled
==
"False"
:
dnn_available
.
avail
=
False
dnn_available
.
msg
=
"disabled by dnn.enabled flag"
if
dnn_available
.
avail
is
None
and
not
theano
.
sandbox
.
cuda
.
cuda_available
:
dnn_available
.
msg
=
"CUDA not available"
dnn_available
.
avail
=
False
elif
dnn_available
.
avail
is
None
:
dev
=
theano
.
sandbox
.
cuda
.
active_device_number
()
if
theano
.
sandbox
.
cuda
.
device_properties
(
dev
)[
'major'
]
<
3
:
dnn_available
.
msg
=
"Device not supported by cuDNN"
...
...
@@ -100,7 +102,11 @@ if ((err = cudnnCreate(&_handle)) != CUDNN_STATUS_SUCCESS) {
"candidate) that isn't supported. Please update to "
"at least v3 final version."
)
raise
RuntimeError
(
dnn_available
.
msg
)
if
config
.
dnn
.
enabled
==
"True"
:
if
not
dnn_available
.
avail
:
raise
RuntimeError
(
"You enabled CuDNN, but we aren't able to use it:
%
s"
%
dnn_available
.
msg
)
return
dnn_available
.
avail
...
...
theano/sandbox/gpuarray/dnn.py
浏览文件 @
c732789b
...
...
@@ -86,6 +86,9 @@ def _dnn_check_version():
def
dnn_present
():
if
dnn_present
.
avail
is
not
None
:
return
dnn_present
.
avail
if
config
.
dnn
.
enabled
==
"False"
:
dnn_present
.
msg
=
"disabled by dnn.enabled flag"
dnn_present
.
avail
=
False
if
pygpu
is
None
:
dnn_present
.
msg
=
"PyGPU not available"
...
...
@@ -98,6 +101,12 @@ def dnn_present():
if
not
dnn_present
.
avail
:
raise
RuntimeError
(
dnn_present
.
msg
)
if
config
.
dnn
.
enabled
==
"True"
:
if
not
dnn_present
.
avail
:
raise
RuntimeError
(
"You enabled CuDNN, but we aren't able to use it:
%
s"
%
dnn_present
.
msg
)
return
dnn_present
.
avail
dnn_present
.
avail
=
None
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论