Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Build TensorFlow on SynQuacer
Search
Toshifumi NISHINAGA
July 21, 2018
Programming
1
350
Build TensorFlow on SynQuacer
SynQuacer上でTensorFlowをビルドする話です。
Toshifumi NISHINAGA
July 21, 2018
Tweet
Share
More Decks by Toshifumi NISHINAGA
See All by Toshifumi NISHINAGA
SecurityCamp2023基板作るコース講義資料/Security Camp 2023 Lecture Materials
tnishinaga
6
1.5k
RP2040のPIOを使う話/KernelVM Hokuriku 6
tnishinaga
1
600
JTAGでArmプロセッサをデバッグする方法のつづき/KernelVM_Tokyo16
tnishinaga
0
230
CMSIS-DAPの概要と使い方/KernelVM Online5
tnishinaga
0
1.2k
JTAGでarmプロセッサをデバッグする話/KernelVM Online4
tnishinaga
4
2.4k
ARM入門/arm introduction
tnishinaga
15
11k
俺の仮想マシンルーターがこんなに遅いはずはない/ KernelVM online 1
tnishinaga
0
2.3k
BareMetalで遊ぶ Raspberry Pi 4 - GIC v2編-/BareMetal Raspberry Pi 4 - GICv2 -
tnishinaga
6
4.3k
ある日突然、 あなたにPowerPCマシンが届いたらどうしますか?/kernelvmtokyo15
tnishinaga
3
3k
Other Decks in Programming
See All in Programming
フロントエンドパフォーマンス 入門
shouta2
7
1.5k
Understanding Ast By Looking
inouehi
0
120
AppDeveloperCon 2024 EU: Building polyglot developer experiences in 2024
salaboy
0
380
今の SmartHR にエンジニアで入社するとどうなるの?
daisukeshinoku
1
360
PHPでOfficeファイルを取り扱う! PHP Officeライブラリを プロダクトに組み込んだ話
hirobe1999
0
840
RubyVM を PHP で実装する 〜Hello World を出力するまで〜
memory1994
PRO
1
490
Deep Dive 大規模システムアーキテクチャ/開発組織エンジニアリング / Deep Dive Large-Scale System Architecture, Development Organization Engineering
nrslib
15
2.9k
Open Source Swiftc Workshop
kitasuke
1
180
Dockerで始めるAWS Lambda開発
stutkhd0709
13
2.5k
Introduction for Open Source Swift Workshop
giginet
PRO
0
180
BuefyのMaintainerを引き継いだ件
kikuomax
0
520
incrementalモデルの理解を深める
ikkimiyazaki
2
640
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
455
32k
Optimizing for Happiness
mojombo
369
69k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
5
1.4k
The MySQL Ecosystem @ GitHub 2015
samlambert
242
12k
The Language of Interfaces
destraynor
150
23k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
319
20k
BBQ
matthewcrist
78
8.7k
Embracing the Ebb and Flow
colly
78
4.1k
Learning to Love Humans: Emotional Interface Design
aarron
266
39k
For a Future-Friendly Web
brad_frost
170
8.9k
Pencils Down: Stop Designing & Start Developing
hursman
115
11k
Large-scale JavaScript Application Architecture
addyosmani
501
110k
Transcript
SynQuacerでTensorflowを 動かす話 Toshifumi NISHINAGA @tnishinaga
$ who • Name: Toshifumi NISHINAGA • Attribute: Hobby embedded
programmer • Activities: ◦ Google Summer of Code 2016(Linux foundation) ▪ https://summerofcode.withgoogle.com/archive/2016/projects/6617849892175872/ ▪ Porting Linux to ARM Cotex-M7 microcontroller. ◦ U-Boot contributor(not active recently…) • link: ◦ https://github.com/tnishinaga ◦ https://speakerdeck.com/tnishinaga 2
あらすじ • じとめが好きそうな人にええマシンをよこせといわれた • オーダーは以下 ◦ Keras + Tensorflowが動くこと ◦
OpenCVがptyhon3から使えること ◦ jupyter notebookも
SynQuacerを使おう • What’s this: ◦ ARM64 desktop (server) machine •
Spec: ◦ Processor: ARM64 Cortex-A53 24 core ◦ Memory: 4GB(up to 16GB x 4 slot) ◦ HDD: 1TB ◦ LAN: 1x 1Gbps ◦ PCIe: x1 x 2, x16(actually x4) x 1 ◦ Graphic: GeForce GT710(PCIe x16) ◦ 2x USB3, 2x USB2, 2x SATA 1x 96board LS connector • Price: ◦ 130,000 yen(chip1stop) 4
まあほぼpipで入るから 簡単やろ
そんなことはなかった
どはまりポイント • pipでTensorFlowインストールできない問題 • pip installが遅い問題 • Tensorflowのビルドが失敗する ◦ ARM32用のコンパイルオプションが勝手につく問題
◦ bazelが搭載メモリを考慮してくれない問題
pipでTensorFlowインストールできない問題 • Could not find a version that requirement tensorflow
とか言われる • AArch64向けには用意されてないっぽい(?) • ソースからビルドが必要 • 簡単インストールの予定が崩れる
TensorFlowビルド手順 • pipから依存ライブラリを入れる • Bazel(Googleの作ったビルドシステム)を入れる • BazelでTensorFlowをビルドする
pip installが遅い問題 • TensorFlowを入れるためには以下のpythonパッケージが必要 ◦ six ◦ numpy ◦ wheel
◦ https://www.tensorflow.org/install/install_sources より • 加えて、jupyter notebookや機械学習のために色々必要 ◦ pip3 --no-cache-dir install Pillow ipykernel jupyter gast \ grpcio absl-py protobuf tensorboard scipy • 普通にpip installでインストールできる
3時間経ってもインストール終わらず
pip installが遅い原因(?) • .whlの無いやつはビルドが走る • 何故かaptで入れたnumpy等のビルドまで走る • pip installは並列ビルドしてくれないっぽい ◦
https://stackoverflow.com/questions/26228136/pip-build-option-to-use-mu lticore • distutils(setuptools)では並列ビルドできる。でもinstallでは動いてない ◦ https://bugs.python.org/issue5309 •
並列ビルドできないとなぜ困るか • 普通のx86_64マシンなら1コアでもそこそこ強いので問題ない • SynQuacerのように複数の弱いコアで計算能力を稼ぐマシンはとてもつらい • 解決手伝ってくれる人募集中
TensorFlowのビルドが失敗する • ARM32のオプションを勝手につける問題 • Bazelが搭載メモリを考慮してくれない問題
TensorFlow: ARM32のオプションが勝手につく問題 • ARM64では-mfpuオプションは使えない(-mcpuに+fpとかやる) ◦ https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html • TensorFlowはなぜかSynQuacerを一部ARM32としてビルドしてしまう • 詳細要調査。協力者募集中。
◦ https://github.com/tnishinaga/tensorflow/commit/8a11597ee0cc5823e3dc57aa7682970e56b51 517
TensorFlow: bazelが搭載メモリを考慮しない • Bazelはビルドオプションで搭載メモリを考慮してビルドできるっぽい(?) ◦ bazel build -c opt \
--copt="-mcpu=cortex-a53+fp" \ --verbose_failures tensorflow/tools/pip_package:build_pip_package \ --local_resources 3072,8.0,1.0
virtual memory exhausted: Cannot allocate memory Target //tensorflow/tools/pip_package:build_pip_package failed to
build INFO: Elapsed time: 24530.257s, Critical Path: 23750.57s INFO: 180 processes: 180 local. FAILED: Build did NOT complete successfully root@949cda07f529:~/tensorflow-1.9.0-rc2#
TensorFlow: bazelが搭載メモリを考慮しない • Bazelはビルドオプションで搭載メモリを考慮してビルドしてくれないっぽい • -j オプションで並列ビルド数を制限できる ◦ bazel build
-c opt \ --copt="-mcpu=cortex-a53+fp" \ --verbose_failures tensorflow/tools/pip_package:build_pip_package \ -j 4
おしまい • TensorFlowはビルドできた • 道のりは険しかった • Dockerコンテナ化してあるので希望があれば公開します • 様々なパッケージをARM64でもビルドできるようにしていく必要がある ◦
仲間募集中