LoginSignup
6

More than 5 years have passed since last update.

posted at

updated at

Chainer 4.0.0b1 on Windows10 with CUDA 9.0

TL;DR

  • install Chainer 4.0.0b1 with CUDA Toolkit 9.0 on Win10

PC構成

CPU: AMD A10-7700K
GPU: NVIDIA GTX 1080Ti
OS : Win 10 Home Edit. (64bit)

必要ソフト

  • Visual C++ Build Tools 2015 (Free)
  • Anaconda (64bit)
  • CUDA Toolkit 9.0
  • cuDNN 7

C++コンパイラ

  • Visual C++ 2015 Build Tools

インストール構成

  • ATL/MFC SDK
  • .NET Framework SDK

PATH

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin

Anaconda

今回はPython3.X系のWindows向け64bitのものを選んだ。(Python 3.6.1、Anaconda 4.4.0を利用)
インストール時にPathを通すか聞いてくれるので、通すにチェックを入れると楽。

CUDA Toolkit

9.0は普通にダウンロードできる
https://developer.nvidia.com/cuda-toolkit

今回はv9.0.176を利用した。

※8.0以前を使いたい場合は、公式アーカイブから取ってくる。
https://developer.nvidia.com/cuda-toolkit-archive

  • INCLUDE

環境変数にINCLUDEを作成する。

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt

cuDNN

cupyにはcuDNNが必要。今回はcuDNN v7.0.4 (Nov 13, 2017)を使った。

なお、NVIDIAのサイトへ開発者としての登録が必要。

解凍して
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0
に入れる。

cupy

pip install --no-cache-dir cupy==4.0.0b1

Test

gitクライアントが既に入ってる場合のやり方。

git clone https://github.com/cupy/cupy
cd cupy/examples

K-Means

cd kmeans
python ./kmeans.py
outpu
 CPU :  20.601157 sec
 GPU :  8.920502 sec

Chainer

pip install --no-cache-dir chainer==4.0.0b1

Test

gitクライアントが既に入ってる場合のやり方。

git clone https://github.com/chainer/chainer
cd chainer/examples

DC-GAN

cd dcgan
python ./train_dcgan.py -g 0

※-gで指定しているのはGPUのID。

output
C:\Programsi\Anaconda3\lib\site-packages\cupy\core\fusion.py:659: FutureWarning: cupy.core.fusion is experimental. The interface can change in the future.
  util.experimental('cupy.core.fusion')
GPU: 0
# Minibatch-size: 50
# n_hidden: 100
# epoch: 1000

epoch       iteration   gen/loss    dis/loss  ................]  0.01%
0           100         1.30576     1.80486
0           200         1.02042     1.48088
0           300         0.81469     1.40954
0           400         0.818605    1.38465
0           500         0.838211    1.38142
0           600         0.875678    1.34252
0           700         1.07016     1.24556
0           800         1.12548     1.31201
0           900         1.15804     1.21789
1           1000        1.26741     1.12504
1           1100        0.960491    1.33918
1           1200        0.95957     1.28511
1           1300        0.999848    1.30188
     total [..................................................]  0.13%
this epoch [#################.................................] 34.00%
      1340 iter, 1 epoch / 1000 epochs
    8.8668 iters/sec. Estimated time to finish: 1 day, 7:17:08.664292.

こんな感じで動いた。

Thanks for

windowsでcudaが動かないときの対処法 (Twitterモーメント)

Windows 10 + Visual Studio 2017 previewの環境でのpip経由のChainerインストール(with GPU)

tensorflowとcupyのwindows環境インストール(cuDNN、CUDA)(2017/10/27時点の情報)

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
What you can do with signing up
6