読者です 読者をやめる 読者になる 読者になる

Windowsにchainer 1.5.1を入れる

Python Windows chainer

chainerを1.3.2から1.5.1にバージョンアップしようとしたら、エラーになった。

Install packages failed: Error occurred when installing package chainer. 

The following command was executed:

packaging_tool.py install --build-dir C:\Users\aaaaaa\AppData\Local\Temp\pycharm-packaging53071042397457997.tmp chainer==1.5.1

The error output of the command:

Command "C:\Python2710\python.exe -c "import setuptools, tokenize;__file__='C:\\Users\\aaaaaa\\AppData\\Local\\Temp\\pycharm-packaging53071042397457997.tmp\\h5py\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\aaaaaa\appdata\local\temp\pip-f1jf9i-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\aaaaaa\AppData\Local\Temp\pycharm-packaging53071042397457997.tmp\h5py

Collecting chainer==1.5.1
  Downloading chainer-1.5.1.tar.gz (864kB)
Requirement already satisfied (use --upgrade to upgrade): filelock in c:\python2710\lib\site-packages (from chainer==1.5.1)
Requirement already satisfied (use --upgrade to upgrade): nose in c:\python2710\lib\site-packages (from chainer==1.5.1)
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.9.0 in c:\python2710\lib\site-packages (from chainer==1.5.1)
Requirement already satisfied (use --upgrade to upgrade): protobuf in c:\python2710\lib\site-packages (from chainer==1.5.1)
Requirement already satisfied (use --upgrade to upgrade): six>=1.9.0 in c:\python2710\lib\site-packages (from chainer==1.5.1)
Collecting h5py>=2.5.0 (from chainer==1.5.1)
  Downloading h5py-2.5.0.tar.gz (684kB)
Requirement already satisfied (use --upgrade to upgrade): setuptools in c:\python2710\lib\site-packages (from protobuf->chainer==1.5.1)
Collecting Cython>=0.17 (from h5py>=2.5.0->chainer==1.5.1)
  Downloading Cython-0.23.4-cp27-none-win_amd64.whl (1.8MB)
Installing collected packages: Cython, h5py, chainer
  Running setup.py install for h5py

略

    C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -DH5_USE_16_API -D_HDF5USEDLL_ -IC:\Users\aaaaaa\AppData\Local\Temp\pycharm-packaging53071042397457997.tmp\h5py\lzf -IC:\Users\aaaaaa\AppData\Local\Temp\pycharm-packaging53071042397457997.tmp\h5py\windows -IC:\Python2710\lib\site-packages\numpy\core\include -IC:\Python2710\include -IC:\Python2710\PC /TcC:\Users\aaaaaa\AppData\Local\Temp\pycharm-packaging53071042397457997.tmp\h5py\h5py\defs.c /Fobuild\temp.win-amd64-2.7\Release\Users\aaaaaa\AppData\Local\Temp\pycharm-packaging53071042397457997.tmp\h5py\h5py\defs.obj
    defs.c
    c:\python2710\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
    c:\users\aaaaaa\appdata\local\temp\pycharm-packaging53071042397457997.tmp\h5py\h5py\api_compat.h(27) : fatal error C1083: Cannot open include file: 'hdf5.h': No such file or directory
    Autodetection skipped [[Error 126] 指定されたモジュールが見つかりません。]
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\BIN\\amd64\\cl.exe' failed with exit status 2

Cython

Cythonのインストールでエラーになっているかと思ったら違った。。
h5pyというもののインストールでエラーになっていた。

WindowsでもCythonを使えるようにする。 - Qiita
http://www.lfd.uci.edu/~gohlke/pythonlibs/#cython

pip install Cython-0.23.4-cp27-none-win_amd64.whl

h5py

http://www.lfd.uci.edu/~gohlke/pythonlibs/#h5py

pip install h5py-2.5.0-cp27-none-win_amd64.whl

numpyインストール(ダメな手順)

    _configtest.exe.manifest : general error c1010070: Failed to load and parse the manifest. ??????????????????
    failure.
    removing: _configtest.c _configtest.obj
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\aaaaaa\AppData\Local\Temp\pycharm-packaging6190809776945737532.tmp\numpy\setup.py", line 263, in <module>
        setup_package()

...

      File "numpy\core\setup.py", line 669, in get_mathlib_info
        raise RuntimeError("Broken toolchain: cannot link a simple C program")
    RuntimeError: Broken toolchain: cannot link a simple C program

