時代は人工知能。機械学習。深層学習。
TensorFlowに続き、ゼロから作るDeep LearningなどiPhone上で動作するPython環境であるPythonistaで機械学習の動作ができないものか検証してきました。
その失敗の連続の第3弾。
最近この記事にコメントをいただきました。ChainerはPythonistaで動くのか?というお話です。
Chainerとは?
実はあまり知らなかったので、調べてみました。
うむ。要はGoogleが開発したTensorFlowのような機械学習のためのライブラリですね。これも使えれば将来的に会社に行かなくてもお金が稼げるようになるかもしれません。
早速インストール
やってみました。ただ、以下の記事を参考にしたのですが、そもそもMacでも動かなかった様子。
そもそもGPUを使用するみたいで、やる前からなんとなく結果が見えてそうな気がしましたが、とりあえずやるだけやってみました。
StaSh v0.6.17 Tip: Send a running command to background by pressing the CZ button (Ctrl-Z on external keyboard) [~/Documents]$ pip install chainer Querying PyPI ... Downloading package ... Opening: https://pypi.python.org/packages/29/d2/97274ffb6903a27897762043914046009000c7c78c1fe8440872f5655ce8/chainer-1.20.0.1.tar.gz Save as: /private/var/mobile/Containers/Data/Application/B41BD429-F4FD-42FB-ADA2-28F769A4800D/tmp/chainer-1.20.0.1.tar.gz (1247648 bytes) 1247648 [100.00%] Extracting archive file ... Archive extracted. Running setup file ... Options: {'profile': False, 'annotate': False, 'linetrace': False, 'no_cuda': False} ************************************************** *** WARNING: nvcc not in path. *** WARNING: Please set path to nvcc. ************************************************** Include directories: [] Library directories: [] [Errno 1] Operation not permitted ************************************************** *** WARNING: Include files not found: ['cublas_v2.h', 'cuda.h', 'cuda_profiler_api.h', 'cuda_runtime.h', 'curand.h', 'nvToolsExt.h'] *** WARNING: Skip installing cuda support *** WARNING: Check your CFLAGS environment variable ************************************************** Include directories: [] Library directories: [] [Errno 1] Operation not permitted ************************************************** *** WARNING: Include files not found: ['cudnn.h'] *** WARNING: Skip installing cudnn support *** WARNING: Check your CFLAGS environment variable ************************************************** WARNING: Extension modules and skipped: [] Package installed: chainer Installing dependency: filelock Querying PyPI ... Downloading package ... Opening: https://pypi.python.org/packages/48/f0/77ece9df4df7924ad0d9ba678c8602dd1114348e1c714e4cd10d9fc35ff0/filelock-2.0.7.tar.gz Save as: /private/var/mobile/Containers/Data/Application/B41BD429-F4FD-42FB-ADA2-28F769A4800D/tmp/filelock-2.0.7.tar.gz (4981 bytes) 4981 [100.00%] Extracting archive file ... Archive extracted. Running setup file ... Package installed: filelock Installing dependency: nose Querying PyPI ... Downloading package ... Opening: https://pypi.python.org/packages/58/a5/0dc93c3ec33f4e281849523a5a913fa1eea9a3068acfa754d44d88107a44/nose-1.3.7.tar.gz Save as: /private/var/mobile/Containers/Data/Application/B41BD429-F4FD-42FB-ADA2-28F769A4800D/tmp/nose-1.3.7.tar.gz (280488 bytes) 280488 [100.00%] Extracting archive file ... Archive extracted. Running setup file ... Package installed: nose Dependency available in Pythonista bundle : numpy Installing dependency: protobuf Querying PyPI ... Downloading package ... Opening: https://pypi.python.org/packages/e0/2f/690a5f047e2cfef40c9c5eec0877b496dc1f5a0625ca6b0ac1cd11f12f6a/protobuf-3.2.0.tar.gz Save as: /private/var/mobile/Containers/Data/Application/B41BD429-F4FD-42FB-ADA2-28F769A4800D/tmp/protobuf-3.2.0.tar.gz (132939 bytes) 132939 [100.00%] Extracting archive file ... Archive extracted. Running setup file ... WARNING: Extension modules and skipped: [] Package installed: protobuf Dependency available in Pythonista bundle : six Dependency available in Pythonista bundle : six [~/Documents]$
んー。やはりエラーだのワーニングだの出てますね。単純にpipからのインストールは無理そうです。念のためコンソールから叩いてみましたが、
>>> import cupy Traceback (most recent call last): File "/private/var/mobile/Containers/Shared/AppGroup/722F33E9-7E9E-4D87-BC34-F33E0DEA46A1/Pythonista3/Documents/site-packages/cupy/__init__.py", line 7, in <module> from cupy import core # NOQA File "/private/var/mobile/Containers/Shared/AppGroup/722F33E9-7E9E-4D87-BC34-F33E0DEA46A1/Pythonista3/Documents/site-packages/cupy/core/__init__.py", line 1, in <module> from cupy.core import core # NOQA ImportError: cannot import name 'core' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<string>", line 1, in <module> File "/private/var/mobile/Containers/Shared/AppGroup/722F33E9-7E9E-4D87-BC34-F33E0DEA46A1/Pythonista3/Documents/site-packages/cupy/__init__.py", line 18, in <module> raise six.reraise(RuntimeError, RuntimeError(msg), exc_info[2]) File "/var/containers/Bundle/Application/AD249D5C-D4B8-420C-B9F6-28769AD7D77F/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/six.py", line 551, in reraise raise value.with_traceback(tb) File "/private/var/mobile/Containers/Shared/AppGroup/722F33E9-7E9E-4D87-BC34-F33E0DEA46A1/Pythonista3/Documents/site-packages/cupy/__init__.py", line 7, in <module> from cupy import core # NOQA File "/private/var/mobile/Containers/Shared/AppGroup/722F33E9-7E9E-4D87-BC34-F33E0DEA46A1/Pythonista3/Documents/site-packages/cupy/core/__init__.py", line 1, in <module> from cupy.core import core # NOQA RuntimeError: CuPy is not correctly installed. Please check your environment, uninstall Chainer and reinstall it with `pip install chainer --no-cache-dir -vvvv`. original error: cannot import name 'core'
importでエラーがでますね。正しくインストールはできていない模様。あまり時間もなかったので一旦ここまでにして、入れかけたChainerは削除しておきます。
[~/Documents]$ pip remove chainer Package removed. Removing dependency: filelock Package removed. Removing dependency: nose Package removed. Removing dependency: protobuf Package removed. [~/Documents]$
Pythonista3に新たにライブラリを入れるのがなかなかうまく行かないですね。もう少し研究が必要そうです。とりあえず今回はここまで。