internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: chainer/chainer

Issue:
TestConvolution2D.test_(forward, backward)_gpu_im2col does not check use_cudnn=False case
`TestConvolution2D.test_forward_gpu_im2col` and `TestConvolution2D.test_backward_gpu_im2col` are expected to test `Convolution2DFunction.backward_gpu` works correctly when CuDNN is disabled.

To achieve this, these test fixtures set `self.use_cudnn` attribute of the instance of `Convolution2D` to `False` . But what is actually passed to `convoluton_2d` function as `use_cudnn` option is the `use_cudnn` argument of `__init__` , not the attribute `self.use_cudnn` (See [here](https://github.com/pfnet/chainer/blob/af1f11d4e50b322286a041c416eddd4e0ee63d30/chainer/links/connection/convolution_2d.py#L75)).



Discussion:

Resolving patch:
diff --git a/chainer/links/connection/convolution_2d.py b/chainer/links/connection/convolution_2d.py
--- a/chainer/links/connection/convolution_2d.py
+++ b/chainer/links/connection/convolution_2d.py
@@ -42,7 +42,9 @@ def __init__(self, in_channels, out_channels, ksize, stride=1, pad=0,
                  wscale=1, bias=0, nobias=False, use_cudnn=True,
                  initialW=None, initial_bias=None):
         kh, kw = _pair(ksize)
-        self._conv_arg = (stride, pad, use_cudnn)
+        self.stride = _pair(stride)
+        self.pad = _pair(pad)
+        self.use_cudnn = use_cudnn
 
         W_shape = (out_channels, in_channels, kh, kw)
         super(Convolution2D, self).__init__(W=W_shape)
@@ -72,7 +74,7 @@ def __call__(self, x):
 
         """
         return convolution_2d.convolution_2d(
-            x, self.W, self.b, *self._conv_arg)
+            x, self.W, self.b, self.stride, self.pad, self.use_cudnn)
 
 
 def _pair(x):


Test patch:
Repository: chainer/chainer

Issue:
Unreadable error message appears when `nvcc` command is not found
Only "No suche file or directory" is shown in such case.

related to #698



Discussion:

Resolving patch:
diff --git a/cupy/cuda/compiler.py b/cupy/cuda/compiler.py
--- a/cupy/cuda/compiler.py
+++ b/cupy/cuda/compiler.py
@@ -32,6 +32,15 @@ def __exit__(self, exc_type, exc_value, traceback):
         os.rmdir(self.path)
 
 
+def _run_nvcc(cmd, cwd):
+    try:
+        return subprocess.check_output(cmd, cwd=cwd)
+    except OSError as e:
+        trace = sys.exc_info()[2]
+        msg = 'Failed to run `nvcc` command: ' + str(e)
+        six.reraise(OSError, msg, trace)
+
+
 def nvcc(source, options=(), arch=None):
     if not arch:
         arch = _get_arch()
@@ -46,7 +55,7 @@ def nvcc(source, options=(), arch=None):
             cu_file.write(source)
 
         cmd.append(cu_path)
-        subprocess.check_output(cmd, cwd=root_dir)
+        _run_nvcc(cmd, root_dir)
 
         with open(cubin_path, 'rb') as bin_file:
             return bin_file.read()
@@ -62,7 +71,7 @@ def preprocess(source, options=()):
             cu_file.write(source)
 
         cmd.append(cu_path)
-        pp_src = subprocess.check_output(cmd, cwd=root_dir)
+        pp_src = _run_nvcc(cmd, root_dir)
 
         if isinstance(pp_src, six.binary_type):
             pp_src = pp_src.decode('utf-8')


Test patch:
diff --git a/tests/cupy_tests/cuda_tests/test_compiler.py b/tests/cupy_tests/cuda_tests/test_compiler.py
new file mode 100644
--- /dev/null
+++ b/tests/cupy_tests/cuda_tests/test_compiler.py
@@ -0,0 +1,23 @@
+import os
+import unittest
+
+from cupy.cuda import compiler
+
+
+class NvccNotFoundTest(unittest.TestCase):
+
+    def setUp(self):
+        self.path = os.environ.pop('PATH', '')
+
+    def tearDown(self):
+        os.environ['PATH'] = self.path
+
+    def test_nvcc_without_command(self):
+        # Check that error message includes command name `nvcc`
+        with self.assertRaisesRegexp(OSError, 'nvcc'):
+            compiler.nvcc('')
+
+    def test_preprocess_without_command(self):
+        # Check that error message includes command name `nvcc`
+        with self.assertRaisesRegexp(OSError, 'nvcc'):
+            compiler.preprocess('')
Repository: chainer/chainer

Issue:
`/usr/local/cuda/lib` in Linux for Tegra
In CUDA for L4T (Linux for Tegra), shared objects are located in `/usr/local/cuda/lib`, not in `lib64`. I failed to install Chainer.



Discussion:

Resolving patch:
diff --git a/chainer_setup_build.py b/chainer_setup_build.py
--- a/chainer_setup_build.py
+++ b/chainer_setup_build.py
@@ -93,10 +93,9 @@ def get_compiler_setting():
         if sys.platform == 'win32':
             library_dirs.append(path.join(cuda_path, 'bin'))
             library_dirs.append(path.join(cuda_path, 'lib', 'x64'))
-        elif sys.platform == 'darwin':
-            library_dirs.append(path.join(cuda_path, 'lib'))
         else:
             library_dirs.append(path.join(cuda_path, 'lib64'))
+            library_dirs.append(path.join(cuda_path, 'lib'))
     if sys.platform == 'darwin':
         library_dirs.append('/usr/local/cuda/lib')
 


Test patch:
Repository: chainer/chainer

Issue:
Use `SOFTMAX_LOG` API of cudnn v3 in `softmax_corss_entropy`
`SOFTMAX_LOG` is supported in cudnn v3. It helps `softmax_cross_entropy` in #712 
We need to check version of cudnn. CuPy doesn't support it now.



Discussion:

Resolving patch:
diff --git a/chainer/functions/loss/softmax_cross_entropy.py b/chainer/functions/loss/softmax_cross_entropy.py
--- a/chainer/functions/loss/softmax_cross_entropy.py
+++ b/chainer/functions/loss/softmax_cross_entropy.py
@@ -6,6 +6,14 @@
 from chainer.utils import type_check
 
 
+if cuda.cudnn_enabled:
+    cudnn = cuda.cudnn
+    libcudnn = cudnn.cudnn
+    _algorithm = libcudnn.CUDNN_SOFTMAX_LOG
+    _mode = libcudnn.CUDNN_SOFTMAX_MODE_CHANNEL
+    _cudnn_version = libcudnn.getVersion()
+
+
 def logsumexp(x):
     xp = cuda.get_array_module(x)
     m = x.max(axis=1, keepdims=True)
@@ -14,10 +22,26 @@ def logsumexp(x):
     return xp.log(y.sum(axis=1, keepdims=True)) + m
 
 
-def softmax_log(x):
-    # TODO(unno): Use cudnn (cudnn v2 doesn't support CUDNN_SOFTMAX_LOG)
-    log_z = logsumexp(x)
-    return x - log_z
+def softmax_log(x, use_cudnn):
+    xp = cuda.get_array_module(x)
+    if xp != numpy and cuda.cudnn_enabled and use_cudnn \
+       and _cudnn_version >= 3000:
+        dtype = x.dtype
+        one = numpy.array(1, dtype=dtype).ctypes
+        zero = numpy.array(0, dtype=dtype).ctypes
+        handle = cudnn.get_handle()
+        x_cube = x.reshape(x.shape[:2] + (-1, 1))
+        desc = cudnn.create_tensor_descriptor(x_cube)
+        y = xp.empty_like(x)
+        libcudnn.softmaxForward(
+            handle, _algorithm, _mode, one.data, desc.value,
+            x_cube.data.ptr, zero.data, desc.value,
+            y.data.ptr)
+        return y
+
+    else:
+        log_z = logsumexp(x)
+        return x - log_z
 
 
 class SoftmaxCrossEntropy(function.Function):
@@ -45,7 +69,7 @@ def check_type_forward(self, in_types):
 
     def forward_cpu(self, inputs):
         x, t = inputs
-        log_y = softmax_log(x)
+        log_y = softmax_log(x, False)
         self.y = numpy.exp(log_y)
         log_yd = numpy.rollaxis(log_y, 1)
         log_yd = log_yd.reshape(len(log_yd), -1)
@@ -69,7 +93,7 @@ def forward_cpu(self, inputs):
     def forward_gpu(self, inputs):
         cupy = cuda.cupy
         x, t = inputs
-        log_y = softmax_log(x)
+        log_y = softmax_log(x, self.use_cudnn)
         self.y = cupy.exp(log_y)
         if getattr(self, 'normalize', True):
             count = float((t != self.ignore_label).sum())


Test patch:
Repository: chainer/chainer

Issue:
BUG: Variable.to_gpu doesn't work to move the other GPU
I understand `Variable.to_gpu` moves current variable to specified GPU destructively. But it isn't the case when current / target devices are both GPU?

```
c1 = chainer.Variable(cp.asarray(np.array([1, 2, 3])))
cuda.get_device(c1.data)
# <CUDA Device 0>

# NG, must be Device 2?
c1.to_gpu(2)
cuda.get_device(c1.data)
# <CUDA Device 0>

# OK
c2 = F.copy(c1, 2)
cuda.get_device(c2.data)
# <CUDA Device 2>
```



Discussion:

Resolving patch:
diff --git a/chainer/cuda.py b/chainer/cuda.py
--- a/chainer/cuda.py
+++ b/chainer/cuda.py
@@ -190,7 +190,12 @@ def to_gpu(array, device=None, stream=None):
     check_cuda_available()
     assert stream is None  # TODO(beam2d): FIX IT
     with get_device(device):
-        return cupy.asarray(array)
+        dev_id = int(get_device(array))
+        if dev_id != -1 and dev_id != cupy.cuda.device.get_device_id():
+            # Need to make a copy when an array is copied to another device
+            return cupy.array(array, copy=True)
+        else:
+            return cupy.asarray(array)
 
 
 def to_cpu(array, stream=None):


Test patch:
diff --git a/tests/chainer_tests/test_variable.py b/tests/chainer_tests/test_variable.py
--- a/tests/chainer_tests/test_variable.py
+++ b/tests/chainer_tests/test_variable.py
@@ -215,6 +215,21 @@ def test_to_gpu(self):
         cp.testing.assert_array_equal(a.data, cp.zeros(3, dtype=np.float32))
         cp.testing.assert_array_equal(a.grad, cp.ones(3, dtype=np.float32))
 
+    @attr.gpu
+    @attr.multi_gpu(2)
+    def test_to_gpu_from_another_gpu(self):
+        cp = cuda.cupy
+        a = chainer.Variable(cp.zeros(3, dtype=np.float32))
+        a.grad = cuda.cupy.ones_like(a.data)
+        b = a.data.copy()
+        gb = a.grad.copy()
+        a.to_gpu(1)
+
+        self.assertEqual(int(cuda.get_device(a.data)), 1)
+        self.assertEqual(int(cuda.get_device(a.grad)), 1)
+        cp.testing.assert_array_equal(a.data, b)
+        cp.testing.assert_array_equal(a.grad, gb)
+
     def check_zerograd(self, a_data, fill=False):
         xp = cuda.get_array_module(a_data)
         a = chainer.Variable(a_data)
Repository: chainer/chainer

Issue:
Use `numpy.uintp` for `size_t`
`numpy.intp` is `ssize_t`, and is not `size_t`. When value of `ptr` allocated by `malloc` method is larger than the maximum value of `ssize_t`, `numpy.intp(ptr)` causes an error, because it checks actual value of `ptr`.
We need to use `numpy.uintp` in this case.

Note that `numpy.uintp` is not documented in the reference manual http://docs.scipy.org/doc/numpy-1.10.1/user/basics.types.html



Discussion:

Resolving patch:
diff --git a/chainer/functions/math/matmul.py b/chainer/functions/math/matmul.py
--- a/chainer/functions/math/matmul.py
+++ b/chainer/functions/math/matmul.py
@@ -15,14 +15,14 @@ def _mat_ptrs(a):
         GPU array of pointers to matrices
     """
     if a.shape[0] == 1:
-        return cuda.cupy.full((1,), a[0].data.ptr, dtype=numpy.intp)
+        return cuda.cupy.full((1,), a[0].data.ptr, dtype=numpy.uintp)
     else:
         stride = a[1].data.ptr - a[0].data.ptr
         return cuda.cupy.arange(
             a[0].data.ptr,
             a[0].data.ptr + stride * a.shape[0],
             stride,
-            dtype=numpy.intp)
+            dtype=numpy.uintp)
 
 
 def _as_mat(x):


Test patch:
Repository: chainer/chainer

Issue:
`cupy.array_split` doesn't accept empty indecies
```
>>> x=cupy.array([1])
>>> cupy.array_split(x, [])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/unno/git/chainer/cupy/manipulation/split.py", line 32, in array_split
    ret.append(ary[skip + (slice(index, size),)])
UnboundLocalError: local variable 'index' referenced before assignment
```



Discussion:

Resolving patch:
diff --git a/cupy/manipulation/split.py b/cupy/manipulation/split.py
--- a/cupy/manipulation/split.py
+++ b/cupy/manipulation/split.py
@@ -23,6 +23,9 @@ def array_split(ary, indices_or_sections, axis=0):
     else:
         indices = indices_or_sections
 
+    if len(indices) == 0:
+        return [ary]
+
     skip = (slice(None),) * axis
     ret = []
     i = 0


Test patch:
diff --git a/tests/cupy_tests/manipulation_tests/test_split.py b/tests/cupy_tests/manipulation_tests/test_split.py
--- a/tests/cupy_tests/manipulation_tests/test_split.py
+++ b/tests/cupy_tests/manipulation_tests/test_split.py
@@ -20,6 +20,12 @@ def test_array_spliti2(self, xp):
         split = xp.array_split(a, 4, 1)
         return xp.concatenate(split, -1)
 
+    @testing.numpy_cupy_array_equal()
+    def test_array_spliti_empty(self, xp):
+        a = testing.shaped_arange((3, 11), xp)
+        split = xp.array_split(a, [])
+        return xp.concatenate(split, -1)
+
     @testing.numpy_cupy_array_equal()
     def test_dsplit(self, xp):
         a = testing.shaped_arange((3, 3, 12), xp)
Repository: chainer/chainer

Issue:
cuda.cupy.clip errors 
If I runt he code 

`cuda.cupy.clip(cuda.cupy.arange(10), 2, 7)`

I get the following error

```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-e529e5fea46e> in <module>()
----> 1 cuda.cupy.clip(cuda.cupy.arange(10), 2, 7)

/usr/local/lib/python2.7/dist-packages/cupy/math/misc.pyc in clip(a, a_min, a_max, out)
     24     '''
     25     # TODO(okuta): check type
---> 26     return a(a_min, a_max, out=out)
     27 
     28 

TypeError: 'cupy.core.core.ndarray' object is not callable
```

Expected output via numpy code `np.clip(np.arange(10), 2, 7)` is `array([2, 2, 2, 3, 4, 5, 6, 7, 7, 7])`



Discussion:
Thank you for reporting a bug. I'll fix it.


Resolving patch:
diff --git a/cupy/math/misc.py b/cupy/math/misc.py
--- a/cupy/math/misc.py
+++ b/cupy/math/misc.py
@@ -23,7 +23,7 @@ def clip(a, a_min, a_max, out=None):
 
     '''
     # TODO(okuta): check type
-    return a(a_min, a_max, out=out)
+    return a.clip(a_min, a_max, out=out)
 
 
 sqrt = core.create_ufunc(


Test patch:
diff --git a/tests/cupy_tests/math_tests/test_misc.py b/tests/cupy_tests/math_tests/test_misc.py
--- a/tests/cupy_tests/math_tests/test_misc.py
+++ b/tests/cupy_tests/math_tests/test_misc.py
@@ -50,6 +50,12 @@ def test_clip1(self, xp, dtype):
         a = testing.shaped_arange((2, 3, 4), xp, dtype)
         return a.clip(3, 13)
 
+    @testing.for_all_dtypes()
+    @testing.numpy_cupy_array_equal()
+    def test_clip_func(self, xp, dtype):
+        a = testing.shaped_arange((2, 3, 4), xp, dtype)
+        return xp.clip(a, 3, 13)
+
     @testing.for_all_dtypes()
     @testing.numpy_cupy_array_equal()
     def test_clip2(self, xp, dtype):
Repository: chainer/chainer

Issue:
Show more error messages when cython fails
Some users failed to run `cython` and it shows no message (I don't know the reason). In this case, `subprocess.check_call` shows nothing. We need to show an error message in `chainer_setup_build.py`.



Discussion:

Resolving patch:
diff --git a/chainer_setup_build.py b/chainer_setup_build.py
--- a/chainer_setup_build.py
+++ b/chainer_setup_build.py
@@ -261,12 +261,26 @@ def get_cython_pkg():
     return pkg_resources.get_distribution('cython')
 
 
+def run_command(cmd):
+    try:
+        subprocess.check_output(cmd, stderr=subprocess.STDOUT)
+    except subprocess.CalledProcessError as e:
+        msg = '''Command %r failed:
+
+  command: %s
+  return code: %d
+  output:
+
+%s''' % (cmd[0], ' '.join(e.cmd), e.returncode, e.output)
+        raise distutils.errors.DistutilsExecError(msg)
+
+
 def cythonize(extensions, force=False, annotate=False, compiler_directives={}):
     cython_location = get_cython_pkg().location
     cython_path = path.join(cython_location, 'cython.py')
     print("cython path:%s" % cython_location)
     cython_cmdbase = [sys.executable, cython_path]
-    subprocess.check_call(cython_cmdbase + ['--version'])
+    run_command(cython_cmdbase + ['--version'])
 
     cython_cmdbase.extend(['--fast-fail', '--verbose', '--cplus'])
     for ext in extensions:
@@ -274,7 +288,7 @@ def cythonize(extensions, force=False, annotate=False, compiler_directives={}):
         for i in compiler_directives.items():
             cmd.append('--directive')
             cmd.append('%s=%s' % i)
-        subprocess.check_call(cmd + ext.sources)
+        run_command(cmd + ext.sources)
 
 
 def to_cpp_extensions(extensions):


Test patch:
Repository: chainer/chainer

Issue:
`select_item` doesn't work when an input array is large
`numpy.choose` doesn't work with a large array whose size is larger than 32.

```
>>> F.select_item(chainer.Variable(numpy.zeros((1,100), numpy.float32)), chainer.Variable(numpy.array([0], numpy.int32)))
...
ValueError: Need between 2 and (32) array objects (inclusive).
```



Discussion:

Resolving patch:
diff --git a/chainer/functions/array/select_item.py b/chainer/functions/array/select_item.py
--- a/chainer/functions/array/select_item.py
+++ b/chainer/functions/array/select_item.py
@@ -24,7 +24,9 @@ def check_type_forward(self, in_types):
 
     def forward_cpu(self, inputs):
         x, t = inputs
-        return t.choose(x.T),
+        # This code is equivalent to `t.choose(x.T)`, but `numpy.choose`
+        # does not work when `x.shape[1] > 32`.
+        return x[six.moves.range(t.size), t],
 
     def forward_gpu(self, inputs):
         x, t = inputs


Test patch:
diff --git a/tests/chainer_tests/functions_tests/array_tests/test_select_item.py b/tests/chainer_tests/functions_tests/array_tests/test_select_item.py
--- a/tests/chainer_tests/functions_tests/array_tests/test_select_item.py
+++ b/tests/chainer_tests/functions_tests/array_tests/test_select_item.py
@@ -10,9 +10,12 @@
 from chainer.testing import attr
 
 
+@testing.parameterize(
+    {'in_shape': (10, 5), 'out_shape': (10,)},
+    {'in_shape': (0, 5),  'out_shape': (0,)},
+    {'in_shape': (1, 33), 'out_shape': (1,)},
+)
 class TestSelectItem(unittest.TestCase):
-    in_shape = (10, 5)
-    out_shape = (10,)
 
     def setUp(self):
         self.x_data = numpy.random.uniform(
@@ -53,9 +56,4 @@ def test_backward_gpu(self):
                             cuda.to_gpu(self.gy_data))
 
 
-class TestSelectItemZeroSize(unittest.TestCase):
-    in_shape = (0, 5)
-    out_shape = (0,)
-
-
 testing.run_module(__name__, __file__)
Repository: chainer/chainer

Issue:
Stream object should have .ptr set to 0, not None.
The event object expects the stream.ptr to be an integer (size_t) here:
https://github.com/pfnet/chainer/blob/master/cupy/cuda/stream.py#L56
https://github.com/pfnet/chainer/blob/master/cupy/cuda/runtime.pyx#L309

In trunk at the moment, recording events with default stream fails via:
Traceback (most recent call last):
  File "train_imagenet.py", line 85, in <module>
    train_loop()
  File "train_imagenet.py", line 67, in train_loop
    start.record()
  File "/home/awesomebox/anaconda/lib/python2.7/site-packages/chainer-1.5.1-py2.7-linux-x86_64.egg/cupy/cuda/stream.py", line 56, in record
    runtime.eventRecord(self.ptr, stream.ptr)
  File "cupy/cuda/runtime.pyx", line 309, in cupy.cuda.runtime.eventRecord (cupy/cuda/runtime.cpp:6139)
TypeError: an integer is required

The fix seems simple:

https://github.com/pfnet/chainer/blob/master/cupy/cuda/stream.py#L103
self.ptr = 0



Discussion:

Resolving patch:
diff --git a/cupy/cuda/stream.py b/cupy/cuda/stream.py
--- a/cupy/cuda/stream.py
+++ b/cupy/cuda/stream.py
@@ -22,7 +22,7 @@ class Event(object):
 
     """
     def __init__(self, block=False, disable_timing=False, interprocess=False):
-        self.ptr = None
+        self.ptr = 0
 
         if interprocess and not disable_timing:
             raise ValueError('Timing must be disabled for interprocess events')
@@ -34,7 +34,6 @@ def __init__(self, block=False, disable_timing=False, interprocess=False):
     def __del__(self):
         if self.ptr:
             runtime.eventDestroy(self.ptr)
-            self.ptr = None
 
     @property
     def done(self):
@@ -100,7 +99,7 @@ class Stream(object):
     """
     def __init__(self, null=False, non_blocking=False):
         if null:
-            self.ptr = None
+            self.ptr = 0
         elif non_blocking:
             self.ptr = runtime.streamCreateWithFlags(runtime.streamNonBlocking)
         else:
@@ -109,7 +108,6 @@ def __init__(self, null=False, non_blocking=False):
     def __del__(self):
         if self.ptr:
             runtime.streamDestroy(self.ptr)
-            self.ptr = None
 
     @property
     def done(self):


Test patch:
Repository: chainer/chainer

Issue:
ctc loss compatibility
i think this error is a bug in ctc implementation:

```
  File "/usr/local/lib/python2.7/dist-packages/chainer/functions/loss/ctc.py", line 223, in connectionist_temporal_classification
    assert blank_symbol < x[0].data.shape[1]
TypeError: 'Variable' object does not support indexing
```

x is Variable from output of relu function.



Discussion:
Sorry, this is a bug. I'll fix it.

I found that `x` is a list of `Variable` and is not a `Variable`. The document is wrong.


Resolving patch:
diff --git a/chainer/functions/loss/ctc.py b/chainer/functions/loss/ctc.py
--- a/chainer/functions/loss/ctc.py
+++ b/chainer/functions/loss/ctc.py
@@ -1,3 +1,4 @@
+import collections
 import numpy
 import six
 
@@ -184,8 +185,10 @@ def connectionist_temporal_classification(x, t, blank_symbol):
     unknown. See also [Graves2012]_
 
     Args:
-        x (Variable): RNN output at each time.
-                      (ex. :math:`(y_1, y_2, ..., y_T)`)
+        x (sequence of Variable): RNN output at each time. ``x`` must be a list
+            of :class:`~chianer.Variable` s. Each element of ``x``, ``x[i]``
+            is a :class:`~chainer.Variable` representing output of RNN at time
+            ``i``.
         t (Variable): Expected label sequence.
         blank_symbol (int): Index of blank_symbol.
                             This value must be non-negative.
@@ -217,6 +220,8 @@ def connectionist_temporal_classification(x, t, blank_symbol):
     <http://www.cs.toronto.edu/~graves/preprint.pdf>`_
 
     """
+    if not isinstance(x, collections.Sequence):
+        raise TypeError('x must be a list of Variables')
     if not isinstance(blank_symbol, int):
         raise TypeError('blank_symbol must be non-negative integer.')
     assert blank_symbol >= 0


Test patch:
diff --git a/tests/chainer_tests/functions_tests/loss_tests/test_ctc.py b/tests/chainer_tests/functions_tests/loss_tests/test_ctc.py
--- a/tests/chainer_tests/functions_tests/loss_tests/test_ctc.py
+++ b/tests/chainer_tests/functions_tests/loss_tests/test_ctc.py
@@ -95,4 +95,14 @@ def test_backward_gpu(self):
         self.check_backward(cuda.to_gpu(self.t),
                             tuple(cuda.to_gpu(x_data) for x_data in self.x))
 
+
+class TestCTCError(unittest.TestCase):
+
+    def test_not_iterable(self):
+        x = chainer.Variable(numpy.zeros((4, 2, 3), numpy.float32))
+        t = chainer.Variable(numpy.zeros((2, 2), numpy.int32))
+        with self.assertRaises(TypeError):
+            functions.connectionist_temporal_classification(x, t, 0)
+
+
 testing.run_module(__name__, __file__)
Repository: chainer/chainer

Issue:
check_cuda_version and check_cudnn_version failed although compile and link are successful.
`check_cuda_version` and `check_cudnn_version` check the version of CUDA and cuDNN respectively by making a temporary cpp file, compiling and linking it.

In some environment, the compiler used is gcc although the extension is `.cpp`. As checking code does not  return exit code explicitly, the return code can be other than 0 although all procedures are successful. If g++ was used, this problem would not occur because the code return 0 by default.



Discussion:

Resolving patch:
diff --git a/chainer_setup_build.py b/chainer_setup_build.py
--- a/chainer_setup_build.py
+++ b/chainer_setup_build.py
@@ -33,6 +33,7 @@ def check_cuda_version(compiler, settings):
     #include <stdio.h>
     int main(int argc, char* argv[]) {
       printf("%d", CUDA_VERSION);
+      return 0;
     }
     ''', include_dirs=settings['include_dirs'])
 
@@ -57,6 +58,7 @@ def check_cudnn_version(compiler, settings):
     #include <stdio.h>
     int main(int argc, char* argv[]) {
       printf("%d", CUDNN_VERSION);
+      return 0;
     }
     ''', include_dirs=settings['include_dirs'])
 


Test patch: