Translate

2016年9月16日金曜日

Azure Machine Learning Studio 環境上でTensorFlowが動くか試してみた、が..だめだった..

#本記事には、一部翻訳がのっていますが
#つたない英語力で日本語化しているので
#参照される方は at your own risk でお願いします。

Azure Machine Learning Studioでは(Rや)Pythonが使えるとのこと。
実際にExecute Python Scriptというノードが有り、これを使うとAnaconda環境を使うことができるらしい。
ノードプロパティには、Anaconda2.7/Pythoin2.7.7Anaconda4.0/Python2.7.11Anaconda4.0/Python3.5のいずれかが動作するらしい。

プロパティ内には、以下のPythonスクリプトが編集可能な状態になっていた。


# The script MUST contain a function named azureml_main
# which is the entry point for this module.
# スクリプトには、このモジュールのエントリポイントになっている
# 関数うazureml_main()を必ず含めておかなくてはならない。

# imports up here can be used to
# インポートする場合はココに書けます

import pandas as pd

# The entry point function can contain up to two input arguments:
#   Param: a pandas.DataFrame
#   Param: a pandas.DataFrame
# エントリポイント関数は最大で2つの引数を指定できる:
#   Param: pandas.DataFrame値
#   Param: pandas.DataFrame値
def azureml_main(dataframe1 = None, dataframe2 = None):

    # Execution logic goes here
    # ココからロジックが実行される
    print('Input pandas.DataFrame #1:\r\n\r\n{0}'.format(dataframe1))

    # If a zip file is connected to the third input port is connected,
    # it is unzipped under ".\Script Bundle". This directory is added
    # to sys.path. Therefore, if your zip file contains a Python file
    # mymodule.py you can import it using:
    # import mymodule
    # もしZipファイルを3番めの入力ポートに接続した場合、
    # ".\Script Bundle"フォルダ下に解凍される。このフォルダは
    # sys.pathに追加される。このため、もしZipファイルにPython
    # ファイル mymodule.pyが含まれていたなら、それをimportに使用する
    # ことができます。


    # Return value must be of a sequence of pandas.DataFrame
    # pandafs.DataFrameシーケンスを必ず返却すること
    return dataframe1,

これつかえば、TensorFlowで書いたコードをかんたんにWebサービス化できるんちゃうの?

で、import tensorflow as tfazureml_main()の中に簡単なTensorFlowコードを入力してみた。


..が、動かなかった。

その時出たエラーは以下の通り。

Error 0085: The following error occurred during script evaluation, please view the output log for more information:
---------- Start of error message from Python interpreter ----------
Caught exception while executing function: Traceback (most recent call last):
  File "C:\server\invokepy.py", line 189, in batch
    mod = import_module(moduleName)
  File "C:\pyhome\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "C:\temp\2aaf8e0ab30244b2880f412042c39f62.py", line 20, in
    import tensorflow as tf
ImportError: No module named tensorflow
Process returned with non-zero exit code 1

---------- End of error message from Python  interpreter  ----------
Start time: UTC 09/16/2016 05:06:38
End time: UTC 09/16/2016 05:06:57

そもそもTensorFlowがAnaconda上にインストールされていない。

自由にpip/condaできればいいのだけど、Studioからはいまのところ操作できないようだ。
そうか、プロパティでPythonバージョン指定のところがcondaコマンド代替なんだ..
 condaする前にTensorFlowをpipしてほしいのだけど..

Azureのヘルプを調べると、フォーラムに以下の質問がのっていた。



Tensorflow in AzureML

Question

I've seen a  blog post that says tensorflow can be used using docker in Azure.

Is there any way to use tensorflow as a python package inside AzureML,so that finally I can use it to build model and call it using web service.

Tuesday, September 06, 2016 2:25 PM TanayC



質問

私は、Azure上のdockerを使ってTensorFlowがつかえるというブログ記事を読みました。
最終的に私はモデルをビルドしてWebサービスとして呼び出せるようにするために、AzureML内部でpythonパッケージとしてtensorflowを使う方法がありますか?
2016年9月6日(火) PM2:25 TanayC


良い質問だ..で答えは..


Answer

TensorFlow is not supported on Windows OS right now. Hence we can't run it in Azure ML yet.

Marked as answer by Hai NingMicrosoft employee, Moderator Wednesday, September 07, 2016 1:12 PM Hai Ning (MSFT,Partner)


回答

現時点では、TensorFlowはWindowsOS上ではサポートされていません。このため、Azure ML上ではTensorFlowは動作しません。
2016年9月7日(水) MS社員 Hai Ning(MSFT, パートナ)

スクリプトにZipファイルにのくだりのコメントがデフォルトのスクリプトにあるので、てっきりZipファイルをAzure Blob Storageとかに置いておけば使えるのかと思っていたのに..

ひょっとしたら質問のほうにかいてあったようなDockerコンテナを使った実装になっていないからじゃないからかな..

..がっかり..
 

0 件のコメント:

既存アプリケーションをK8s上でコンテナ化して動かす場合の設計注意事項メモ

既存アプリをK8sなどのコンテナにして動かすには、どこを注意すればいいか..ちょっと調べたときの注意事項をメモにした。   1. The Twelve Factors (日本語訳からの転記) コードベース   バージョン管理されている1つのコードベースと複数のデプロイ 依存関係 ...