UnicodeDecodeError当我使用cuda训练数据集时

时间:2017-08-03 02:37:51

标签: python chainer cupy

我用chainer来训练一些图像,但是有一个错误。

我不知道它的UnicodeDecodeError还是安装错误。

P:\dcgans\chainer-DCGAN\chainer-DCGAN>python DCGAN.py

Traceback (most recent call last):
  File "DCGAN.py", line 279, in <module>
    train_dcgan_labeled(gen, dis)
  File "DCGAN.py", line 171, in train_dcgan_labeled
    zvis = (xp.random.uniform(-1, 1, (100, nz), dtype=np.float32))
  File "P:\Python35\lib\site-packages\cupy\random\distributions.py", line 132, in uniform
    return rs.uniform(low, high, size=size, dtype=dtype)
  File "P:\Python35\lib\site-packages\cupy\random\generator.py", line 235, in uniform
    rand = self.random_sample(size=size, dtype=dtype)
  File "P:\Python35\lib\site-packages\cupy\random\generator.py", line 153, in random_sample
    RandomState._1m_kernel(out)
  File "cupy/core/elementwise.pxi", line 552, in cupy.core.core.ElementwiseKernel.__call__ (cupy\core\core.cpp:43810)
  File "cupy/util.pyx", line 39, in cupy.util.memoize.decorator.ret (cupy\util.cpp:1480)
  File "cupy/core/elementwise.pxi", line 409, in cupy.core.core._get_elementwise_kernel (cupy\core\core.cpp:42156)
  File "cupy/core/elementwise.pxi", line 12, in cupy.core.core._get_simple_elementwise_kernel (cupy\core\core.cpp:34787)
  File "cupy/core/elementwise.pxi", line 32, in cupy.core.core._get_simple_elementwise_kernel (cupy\core\core.cpp:34609)
  File "cupy/core/carray.pxi", line 87, in cupy.core.core.compile_with_cache (cupy\core\core.cpp:34264)
  File "P:\Python35\lib\site-packages\cupy\cuda\compiler.py", line 133, in compile_with_cache
    base = _empty_file_preprocess_cache[env] = preprocess('', options)
  File "P:\Python35\lib\site-packages\cupy\cuda\compiler.py", line 99, in preprocess
    pp_src = pp_src.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 27-28: invalid continuation byte

1 个答案:

答案 0 :(得分:0)

似乎nvcc生成了非UTF8输出,而CuPy无法对其进行解码。 这是CuPy的错误(我发布了一个问题:#378)。

目前可能的解决方案是将第'utf-8'cupy/cuda/compiler.py中的pp_src = pp_src.decode('utf-8')替换为与您的环境匹配的内容。例如,在日语环境中,'cp932'应该有效,'cp936'也许适用于简体中文。

您也可以尝试locale.getdefaultlocale()[1]作为通用解决方案(务必import locale)。

更新:修复程序已合并。它应该在即将发布的CuPy v1.0.3中修复。