※この方法はダメだった。
sourceforge.netにあるインストーラーは、32bit版numpyが入ってchainerを入れるときにエラーになる。
Numerical Python - Browse /NumPy/1.10.2 at SourceForge.net
numpy-1.10.2-win32-superpack-python2.7.exe
を入れようとしたら、インストール先フォルダが違う。選択できない。
registryの
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath
の値を
C:\Python27\
から

C:\Python2710\

に変えたら、インストールしたいフォルダに変わった。

I cannot install numpy because it can't find python 2.7, althought I have installed python - Stack Overflow

numpyインストール

http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy

コマンドラインで、ダウンロードしたフォルダに移動して以下を実行。

pip install "numpy-1.10.2+mkl-cp27-none-win_amd64.whl"  

エラー

Upgrade packages failed.


The following command was executed:

packaging_tool.py install --build-dir C:\Users\aaaaaa\AppData\Local\Temp\pycharm-packaging3546373645558497351.tmp -U chainer

The error output of the command:

Command "python setup.py egg_info" failed with error code 1 in C:\Users\aaaaaa\AppData\Local\Temp\pycharm-packaging3546373645558497351.tmp\chainer

Collecting chainer
  Using cached chainer-1.5.1.tar.gz
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info\chainer.egg-info
    writing requirements to pip-egg-info\chainer.egg-info\requires.txt
    writing pip-egg-info\chainer.egg-info\PKG-INFO
    writing top-level names to pip-egg-info\chainer.egg-info\top_level.txt
    writing dependency_links to pip-egg-info\chainer.egg-info\dependency_links.txt
    writing manifest file 'pip-egg-info\chainer.egg-info\SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found
    
    Executing cythonize
    Options: {'profile': False, 'annotate': False, 'linetrace': False, 'no_cuda': False}
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "C:\Users\aaaaaa\AppData\Local\Temp\pycharm-packaging3546373645558497351.tmp\chainer\setup.py", line 87, in <module>
        'build_ext': chainer_setup_build.chainer_build_ext,
      File "C:\Python2710\lib\distutils\core.py", line 151, in setup
        dist.run_commands()
      File "C:\Python2710\lib\distutils\dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "C:\Python2710\lib\distutils\dist.py", line 972, in run_command
        cmd_obj.run()
      File "<string>", line 15, in replacement_run
      File "C:\Python2710\lib\site-packages\setuptools\command\egg_info.py", line 207, in find_sources
        mm.run()
      File "C:\Python2710\lib\site-packages\setuptools\command\egg_info.py", line 291, in run
        self.add_defaults()
      File "C:\Python2710\lib\site-packages\setuptools\command\egg_info.py", line 320, in add_defaults
        sdist.add_defaults(self)
      File "C:\Python2710\lib\site-packages\setuptools\command\sdist.py", line 130, in add_defaults
        build_ext = self.get_finalized_command('build_ext')
      File "C:\Python2710\lib\distutils\cmd.py", line 312, in get_finalized_command
        cmd_obj.ensure_finalized()
      File "C:\Python2710\lib\distutils\cmd.py", line 109, in ensure_finalized
        self.finalize_options()
      File "chainer_setup_build.py", line 319, in finalize_options
        extensions = make_extensions(_arg_options, compiler)
      File "chainer_setup_build.py", line 180, in make_extensions
        import numpy
      File "C:\Python2710\lib\site-packages\numpy\__init__.py", line 180, in <module>
        from . import add_newdocs
      File "C:\Python2710\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
        from numpy.lib import add_newdoc
      File "C:\Python2710\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
        from .type_check import *
      File "C:\Python2710\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
        import numpy.core.numeric as _nx
      File "C:\Python2710\lib\site-packages\numpy\core\__init__.py", line 14, in <module>
        from . import multiarray
    ImportError: DLL load failed: %1 は有効な Win32 アプリケーションではありません。
    
    ----------------------------------------

原因は、32bitのnumpyをインストールしたことだった。

numpy-1.10.2+mkl-cp27-none-win_amd64.whl
でnumpyを入れて、pipでchainerを入れたら、
1.5.1になった。

エラーは出なかったけど、cuDNNというものを入れないと
chainerのコードが警告が出て正しく動かないのかもしれない。
cuDNNを入れた時のメモ。
http://kubotti.hatenablog.com/entry/2015/12/27/154500