์•„๋ž˜ URL์— ๋‚˜์˜ค๋Š” ๊ฐ„๋‹จํ•œ LSTM ๊ด€๋ จ python code๋ฅผ ์ˆ˜ํ–‰ํ•˜๋ ค๊ณ  ํ•˜๋Š”๋ฐ, ์ด๋Ÿฐ error๊ฐ€ ๋‚˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

Time Series Prediction with LSTM Recurrent Neural Networks in Python with Keras

minsky@minsky:~/exam$ python lstm1.py

import scipy.special as spec
File “/home/minsky/anaconda3/lib/python3.6/site-packages/scipy/special/__init__.py”, line 6 40, in
from ._ufuncs import *
ImportError: /home/minsky/anaconda3/lib/python3.6/site-packages/scipy/special/_ufuncs.cpython -36m-powerpc64le-linux-gnu.so: undefined symbol: _gfortran_stop_numeric_f08

์ด๊ฑด ๊ผญ ppc64le ํ™˜๊ฒฝ์—์„œ๋งŒ ๋‚˜๋Š” error๋Š” ์•„๋‹™๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์ตœ๊ทผ์— ์ €๋„ caffe๋ฅผ buildํ•˜๋ฉด์„œ ์ด์™€ ์œ ์‚ฌํ•œ undefined symbol error๋กœ ์ธํ•ด ๊ณ ์ƒ์„ ํ•œ ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

์ด error๋Š” ํ•œ์ค„ ์š”์•ฝํ•˜๋ฉด ์˜ฌํ•ด ์ดˆ์— release๋œ Anaconda 5.1 ๋•Œ๋ฌธ์— ๋ฐœ์ƒํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๊ทธ๋ ‡๋‹ค๊ณ  Anaconda 5.1์— bug๊ฐ€ ์žˆ๋Š” ๊ฒƒ์€ ์•„๋‹ˆ๊ณ , Anaconda 5.1์„ buildํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋œ gcc ๋ฒ„์ „์ด 7.2.0์ด๋ผ๋Š” ๊ฒƒ์— ๋ฌธ์ œ๊ฐ€ ์žˆ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

