Repository: Theano/Theano

Issue:
After updating Theano weird problems when using GPU
Recently I've updated Theano to the master branch. However, this lead to the following error:
`
Exception: ('The following error happened while compiling the node', GpuDnnConvGradI{algo='none', inplace=True}(GpuContiguous.0, GpuContiguous.0, GpuAllocEmpty{dtype='float32', context_name=None}.0, GpuDnnConvDesc{border_mode='half', subsample=(1, 1), dilation=(1, 1), conv_mode='conv', precision='float32'}.0, Constant{1.0}, Constant{0.0}), '\n', "Compilation failed (return status=1): /home/abotev/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.6.0-64/tmpa8wrg7og/mod.cpp:442: error: a brace-enclosed initializer is not allowed here before '{' token. /home/abotev/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.6.0-64/tmpa8wrg7og/mod.cpp:442: error: ISO C++ forbids initialization of member 'prev_kern_dims'. /home/abotev/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.6.0-64/tmpa8wrg7og/mod.cpp:442: error: making 'prev_kern_dims' static. /home/abotev/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.6.0-64/tmpa8wrg7og/mod.cpp:442: error: invalid in-class initialization of static data member of non-integral type 'size_t [5]'. /home/abotev/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.6.0-64/tmpa8wrg7og/mod.cpp:443: error: a brace-enclosed initializer is not allowed here before '{' token. /home/abotev/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.6.0-64/tmpa8wrg7og/mod.cpp:443: error: ISO C++ forbids initialization of member 'prev_top_dims'. /home/abotev/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.6.0-64/tmpa8wrg7og/mod.cpp:443: error: making 'prev_top_dims' static. /home/abotev/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.6.0-64/tmpa8wrg7og/mod.cpp:443: error: invalid in-class initialization of static data member of non-integral type 'size_t [5]'. /home/abotev/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.6.0-64/tmpa8wrg7og/mod.cpp: In member function 'int<unnamed>::__struct_compiled_op_mc2bb2e24bb41d8af45c9d8be40d95ddd::conv_gi_node_mc2bb2e24bb41d8af45c9d8be40d95ddd_0(PyGpuArrayObject*, PyGpuArrayObject*, PyGpuArrayObject*, cudnnConvolutionStruct*, double, double, PyGpuArrayObject**, _Params_c626b80a28594f6fe623577946e29157_c29b5bb55c42161a5f82e1c2559749fa*)':. /home/abotev/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.6.0-64/tmpa8wrg7og/mod.cpp:558: error: 'prev_kern_dims' was not declared in this scope. /home/abotev/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.6.0-64/tmpa8wrg7og/mod.cpp:560: error: 'prev_top_dims' was not declared in this scope. /home/abotev/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.6.0-64/tmpa8wrg7og/mod.cpp:625: error: 'prev_kern_dims' was not declared in this scope. /home/abotev/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.6.0-64/tmpa8wrg7og/mod.cpp:626: error: 'prev_top_dims' was not declared in this scope. /home/abotev/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.6.0-64/tmpa8wrg7og/mod.cpp: In member function 'int<unnamed>::__struct_compiled_op_mc2bb2e24bb41d8af45c9d8be40d95ddd::init(PyObject*, PyObject*, PyObject*, PyObject*, PyObject*, PyObject*, PyObject*, PyObject*, PyObject*)':. /home/abotev/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.6.0-64/tmpa8wrg7og/mod.cpp:883: error: 'prev_kern_dims' was not declared in this scope. /home/abotev/.theano/compiledir_Linux-2.6-el6.x86_64-x86_64-with-centos-6.5-Final-x86_64-3.6.0-64/tmpa8wrg7og/mod.cpp:884: error: 'prev_top_dims' was not declared in this scope. ", "[GpuDnnConvGradI{algo='none', inplace=True}(<GpuArrayType<None>(float32, (True, False, False, False))>, <GpuArrayType<None>(float32, (False, True, False, False))>, <GpuArrayType<None>(float32, 4D)>, <CDataType{cudnnConvolutionDescriptor_t}>, Constant{1.0}, Constant{0.0})]")
`
I've also tried updating `libgpuarray` to the latest but that did not resolve it either. The code however runs fine on the CPU and worked fine before on the GPU. 

It seems that the error is coming from the C code of the kernel `prev_kern_dims` where there is a mistake of a brace initializer. However, I have no idea where exactly to look for that. 


Discussion:
Ok so it seems that this is stemming from my compiler since the default one is quite old, but I guess it would be good to notify users if before you could have got away without `-std=c++11` and now you don't. This quite relevant for people using clusters on older CentOS systems.

Resolving patch:
diff --git a/theano/gof/op.py b/theano/gof/op.py
--- a/theano/gof/op.py
+++ b/theano/gof/op.py
@@ -442,7 +442,7 @@ def c_init_code_struct(self, node, name, sub):
             The subclass does not override this method.
 
         """
-        raise utils.MethodNotDefined("c_init_code_apply", type(self),
+        raise utils.MethodNotDefined("c_init_code_struct", type(self),
                                      self.__class__.__name__)
 
     def c_support_code_struct(self, node, name):


Test patch: