Fix backward on cpu environment
@@ -351,6 +351,8 @@ Actual: {0}'''.format(type(data))
"""
if self.creator is None:
return
+ initial_device = None
+ if cuda.available:
initial_device = cuda.Device()
is_debug = chainer.is_debug()
@@ -442,6 +444,7 @@ Actual: {0}'''.format(type(data))
else: # 3rd or later visit
x._grad += gx
del gxs # to reduce memory usage
+ if initial_device is not None:
initial_device.use()
def unchain_backward(self):
