2017年7月21日金曜日

pyenv 下のPythonを使って PySpark

conf/spark-defaults.conf に、
spark.pyspark.python   /home/XXX/.pyenv/versions/anaconda2-4.4.0/bin/python
みたいに直接書くとうまくいく。

2017年7月19日水曜日

cargo

rust のツールチェーンにcargoなるものが含まれている。makeみたいなものか?もう少し高度なのか。sbtぐらい?
プロジェクトディレクトリを自動的につくって、ソースとビルドファイルのテンプレートまで作ってくれる。驚いたことに、勝手に.gitができていてgit管理下になっている。便利。

Hidemotos-MacBook:rust nakada$ cargo new myProj --bin
     Created binary (application) `myProj` project
ディレクトリができて、その中にビルドファイルCargo.toml とsrcディレクトリができる。
$ ls myProj
Cargo.toml    src
Cargo.toml はこんな感じ。toml はTom’s Obvious, Minimal Language だそうだ。INIファイルとかに似てる?
$ cat myProj/Cargo.toml
[package]
name = "myProj"
version = "0.1.0"
authors = ["nakada"]

[dependencies]
srcの中にはmain.rsができる。
$ cat myProj/src/main.rs 
fn main() {
    println!("Hello, world!");
}
プロジェクトディレクトで、cargo build とすると、targetというディレクトリが作られて、target/debug/プロジェクト名 でバイナリができる。
cargo run とやるとbuild したあとそのまま実行するようだ。

Rust install mac

https://www.rustup.rs/ にしたがって、
curl https://sh.rustup.rs -sSf | sh
とやる。なにか.bash_profile とか書き換えているようで、ちょっと嫌な感じ。cargoなど一切合切ツールチェーンもインストールされる。
$ rustc --version
rustc 1.18.0 (03fc9d622 2017-06-06)
無事インストールできたようだ。
fn main() {
    println!("Hello, world!");
}
をtest.rs としてセーブして、
$ rustc test.rs
とやると test というバイナリができる。
これを実行すると
$ ./test
Hello, world!
となる。a.out になったりしないあたりが偉い。
$ ls -al test
-rwxr-xr-x  1 XXXXXX  staff  400552 Jul 19 16:22 test
400Kbytesもある。いまどきこんなもんか。

tensorflow server

https://tensorflow.github.io/serving/serving_basic TensorFlowサーバなるものがあるらしい。 学習済みのモデルをエクスポートする。 これをサーババイナリ(C++で書かれている模様)に与えると、 grpcのサーバができるので、ネットワーク越しにgrpcで呼び出して 予測をさせる事ができる、ということらしい。