LoginSignup
4
4

More than 5 years have passed since last update.

Theanoのインストールメモ

Posted at

やりたいこと

pyenvでtheano使える環境をつくりたい

OS: Ubuntu 16.04.1 LTS

つまったところ

pyenv 使って,普通に

pyenv install 2.7.6
pyenv shell 2.7.6
pip install Theano
python -c "import theano"

ってやったら

.pyenv/versions/2.7.10/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
.pyenv/versions/2.7.10/lib/libpython2.7.a: error adding symbols: Bad value

てエラー...

原因

stackoverflowで調べたら,

Error importing Theano - Stack Overflow
ここに,

You didn't build correctly python. It wasn't compiled with the -fPIC parameter. Look at how to compile python with a shared library.

よくわからなかったがshared libraryがないとか.

解決

pythonインストール時に--enable-sharedってオプションいれなきゃいけない.
pyenvでのインストール方法は,Home · yyuu/pyenv Wiki · GitHub の一番下に書いてあった.

env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.5.0

バージョンをインストールしたいのに変えればできる.
これでとりあえず,python -c "import theano"は通った.
次に,python -c "import theano; theano.test()"
したら,noseとnose_parameterizedっていうモジュールがないと,
公式Installing Theano - Theano 0.8.2 documentation にもテストするときはこの二つを入れてと書いてあった.
pip install nose nose-parameterized

とりあえずこれでtestも通った.(warningいろいろ出たけど.)

まとめ

pyenv使ってtheano入れるときは

env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install x.x.x
pyenv shell x.x.x
pip install nose nose_parameterized theano
python -c "import theano; theano.test()

でとりあえずは終わり.
GPU関連の確認をまだしてないので,問題が出たら追記します.

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