2016年12月1日木曜日

WindowsでDeepLearning・その2

さて,昨日の段階で,

    **************************************************
    *** WARNING: Include files not found: ['cudnn.h']
    *** WARNING: Skip installing cudnn support
    *** WARNING: Check your CFLAGS environment variable
    **************************************************
というエラーが出て終わっていたので,FIXを目指す. https://github.com/pfnet/chainer/issues/1699 を見てみたけど,どうも最後まで解決はしていないらしい.

とにかく問題はcuDNNがうまくインストールされていないことらしいということで, あたりがついてきたので,その辺を調べてみる.

どうやらcuDNNは中身を C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0 以下に上書きする必要があったようだ. http://qiita.com/okuta/items/f985b9da6de33a016a75

cuDNNを無事ダウンロードできた人は、展開したファイルをC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5に上書きしてください。
cuDNNv3の場合、cudnn64_70.dllがCUDA\v7.5\binフォルダに、cudnn.hがCUDA\v7.5\includeフォルダにcudnn.libがCUDA\v7.5\lib\x64に入っていれば大丈夫です。

これで再び

>pip install chainer --no-cache-dir -vvvv
でインストールすると,エラーは発生せずに無事インストールできた.

が,実行してみると

>python train_mnist.py --gpu 0

GPU: 0
# unit: 1000
# Minibatch-size: 100
# epoch: 20

Traceback (most recent call last):
  File "C:\usr\Python35\lib\site-packages\cupy\cuda\compiler.py", line 49, in _run_nvcc
    return subprocess.check_output(cmd, cwd=cwd, stderr=subprocess.STDOUT)
  File "C:\usr\Python35\lib\subprocess.py", line 626, in check_output
    **kwargs).stdout
  File "C:\usr\Python35\lib\subprocess.py", line 708, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['nvcc', '--preprocess', '-Xcompiler', '/wd 4819', '-m64', 'C:\\Users\\***\\AppData\\Local\\Temp\\tmp_ak8290o\\kern.cu']' returned non-zero exit status 2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "train_mnist.py", line 107, in 
    main()
  File "train_mnist.py", line 104, in main
    trainer.run()
  File "C:\usr\Python35\lib\site-packages\chainer\training\trainer.py", line 292, in run
    entry.extension(self)
  File "C:\usr\Python35\lib\contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\usr\Python35\lib\site-packages\chainer\reporter.py", line 90, in scope
    yield
  File "C:\usr\Python35\lib\site-packages\chainer\training\trainer.py", line 289, in run
    update()
  File "C:\usr\Python35\lib\site-packages\chainer\training\updater.py", line 170, in update
    self.update_core()
  File "C:\usr\Python35\lib\site-packages\chainer\training\updater.py", line 182, in update_core
    optimizer.update(loss_func, *in_vars)
  File "C:\usr\Python35\lib\site-packages\chainer\optimizer.py", line 392, in update
    loss = lossfun(*args, **kwds)
  File "C:\usr\Python35\lib\site-packages\chainer\links\model\classifier.py", line 67, in __call__
    self.y = self.predictor(*x)
  File "train_mnist.py", line 24, in __call__
    h1 = F.relu(self.l1(x))
  File "C:\usr\Python35\lib\site-packages\chainer\links\connection\linear.py", line 91, in __call__
    self._initialize_params(x.size // x.shape[0])
  File "C:\usr\Python35\lib\site-packages\chainer\links\connection\linear.py", line 77, in _initialize_params
    initializer=self._W_initializer)
  File "C:\usr\Python35\lib\site-packages\chainer\link.py", line 180, in add_param
    data = initializers.generate_array(initializer, shape, self.xp)
  File "C:\usr\Python35\lib\site-packages\chainer\initializers\__init__.py", line 45, in generate_array
    initializer(array)
  File "C:\usr\Python35\lib\site-packages\chainer\initializers\normal.py", line 94, in __call__
    Normal(s)(array)
  File "C:\usr\Python35\lib\site-packages\chainer\initializers\normal.py", line 31, in __call__
    loc=0.0, scale=self.scale, size=array.shape)
  File "cupy/core/core.pyx", line 1107, in cupy.core.core.ndarray.__setitem__ (cupy\core\core.cpp:22267)
  File "cupy/core/core.pyx", line 1336, in cupy.core.core.elementwise_copy (cupy\core\core.cpp:49642)
  File "cupy/core/elementwise.pxi", line 771, in cupy.core.core.ufunc.__call__ (cupy\core\core.cpp:40576)
  File "cupy/util.pyx", line 35, in cupy.util.memoize.decorator.ret (cupy\util.cpp:1261)
  File "cupy/core/elementwise.pxi", line 579, in cupy.core.core._get_ufunc_kernel (cupy\core\core.cpp:37190)
  File "cupy/core/elementwise.pxi", line 32, in cupy.core.core._get_simple_elementwise_kernel (cupy\core\core.cpp:27744)
  File "cupy/core/carray.pxi", line 87, in cupy.core.core.compile_with_cache (cupy\core\core.cpp:27431)
  File "C:\usr\Python35\lib\site-packages\cupy\cuda\compiler.py", line 131, in compile_with_cache
    base = _empty_file_preprocess_cache[env] = preprocess('', options)
  File "C:\usr\Python35\lib\site-packages\cupy\cuda\compiler.py", line 94, in preprocess
    pp_src = _run_nvcc(cmd, root_dir)
  File "C:\usr\Python35\lib\site-packages\cupy\cuda\compiler.py", line 56, in _run_nvcc
    raise RuntimeError(msg)
RuntimeError: `nvcc` command returns non-zero exit status.
command: ['nvcc', '--preprocess', '-Xcompiler', '/wd 4819', '-m64', 'C:\\Users\\*****\\AppData\\Local\\Temp\\tmp_ak8290o\\kern.cu']
return-code: 2
というわけで,実行時エラー.
さて,ここからどうするか・・・