minsky@minsky:~/exam$ python
Python 3.6.4 |Anaconda, Inc.| (default, Feb 11 2018, 08:19:13)
[GCC 7.2.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

์ € undefined symbol error๋Š” ์„œ๋กœ ๋‹ค๋ฅธ ๋ฒ„์ „์˜ gcc๋กœ compile๋œ object file๋“ค์„ ํ•˜๋‚˜๋กœ linkํ•  ๋•Œ ์ฃผ๋กœ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ Anaconda 5.1 ํ™˜๊ฒฝ์—์„œ gcc๋กœ ๋ญ”๊ฐ€ buildํ•  ๋•Œ๋Š” gcc ๋ฒ„์ „๋„ 7.2๋กœ ๋งž์ถ”๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ Redhat 7.4์˜ ๊ฒฝ์šฐ ํฌํ•จ๋œ gcc์˜ default ๋ฒ„์ „์€ 4.8์ด๊ณ , Ubuntu 16.04๋„ 5.4์— ๋ถˆ๊ณผํ•ฉ๋‹ˆ๋‹ค.

minsky@minsky:~/exam$ gcc –version
gcc (Ubuntu/IBM 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

๋‹ค์‹œ ๋งํ•ด, Anaconda 5.1์— ํฌํ•จ๋œ python library๋“ค์€ gcc 7.2๋กœ compile๋œ ๊ฒƒ์— ๋น„ํ•ด OS์— ํฌํ•จ๋œ gcc ๋ฒ„์ „์€ ํ›จ์”ฌ ๋‚ฎ๊ธฐ ๋•Œ๋ฌธ์— ์ด ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ• ๊นŒ์š” ? ๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ•์€ Anaconda 5.0์„ ์“ฐ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด ๋ฒ„์ „์€ gcc 4.8๋กœ compile๋˜์—ˆ๊ฑฐ๋“ ์š”.

https://repo.continuum.io/archive/

Filename Size Last Modified MD5
Anaconda2-5.1.0-Linux-ppc64le.sh 267.3M 2018-02-15 09:08:49 e894dcc547a1c7d67deb04f6bba7223a
Anaconda3-5.1.0-Linux-ppc64le.sh 285.7M 2018-02-15 09:08:56 47b5b2b17b7dbac0d4d0f0a4653f5b1c
Anaconda2-5.0.0-Linux-ppc64le.sh 282.3M 2017-09-26 16:25:07 157890d591c61a9b511f8452476d6d19
Anaconda3-5.0.0-Linux-ppc64le.sh 296.3M 2017-09-25 14:39:31 8fe5b29ca5be3ff11411621f79babfc2

์•„๋ž˜์™€ ๊ฐ™์ด Anaconda 5.0์„ download ๋ฐ›์•„ ์„ค์น˜ํ•˜๋ฉด ๊ทธ ์†์— ๋“  python์€ GCC 4.8.4๋กœ build๋œ ๊ฒƒ์„ ๋ณด์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

minsky@minsky:~/files$ wget https://repo.continuum.io/archive/Anaconda3-5.0.0-Linux-ppc64le.sh

minsky@minsky:~/exam$ which python
/home/minsky/anaconda3_50/bin/python

minsky@minsky:~/exam$ python
Python 3.6.2 |Anaconda, Inc.| (default, Sep 15 2017, 20:38:23)
[GCC 4.8.4] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

์ด์ œ ์ƒˆ๋กœ ์„ค์น˜๋œ Anaconda ํ™˜๊ฒฝ์— keras์™€ tensorflow๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

minsky@minsky:~/exam$ pip install keras

minsky@minsky:~/exam$ pip install ~/files/tensorflow_pkg/tensorflow-1.3.1-cp36-cp36m-linux_ppc64le.whl

์ด์ œ ์•„๊นŒ ๋Œ๋ฆฌ๋ ค ํ–ˆ๋˜ lstm1.py๋ฅผ ๋‹ค์‹œ ์ˆ˜ํ–‰ํ•ด๋ณด๋Š”๋ฐ, ์ด๋ฒˆ์—” ๋˜ ์ƒ‰๋‹ค๋ฅธ error๊ฐ€ ๋‚ฉ๋‹ˆ๋‹ค.

minsky@minsky:~/exam$ python lstm1.py
Using TensorFlow backend.
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
ImportError: numpy.core.multiarray failed to import

์ด๊ฑด numpy์˜ ๋ฒ„์ „์ด ๋‚ฎ์•„์„œ ์ƒ๊ธฐ๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. numpy๋ฅผ upgradeํ•˜๋ฉด ํ•ด๊ฒฐ๋ฉ๋‹ˆ๋‹ค.

minsky@minsky:~/exam$ pip install numpy –upgrade

minsky@minsky:~/exam$ python lstm1.py
/home/minsky/anaconda3_50/lib/python3.6/site-packages/h5py/__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
Using TensorFlow backend.

– 4s – loss: 0.0057
Epoch 1/1
– 1s – loss: 0.0141
Epoch 1/1
– 1s – loss: 0.0099
Epoch 1/1
– 1s – loss: 0.0072
Epoch 1/1

Epoch 1/1
– 1s – loss: 0.0039
Epoch 1/1
– 1s – loss: 0.0038
Epoch 1/1
– 1s – loss: 0.0038
Epoch 1/1
– 1s – loss: 0.0037
Epoch 1/1
– 1s – loss: 0.0036
Train Score: 29.74 RMSE
Test Score: 79.26 RMSE

๋‹ค๋งŒ ์ด sample code๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด CPU๋„ GPU๋„ ์‚ฌ์šฉ๋Ÿ‰์ด ๊ทธ๋‹ค์ง€ ๋งŽ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ POWER ์•„ํ‚คํ…์ฒ˜์˜ ์žฅ์ ์ธ intel x86 ๋Œ€๋น„ 2๋ฐฐ์— ๊ฐ€๊นŒ์šด memory bandwidth๋ฅผ ๋ณด์—ฌ์ฃผ๊ธฐ์—๋Š” ์ ์ ˆํ•œ ์˜ˆ๋Š” ์•„๋‹Œ ๊ฒƒ์œผ๋กœ ์ƒ๊ฐ๋ฉ๋‹ˆ๋‹ค.

ํ† ๋ก  ์ฐธ๊ฐ€

์ด๋ฉ”์ผ์€ ๊ณต๊ฐœ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ํ•„์ˆ˜ ์ž…๋ ฅ์ฐฝ์€ * ๋กœ ํ‘œ์‹œ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.