0
1

More than 5 years have passed since last update.

chainerアップデートしたら、`Compilation failed`でエラーが出た

Posted at

Chainerの新しいバージョンが出たのは知っていたのでpip install -U chainerでアップデートして、テストとして昔書いたchainerのプログラムを動かしてみたら見たこともないエラーが。
どうも、c++で書かれていてコンパイルしなければならないファイルのコンパイル中にエラーで出ているようでコンパイルに失敗したC++ファイルの中身が出力されて、長いエラーメッセージの後にException: Compilation failed (return status=1)といわれる。

http://stackoverflow.com/questions/38589886/sorry-unimplemented-64-bit-mode-not-compiled-in
このページを見て解決法を探った。

環境

OS: Windows 10
Python: Python 3.5.1 :: Anaconda 2.4.0 (64-bit)
Chainer: 1.22.0

原因

どうも、C++をコンパイルしているMinGWというやつが原因らしい。
さらに具体的にはMinGWのモード(バージョン?)によって64bitのコンパイルができないとか。。。

そこで、g++ -vを確認

>> g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.5.2/lto-wrapper.exe
Target: mingw32
Configured with: ../../src/gcc-4.5.2/configure --build=mingw32 --enable-languages=c,c++,ada,fortran,objc,obj-c++ --enable-threads=win32 --enable-libgomp --enable-lto --enable-fully-dynamic-string --enable-libstdcxx-debug --enable-version-specific-runtime-libs --with-gnu-ld --disable-nls --disable-win32-registry --disable-symvers --disable-werror --prefix=/mingw32tdm --with-local-prefix=/mingw32tdm --enable-cxx-flags='-fno-function-sections -fno-data-sections' --with-pkgversion=tdm-1 --enable-sjlj-exceptions --with-bugurl=http://tdm-gcc.tdragon.net/bugs
Thread model: win32
gcc version 4.5.2 (tdm-1)

この、Target: mingw32Target: x86_64-w64-mingw32にならないといけないらしい。

解決策

MinGWの最新バージョンをインストールする。

まず、現在は入っているMinGWをアンインストールする。(このステップがないとうまくいきませんでした)
アンインストールは、単にC:\MinGWを消すだけ。

次に、
http://www.mingw.org/wiki/Getting_Started
から、mingw-get-setup.exeをダウンロードして実行。

全て終わってから、もう一度g++ -vをチェックすると

>> g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/TDM-GCC-64/bin/../libexec/gcc/x86_64-w64-mingw32/5.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-5.1.0/configure --build=x86_64-w64-mingw32 --enable-targets=all --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-libgomp --enable-lto --enable-graphite --enable-cxx-flags=-DWINPTHREAD_STATIC --disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-libstdcxx-debug --enable-threads=posix --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libstdcxx-threads --enable-libstdcxx-time --with-gnu-ld --disable-werror --disable-nls --disable-win32-registry --prefix=/mingw64tdm --with-local-prefix=/mingw64tdm --with-pkgversion=tdm64-1 --with-bugurl=http://tdm-gcc.tdragon.net/bugs
Thread model: posix
gcc version 5.1.0 (tdm64-1)

となっていた。Targetがきちんと設定されていて、chainerプログラムの実行できた。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1