機械学習周りのプログラミング中心。 イベント情報
ポケモンバトルAI本電子書籍通販中

Chainer v5, CuPy v5, Windows 10での環境構築

古いソフトを動作させるための環境構築。

  • Anacondaをインストール
  • CUDA 10.0をインストール(より新しいバージョンが共存してもOK)
  • Visual C++ Build Tools for Visual Studio 2015 with Update 3 をインストール
    • 環境変数 VS140COMNTOOLS がセットされる
    • これがないと、cupyインストール時に error: Unable to find vcvarsall.bat というエラーになる
conda create -n chainer5 python=3.7
conda activate chainer5
set CUDA_PATH=%CUDA_PATH_V10_0%
pip install "chainer>=5,<6"
pip install "cupy>=5,<6"

実際はchainer==5.4.0, cupy==5.4.0がインストールされる。

cupyインストールの最中、一度失敗したような表示が出るがそのままインストールが続行し、成功する。

      C:\Users\xxx\Anaconda3\envs\chainer5\lib\site-packages\wheel\bdist_wheel.py:82: RuntimeWarning: Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
        warn=(impl == 'cp')):
      C:\Users\xxx\Anaconda3\envs\chainer5\lib\site-packages\wheel\bdist_wheel.py:87: RuntimeWarning: Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect
        sys.version_info < (3, 8))) \
      error: [Errno 2] No such file or directory: 'docs/source/license.rst'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cupy
  Running setup.py clean for cupy
Failed to build cupy
Installing collected packages: cupy
  Running setup.py install for cupy ... done
  DEPRECATION: cupy was installed using the legacy 'setup.py install' method, because a wheel could not be built for it. pip 23.1 will enforce this behaviour change. A possible replacement is to fix the wheel build issue reported above. Discussion can be found at https://github.com/pypa/pip/issues/8368
Successfully installed cupy-5.4.0

以下のページのサンプルコードが実行できることを確認した。

MNIST using Trainer — Chainer 7.8.1 documentation

ただし、以下の行については機能が未実装でありコメントアウトが必要。

trainer.extend(extensions.DumpGraph('main/loss'))