{
  "id": 4519,
  "title": "Bad kernel when building a pylearn2 DBM",
  "url": "/competitions/challenges-in-representation-learning-the-black-box-learning-challenge/discussion/4519",
  "author_name": "",
  "post_date": "2013-05-07T00:46:58.587Z",
  "votes": null,
  "comment_count": 2,
  "views": 1465,
  "content": "<p>I'm trying to get a basic DBM model working using Pylearn. &nbsp;I'm starting with the model in pylearn2/scripts/tutorials/dbm_demo/rbm.yaml. &nbsp;I've replaced the MNIST dataset with the&nbsp;BlackBoxDataset, and removed the&nbsp;bias_from_marginals line due to the out of\r\n range values. &nbsp;When I build the model, I get some pretty hairy error messages, but it seems to boil down to creating a bad kernel which is failing to compile. &nbsp;The error message is:</p>\r\n<pre>mod.cu(65): error: expected a &quot;)&quot;</pre>\r\n<p>The entire kernel code is printed out on error, and the section with the error looks like this:</p>\r\n<pre>58                 y1 = ((x21 &amp; MASK2) &lt;&lt; i15) &#43; (MULT2 * (x21 &gt;&gt; i16));<br>59                 y1 -= (y1 &lt; 0 || y1 &gt;= M2) ? M2 : 0;<br>60                 y2 = ((x23 &amp; MASK2) &lt;&lt; i15) &#43; (MULT2 * (x23 &gt;&gt; i16));<br>61                 y2 -= (y2 &lt; 0 || y2 &gt;= M2) ? M2 : 0;<br>62                 y2 &#43;= x23;<br>63                 y2 -= (y2 &lt; 0 || y2 &gt;= M2) ? M2 : 0;<br>64                 y2 &#43;= y1;<br>65                 y2 -= (y2 &lt; 0 or y2 &gt;= M2) ? M2 : 0;<br>66 <br>67                 x23 = x22;<br>68                 x22 = x21;<br>69                 x21 = y2;</pre>\r\n<p>So it appears that on line 65 it's placing an &quot;or&quot; instead of a &quot;||&quot;. &nbsp;Is this a problem anyone's seen before?</p>\r\n<p><span style=\"line-height:1.4em\"><br>\r\n</span></p>\r\n<p>The full stack trace is as follows:</p>\r\n<pre>['nvcc', '-shared', '-g', '-O3', '-arch=sm_20', '-Xlinker', '/DEBUG', '-m64', '-Xcompiler', '-DCUDA_NDARRAY_CUH=90c42b258281d604500ad1a5624b6654,-D NPY_ARRAY_ENSURECOPY=NPY_ENSURECOPY,-D NPY_ARRAY_ALIGNED=NPY_ALIGNED,-D NPY_ARRAY_WRITEABLE=NPY_WRITEABLE,-D NPY_ARRAY_UPDATE_ALL=NPY_UPDATE_ALL,-D NPY_ARRAY_C_CONTIGUOUS=NPY_C_CONTIGUOUS,-D NPY_ARRAY_F_CONTIGUOUS=NPY_F_CONTIGUOUS,/Zi', '-IC:\\\\Users\\\\dspineo\\\\AppData\\\\Local\\\\Theano\\\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.3\\\\cuda_ndarray', '-IAUTO\\\\include', '-IC:\\\\Python27\\\\lib\\\\site-packages\\\\numpy\\\\core\\\\include', '-IC:\\\\Python27\\\\include', '-IC:\\\\Python27\\\\lib\\\\site-packages\\\\theano\\\\sandbox\\\\cuda', '-o', 'C:\\\\Users\\\\dspineo\\\\AppData\\\\Local\\\\Theano\\\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.3\\\\tmphlgfm0\\\\465ad7f8e1d438d913f57bdca2bb9eb1.pyd', 'mod.cu', '-LC:\\\\Python27\\\\libs', '-LAUTO\\\\lib', '-LC:\\\\Users\\\\dspineo\\\\AppData\\\\Local\\\\Theano\\\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.3\\\\cuda_ndarray', '-LAUTO\\\\lib', '-LAUTO\\\\lib64', '-LC:\\\\Python27', '-lpython27', '-lcudart', '-lcublas', '-lcuda_ndarray']<br>Traceback (most recent call last):<br>  File &quot;D:\\Projects\\Pylearn\\main.py&quot;, line 8, in &lt;module&gt;<br>    train_obj.main_loop()<br>  File &quot;C:\\Python27\\lib\\site-packages\\pylearn2-0.1dev-py2.7.egg\\pylearn2\\train.py&quot;, line 109, in main_loop<br>    self.algorithm.setup(model=self.model, dataset=self.dataset)<br>  File &quot;C:\\Python27\\lib\\site-packages\\pylearn2-0.1dev-py2.7.egg\\pylearn2\\training_algorithms\\sgd.py&quot;, line 217, in setup<br>    grads, updates = self.cost.get_gradients(model, X, ** fixed_var_descr.fixed_vars)<br>  File &quot;C:\\Python27\\lib\\site-packages\\pylearn2-0.1dev-py2.7.egg\\pylearn2\\costs\\cost.py&quot;, line 207, in get_gradients<br>    result = cost.get_gradients(model, X, Y_to_pass, ** kwargs)<br>  File &quot;C:\\Python27\\lib\\site-packages\\pylearn2-0.1dev-py2.7.egg\\pylearn2\\costs\\dbm.py&quot;, line 328, in get_gradients<br>    layer_to_chains = model.make_layer_to_state(self.num_chains)<br>  File &quot;C:\\Python27\\lib\\site-packages\\pylearn2-0.1dev-py2.7.egg\\pylearn2\\models\\dbm\\__init__.py&quot;, line 343, in make_layer_to_state<br>    states = [ layer.make_state(num_examples, rng) for layer in layers ]<br>  File &quot;C:\\Python27\\lib\\site-packages\\pylearn2-0.1dev-py2.7.egg\\pylearn2\\models\\dbm\\__init__.py&quot;, line 1507, in make_state<br>    (h_state , h_sample)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\compile\\function.py&quot;, line 221, in function<br>    profile=profile)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\compile\\pfunc.py&quot;, line 506, in pfunc<br>    on_unused_input=on_unused_input)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\compile\\function_module.py&quot;, line 1339, in orig_function<br>    defaults)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\compile\\function_module.py&quot;, line 1167, in create<br>    _fn, _i, _o = self.linker.make_thunk(input_storage=input_storage_lists)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\gof\\link.py&quot;, line 383, in make_thunk<br>    output_storage = output_storage)[:3]<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\gof\\vm.py&quot;, line 800, in make_all<br>    for node in order]<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\sandbox\\cuda\\__init__.py&quot;, line 244, in make_thunk<br>    compute_map, no_recycling)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\gof\\op.py&quot;, line 580, in make_thunk<br>    output_storage=node_output_storage)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\gof\\cc.py&quot;, line 913, in make_thunk<br>    keep_lock=keep_lock)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\gof\\cc.py&quot;, line 856, in __compile__<br>    keep_lock=keep_lock)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\gof\\cc.py&quot;, line 1279, in cthunk_factory<br>    key=key, fn=self.compile_cmodule_by_step, keep_lock=keep_lock)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\gof\\cmodule.py&quot;, line 975, in module_from_key<br>    module = compile_steps.next()<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\gof\\cc.py&quot;, line 1201, in compile_cmodule_by_step<br>    preargs=preargs)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\sandbox\\cuda\\nvcc_compiler.py&quot;, line 391, in compile_str<br>    'for cmd', ' '.join(cmd))<br>Exception: ('nvcc return status', 2, 'for cmd', 'nvcc -shared -g -O3 -arch=sm_20 -Xlinker /DEBUG -m64 -Xcompiler -DCUDA_NDARRAY_CUH=90c42b258281d604500ad1a5624b6654,-D NPY_ARRAY_ENSURECOPY=NPY_ENSURECOPY,-D NPY_ARRAY_ALIGNED=NPY_ALIGNED,-D NPY_ARRAY_WRITEABLE=NPY_WRITEABLE,-D NPY_ARRAY_UPDATE_ALL=NPY_UPDATE_ALL,-D NPY_ARRAY_C_CONTIGUOUS=NPY_C_CONTIGUOUS,-D NPY_ARRAY_F_CONTIGUOUS=NPY_F_CONTIGUOUS,/Zi -IC:\\\\Users\\\\dspineo\\\\AppData\\\\Local\\\\Theano\\\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.3\\\\cuda_ndarray -IAUTO\\\\include -IC:\\\\Python27\\\\lib\\\\site-packages\\\\numpy\\\\core\\\\include -IC:\\\\Python27\\\\include -IC:\\\\Python27\\\\lib\\\\site-packages\\\\theano\\\\sandbox\\\\cuda -o C:\\\\Users\\\\dspineo\\\\AppData\\\\Local\\\\Theano\\\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.3\\\\tmphlgfm0\\\\465ad7f8e1d438d913f57bdca2bb9eb1.pyd mod.cu -LC:\\\\Python27\\\\libs -LAUTO\\\\lib -LC:\\\\Users\\\\dspineo\\\\AppData\\\\Local\\\\Theano\\\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.3\\\\cuda_ndarray -LAUTO\\\\lib -LAUTO\\\\lib64 -LC:\\\\Python27 -lpython27 -lcudart -lcublas -lcuda_ndarray', '[*1 -&gt; GPU_mrg_uniform{CudaNdarrayType(float32, matrix),no_inplace}(&lt;CudaNdarrayType(float32, vector)&gt;, &lt;TensorType(int32, vector)&gt;), *1::1]')</pre>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>",
  "messages": [
    {
      "id": "23967",
      "postDate": "05/07/2013 00:46:58",
      "content": "<p>I'm trying to get a basic DBM model working using Pylearn. &nbsp;I'm starting with the model in pylearn2/scripts/tutorials/dbm_demo/rbm.yaml. &nbsp;I've replaced the MNIST dataset with the&nbsp;BlackBoxDataset, and removed the&nbsp;bias_from_marginals line due to the out of\r\n range values. &nbsp;When I build the model, I get some pretty hairy error messages, but it seems to boil down to creating a bad kernel which is failing to compile. &nbsp;The error message is:</p>\r\n<pre>mod.cu(65): error: expected a &quot;)&quot;</pre>\r\n<p>The entire kernel code is printed out on error, and the section with the error looks like this:</p>\r\n<pre>58                 y1 = ((x21 &amp; MASK2) &lt;&lt; i15) &#43; (MULT2 * (x21 &gt;&gt; i16));<br>59                 y1 -= (y1 &lt; 0 || y1 &gt;= M2) ? M2 : 0;<br>60                 y2 = ((x23 &amp; MASK2) &lt;&lt; i15) &#43; (MULT2 * (x23 &gt;&gt; i16));<br>61                 y2 -= (y2 &lt; 0 || y2 &gt;= M2) ? M2 : 0;<br>62                 y2 &#43;= x23;<br>63                 y2 -= (y2 &lt; 0 || y2 &gt;= M2) ? M2 : 0;<br>64                 y2 &#43;= y1;<br>65                 y2 -= (y2 &lt; 0 or y2 &gt;= M2) ? M2 : 0;<br>66 <br>67                 x23 = x22;<br>68                 x22 = x21;<br>69                 x21 = y2;</pre>\r\n<p>So it appears that on line 65 it's placing an &quot;or&quot; instead of a &quot;||&quot;. &nbsp;Is this a problem anyone's seen before?</p>\r\n<p><span style=\"line-height:1.4em\"><br>\r\n</span></p>\r\n<p>The full stack trace is as follows:</p>\r\n<pre>['nvcc', '-shared', '-g', '-O3', '-arch=sm_20', '-Xlinker', '/DEBUG', '-m64', '-Xcompiler', '-DCUDA_NDARRAY_CUH=90c42b258281d604500ad1a5624b6654,-D NPY_ARRAY_ENSURECOPY=NPY_ENSURECOPY,-D NPY_ARRAY_ALIGNED=NPY_ALIGNED,-D NPY_ARRAY_WRITEABLE=NPY_WRITEABLE,-D NPY_ARRAY_UPDATE_ALL=NPY_UPDATE_ALL,-D NPY_ARRAY_C_CONTIGUOUS=NPY_C_CONTIGUOUS,-D NPY_ARRAY_F_CONTIGUOUS=NPY_F_CONTIGUOUS,/Zi', '-IC:\\\\Users\\\\dspineo\\\\AppData\\\\Local\\\\Theano\\\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.3\\\\cuda_ndarray', '-IAUTO\\\\include', '-IC:\\\\Python27\\\\lib\\\\site-packages\\\\numpy\\\\core\\\\include', '-IC:\\\\Python27\\\\include', '-IC:\\\\Python27\\\\lib\\\\site-packages\\\\theano\\\\sandbox\\\\cuda', '-o', 'C:\\\\Users\\\\dspineo\\\\AppData\\\\Local\\\\Theano\\\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.3\\\\tmphlgfm0\\\\465ad7f8e1d438d913f57bdca2bb9eb1.pyd', 'mod.cu', '-LC:\\\\Python27\\\\libs', '-LAUTO\\\\lib', '-LC:\\\\Users\\\\dspineo\\\\AppData\\\\Local\\\\Theano\\\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.3\\\\cuda_ndarray', '-LAUTO\\\\lib', '-LAUTO\\\\lib64', '-LC:\\\\Python27', '-lpython27', '-lcudart', '-lcublas', '-lcuda_ndarray']<br>Traceback (most recent call last):<br>  File &quot;D:\\Projects\\Pylearn\\main.py&quot;, line 8, in &lt;module&gt;<br>    train_obj.main_loop()<br>  File &quot;C:\\Python27\\lib\\site-packages\\pylearn2-0.1dev-py2.7.egg\\pylearn2\\train.py&quot;, line 109, in main_loop<br>    self.algorithm.setup(model=self.model, dataset=self.dataset)<br>  File &quot;C:\\Python27\\lib\\site-packages\\pylearn2-0.1dev-py2.7.egg\\pylearn2\\training_algorithms\\sgd.py&quot;, line 217, in setup<br>    grads, updates = self.cost.get_gradients(model, X, ** fixed_var_descr.fixed_vars)<br>  File &quot;C:\\Python27\\lib\\site-packages\\pylearn2-0.1dev-py2.7.egg\\pylearn2\\costs\\cost.py&quot;, line 207, in get_gradients<br>    result = cost.get_gradients(model, X, Y_to_pass, ** kwargs)<br>  File &quot;C:\\Python27\\lib\\site-packages\\pylearn2-0.1dev-py2.7.egg\\pylearn2\\costs\\dbm.py&quot;, line 328, in get_gradients<br>    layer_to_chains = model.make_layer_to_state(self.num_chains)<br>  File &quot;C:\\Python27\\lib\\site-packages\\pylearn2-0.1dev-py2.7.egg\\pylearn2\\models\\dbm\\__init__.py&quot;, line 343, in make_layer_to_state<br>    states = [ layer.make_state(num_examples, rng) for layer in layers ]<br>  File &quot;C:\\Python27\\lib\\site-packages\\pylearn2-0.1dev-py2.7.egg\\pylearn2\\models\\dbm\\__init__.py&quot;, line 1507, in make_state<br>    (h_state , h_sample)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\compile\\function.py&quot;, line 221, in function<br>    profile=profile)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\compile\\pfunc.py&quot;, line 506, in pfunc<br>    on_unused_input=on_unused_input)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\compile\\function_module.py&quot;, line 1339, in orig_function<br>    defaults)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\compile\\function_module.py&quot;, line 1167, in create<br>    _fn, _i, _o = self.linker.make_thunk(input_storage=input_storage_lists)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\gof\\link.py&quot;, line 383, in make_thunk<br>    output_storage = output_storage)[:3]<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\gof\\vm.py&quot;, line 800, in make_all<br>    for node in order]<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\sandbox\\cuda\\__init__.py&quot;, line 244, in make_thunk<br>    compute_map, no_recycling)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\gof\\op.py&quot;, line 580, in make_thunk<br>    output_storage=node_output_storage)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\gof\\cc.py&quot;, line 913, in make_thunk<br>    keep_lock=keep_lock)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\gof\\cc.py&quot;, line 856, in __compile__<br>    keep_lock=keep_lock)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\gof\\cc.py&quot;, line 1279, in cthunk_factory<br>    key=key, fn=self.compile_cmodule_by_step, keep_lock=keep_lock)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\gof\\cmodule.py&quot;, line 975, in module_from_key<br>    module = compile_steps.next()<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\gof\\cc.py&quot;, line 1201, in compile_cmodule_by_step<br>    preargs=preargs)<br>  File &quot;C:\\Python27\\lib\\site-packages\\theano\\sandbox\\cuda\\nvcc_compiler.py&quot;, line 391, in compile_str<br>    'for cmd', ' '.join(cmd))<br>Exception: ('nvcc return status', 2, 'for cmd', 'nvcc -shared -g -O3 -arch=sm_20 -Xlinker /DEBUG -m64 -Xcompiler -DCUDA_NDARRAY_CUH=90c42b258281d604500ad1a5624b6654,-D NPY_ARRAY_ENSURECOPY=NPY_ENSURECOPY,-D NPY_ARRAY_ALIGNED=NPY_ALIGNED,-D NPY_ARRAY_WRITEABLE=NPY_WRITEABLE,-D NPY_ARRAY_UPDATE_ALL=NPY_UPDATE_ALL,-D NPY_ARRAY_C_CONTIGUOUS=NPY_C_CONTIGUOUS,-D NPY_ARRAY_F_CONTIGUOUS=NPY_F_CONTIGUOUS,/Zi -IC:\\\\Users\\\\dspineo\\\\AppData\\\\Local\\\\Theano\\\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.3\\\\cuda_ndarray -IAUTO\\\\include -IC:\\\\Python27\\\\lib\\\\site-packages\\\\numpy\\\\core\\\\include -IC:\\\\Python27\\\\include -IC:\\\\Python27\\\\lib\\\\site-packages\\\\theano\\\\sandbox\\\\cuda -o C:\\\\Users\\\\dspineo\\\\AppData\\\\Local\\\\Theano\\\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.3\\\\tmphlgfm0\\\\465ad7f8e1d438d913f57bdca2bb9eb1.pyd mod.cu -LC:\\\\Python27\\\\libs -LAUTO\\\\lib -LC:\\\\Users\\\\dspineo\\\\AppData\\\\Local\\\\Theano\\\\compiledir_Windows-7-6.1.7601-SP1-Intel64_Family_6_Model_58_Stepping_9_GenuineIntel-2.7.3\\\\cuda_ndarray -LAUTO\\\\lib -LAUTO\\\\lib64 -LC:\\\\Python27 -lpython27 -lcudart -lcublas -lcuda_ndarray', '[*1 -&gt; GPU_mrg_uniform{CudaNdarrayType(float32, matrix),no_inplace}(&lt;CudaNdarrayType(float32, vector)&gt;, &lt;TensorType(int32, vector)&gt;), *1::1]')</pre>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "23968",
      "postDate": "05/07/2013 01:04:06",
      "content": "<p>Looks like a bug in theano. Can you e-mail me the full yaml file?</p>\r\n<p>Also, if you're not using the latest version of theano, try updating. It's possible this bug has already been fixed in the theano github repository.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "23972",
      "postDate": "05/07/2013 02:29:46",
      "content": "<p>Updating to the latest fixed it. &nbsp;I was using the Gohlke build of 0.6.0rc3 previously.</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 23968,
      "author_name": "iangoodfellow",
      "author_url": "",
      "post_date": "05/07/2013 01:04:06",
      "content": "<p>Looks like a bug in theano. Can you e-mail me the full yaml file?</p>\r\n<p>Also, if you're not using the latest version of theano, try updating. It's possible this bug has already been fixed in the theano github repository.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 23972,
      "author_name": "dpineo",
      "author_url": "",
      "post_date": "05/07/2013 02:29:46",
      "content": "<p>Updating to the latest fixed it. &nbsp;I was using the Gohlke build of 0.6.0rc3 previously.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "23967": "",
    "23968": "",
    "23972": ""
  },
  "source": "meta"
}