クラウドインフラ構築記

現在AWSの構築支援に携わっております。今注視しているのは、GKE、BigQuery、Google Dataflowなどサービスを展開しているGoolge Cloud Platformです。

ubuntuにjupyter notebookを導入 #jupyter


9/1に、OSSユーザの勉強会 TensorFlow編でGoogle 中井様(@enakai00)から、jupyterでTensorFlowの話がありましたので、jupyter notebookをUbuntu 14.04に、jupyter notebook & TensorFlowをインストールしてみました。

まずは、pythonのバージョン管理にpyenvをインストール

git clone https://github.com/yyuu/pyenv.git .pyenv
pyenv install 2.7.9
pyenv local 2.7.9

各種プラグインを取得

cd ~/.pyenv/plugins
git clone https://github.com/yyuu/pyenv-virtualenv.git
git clone https://github.com/yyuu/pyenv-virtualenvwrapper.git

TensorFlow用に2.7.11をインストール

pyenv install 2.7.11
pyenv virtualenv 2.7.11 TensorFlow
pyenv versions
 system
2.7.11
2.7.11/envs/TensorFlow
2.7.9
* TensorFlow (set by /home/hiruta/.python-version)

TensorFlowをインストール

mkdir -p tensorflow ; cd tensorflow
pip install -U https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0rc0-cp27-none-linux_x86_64.whl

jupyterのインストール

pip install -U matplotlib jupyter

それで、ipythonが使えるようになっています。

jupyterは下記モジュールがないと起動できないので、インストールしておきます。

sudo apt-get install libsqlite3-dev
pip install -U pysqlite

デフォルトでは、リモートからの接続できないようになっているので、設定変更が必要

jupyter notebook --generate-config
ipython

ハッシュしたパスワードを生成しておきます。

In [1]: from notebook.auth import passwd

In [2]: passwd()
 Enter password: <パスワードを入力>
 Verify password: <パスワードを再入力>
 Out[2]: 'sha1:<ハッシュ化されたパスワード>'
cd ~/.jupyter/
vi ~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip = '*'
c.NotebookApp.password = u'sha1:602f13266797:7ff1aed8351ad03b03e06facfd67bc2649717b7e'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888

c.NotebookApp.ipでクライアントIPで制限もできますが、今回は全て許可にしています。

jupyterからGoogle Cloud Visionを利用するのに、下記pythonモジュールを導入しておきます。

pip install httplib2
pip install Image
pip install --upgrade google-api-python-client

Cloud visionのnotebookをgit cloneしておきます。

git clone https://github.com/enakai00/jupyter_gcp.git
 cd jupyter_gcp
 jupyter notebook 

juoyter notebookは、Google Datalabでも使えます。(Google DatalabはLaunchできないなど不安定な場合があります)

 

 

 

コメントは受け付けていません。