LoginSignup
6
6

More than 5 years have passed since last update.

TSUBAME2.0でtheanoをどうにか動かしたお話

Last updated at Posted at 2015-01-09

abstract

TSUBAME2.0上でtheanoを走らせるまでの記録です。

TSUBAME2.0ではpython関連は全て自分でビルドする必要があります。
こちらのサイトを参考にnumpy,scipy,theanoのインストールを行いましたが、scipy.test()が落ちており、theanoもうまく動きませんでした。

2016/7/25 追記 こちらのサイトが見えなくなっているようでしたので追記。
まずポータルに公開鍵の登録をしておきます。でsshを設定します

~/.ssh/config
Host login-t2.g.gsic.titech.ac.jp                                            
    HostName login-t2.g.gsic.titech.ac.jp                                      
    User USER_ID                                                              
    IdentityFile WHERE_OF_PUBLIC_KEY                                                 
    RemoteForward 3128 proxy.noc.titech.ac.jp:3128

TSUBAME側で、

~/.bashrc
export http_proxy="http://localhost:3128"                                      
export https_proxy="http://localhost:3128"                                     
export ftp_proxy="http://localhost:3128"

追記終わり

試行錯誤した結果、OpenBLASを使用してnumpyをインストールすることで無理やりtheanoがきちんと動くようになりました。

[おしながき]
* コンパイラ:gcc
* python-2.7.7
* openblas-0.2.13
* numpy-1.8.1
* scipy-0.14.0
* theano-0.7.0

[デメリット]
* openblasよりもmklを使った方がおそらく早いはずなので損をしている

まず、上記のサイトの3.4(matplotlibのインストール)まで行ってください。

OpenBLAS

cd OpenBLAS
make BINARY=64 USE_THREAD=1 FC=gfortran
make PREFIX=~/.local/OpenBLAS/ install 

PATHを通しておきます

export LIBRARY_PATH=~/.local/lib:~/.local/OpenBLAS/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=~/.local/lib:~/.local/OpenBLAS/lib:$LD_LIBRARY_PATH
export PATH=~/.local/bin:~/.local/OpenBLAS/bin:$PATH
export BLAS=/home/....../.local/OpenBLAS/lib/libopenblas.a
export LAPACK=/home/....../.local/OpenBLAS/lib/libopenblas.a

numpy

cd numpy
cp site.cfg.example site.cfg

こちら、およびこちらを参考に、以下のようにsite.cfgを書きます(以下、PATH類は適宜書き換えてください)

site.cfg
[default]
library_dirs = /home/....../.local/OpenBLAS/lib

[openblas]
libraries = openblas
library_dirs = /home/....../.local/OpenBLAS/lib
include_dirs = /home/....../.local/OpenBLAS/include

[atlas]
atlas_libs = openblas
library_dirs = /home/....../.local/OpenBLAS/lib

[lapack]
lapack_libs = openblas
library_dirs = /home/....../.local/OpenBLAS/lib

なんか、atlas,lapackを設定しないと、scipyでdot()関数をtestしているときにセグフォがおきます.

ちゃんと設定できたか確認します

python setup.py config

openblas,atlas,lapackがFOUNDと表示されていたら、インストールに移ります

python setup.py build
python setup.py install
cd ~
python -c "import numpy;numpy.test(verbose=10)"

scipy

scipyについては特に何かする必要はなさそうです

cd scipy
python setup.py build
python setup.py install
cd ~
python -c "import scipy;scipy.test(verbose=10)"

Theano

cd theano
python setup.py develop --prefix=~/.local
python setup.py install

~/.theanorcを以下のように作成します

.theanorc
[global]
floatX = float32
device = gpu
openmp = True


[nvcc]
fastmath = True

[blas]
ldflags =  -lopenblas

[cuda]
root = /usr/apps.sp3/cuda/6.0/
[gcc]
cxxflags = -I/usr/apps.sp3/mpi/openmpi/1.8.2/g4.3.4_cuda6.0/include -I/usr/apps.sp3/mpi/openmpi/1.8.2/g4.3.4_cuda6.0/include/openmpi -L/usr/apps.sp3/mpi/openmpi/1.8.2/g4.3.4_cuda6.0/lib -lmpi -lmpi_cxx

あとはお好きなプログラムを走らせてください。DeepLearningTutorialsのサンプルが動けばまああとはなんとかなるかと。.

6
6
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
6
6