Repository: incubator-singa Updated Branches: refs/heads/master 2608d4166 -> e527db986
Enable configuration of cudnn workspace size limit in PySINGA Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/e527db98 Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/e527db98 Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/e527db98 Branch: refs/heads/master Commit: e527db98614d9073b0f1d64eaeb3b17755650b12 Parents: 2608d41 Author: wangwei <[email protected]> Authored: Tue Apr 18 11:18:47 2017 +0800 Committer: wangwei <[email protected]> Committed: Tue Apr 18 11:18:47 2017 +0800 ---------------------------------------------------------------------- python/singa/layer.py | 9 +++++++-- src/model/layer/cudnn_convolution.cc | 2 +- src/proto/model.proto | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/e527db98/python/singa/layer.py ---------------------------------------------------------------------- diff --git a/python/singa/layer.py b/python/singa/layer.py index b985783..2ce204b 100644 --- a/python/singa/layer.py +++ b/python/singa/layer.py @@ -308,6 +308,7 @@ class Conv2D(Layer): cudnn_prefer (string): the preferred algorithm for cudnn convolution which could be 'fatest', 'autotune', 'limited_workspace' and 'no_workspace' + workspace_byte_limit(int): max workspace size in MB (default is 512MB) data_format (string): either 'NCHW' or 'NHWC' use_bias (bool): True or False pad: an integer or a pair of integers for padding height and width @@ -329,14 +330,16 @@ class Conv2D(Layer): """ def __init__(self, name, nb_kernels, kernel=3, stride=1, border_mode='same', - cudnn_prefer='fatest', data_format='NCHW', - use_bias=True, W_specs=None, b_specs=None, + cudnn_prefer='fatest', workspace_byte_limit=512, + data_format='NCHW', use_bias=True, W_specs=None, b_specs=None, pad=None, input_sample_shape=None): super(Conv2D, self).__init__(name) assert data_format == 'NCHW', 'Not supported data format: %s ' \ 'only "NCHW" is enabled currently' % (data_format) conf = self.conf.convolution_conf conf.num_output = nb_kernels + conf.prefer = cudnn_prefer + conf.workspace_byte_limit = workspace_byte_limit conf = _set_kernel_stride_pad(conf, kernel, stride, border_mode, pad) conf.bias_term = use_bias # TODO(wangwei) enable data format for cpp code @@ -374,6 +377,7 @@ class Conv1D(Conv2D): def __init__(self, name, nb_kernels, kernel=3, stride=1, border_mode='same', cudnn_prefer='fatest', + workspace_byte_limit=512, use_bias=True, W_specs={'init': 'Xavier'}, b_specs={'init': 'Constant', 'value': 0}, pad=None, input_sample_shape=None): @@ -384,6 +388,7 @@ class Conv1D(Conv2D): input_sample_shape = (1, 1, input_sample_shape[0]) super(Conv1D, self).__init__(name, nb_kernels, (1, kernel), (0, stride), border_mode, cudnn_prefer, + workspace_byte_limit, use_bias=use_bias, pad=pad, W_specs=W_specs, b_specs=b_specs, input_sample_shape=input_sample_shape) http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/e527db98/src/model/layer/cudnn_convolution.cc ---------------------------------------------------------------------- diff --git a/src/model/layer/cudnn_convolution.cc b/src/model/layer/cudnn_convolution.cc index cc78499..7d5e554 100644 --- a/src/model/layer/cudnn_convolution.cc +++ b/src/model/layer/cudnn_convolution.cc @@ -153,7 +153,7 @@ void CudnnConvolution::InitCudnn(const Tensor &input) { workspace_count_ = std::max(std::max(fp_byte, bp_data_byte), bp_filter_byte) / sizeof(float) + 1; - if (workspace_count_ > workspace_byte_limit_) + if (workspace_count_ * sizeof(float) > workspace_byte_limit_) LOG(WARNING) << "The required memory for workspace (" << workspace_count_ * sizeof(float) << ") is larger than the expected Bytes (" http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/e527db98/src/proto/model.proto ---------------------------------------------------------------------- diff --git a/src/proto/model.proto b/src/proto/model.proto index cfe946d..d4b85b6 100644 --- a/src/proto/model.proto +++ b/src/proto/model.proto @@ -689,7 +689,7 @@ message PoolingConf { // Added by xiangrui, 18 Oct, 2016 optional bool ceil = 60 [default = false]; -} +} message PowerConf { // PowerLayer computes outputs y = (shift + scale * x) ^ power.
