Google ColaboratoryでいつでもFPGA開発
この記事はFPGA Advent Calender 2018の21日目の記事です。 すでに、25日なのは記事を書く時間が無かったためです。すみません。
さて、タイトルの通り、私は現在機械学習系の実験は、ほぼGoogle Colaboratoryを使用しています。 最近のバージョンですとChainerがすでにインストールされており(Chainerで開発することが多いので)、簡単にGPUを使った開発ができる環境が整っているのと、Jupyter Notebookベースのドキュメントが簡単に残せるから、なにより無料というのが一番の理由です。 ということで、Google Colaboratory でFPGA開発できたらおもしろくね?と思ってチャレンジしていました。
本日の時点でGoogle Colaboratoryで使用できるインスタンスのスペックは下記の通りです。
項目 | 内容 |
---|---|
OS | Ubuntu 18.04.1 LTS |
CPU | Xeon 2.3GHz x 2 |
Mem | 12GB |
Storage | |
基本的にSurface Pro4しか使ってない自分からしたら(ストレージ以外は GPUインスタンスだと360GBあったので余裕)FPGA用にはそれなりに使えそうなスペックです。また、インストーラ本体をGoogle Driveに予め展開しておき、デバイスを絞れば入るのでは?となんとなく感じたのでセットアップをトライしてみます。
予めGoogle Driveの tools/installer
以下にVivadoインストーラがあるものとします。
またバッチモードでインストールを行うのでinstall_config.txt
を作成しておきます。
今回は下記のような設定です。
#### Vivado HL WebPACK Install Configuration #### Edition=Vivado HL WebPACK # Path where Xilinx software will be installed. Destination=/opt/Xilinx # Choose the Products/Devices the you would like to install. Modules=DocNav:0,Kintex UltraScale:0,Virtex UltraScale+ HBM ES:0,Spartan-7:0,Artix-7:0,Model Composer:0,ARM Cortex-A53:0,Zynq UltraScale+ MPSoC:0,Zynq-7000:1,SDK Core Tools:1,ARM Cortex-A9:1,ARM Cortex R5:0,Virtex UltraScale+ 58G ES:0,Zynq UltraScale+ MPSoC ES:0,System Generator for DSP:0,Kintex-7:0,Kintex UltraScale+:0,MicroBlaze:1 # Choose the post install scripts you'd like to run as part of the finalization step. Please note that some of these scripts may require user interaction during runtime. InstallOptions=Enable WebTalk for SDK to send usage statistics to Xilinx:1 ## Shortcuts and File associations ## # Choose whether Start menu/Application menu shortcuts will be created or not. CreateProgramGroupShortcuts=0 # Choose the name of the Start menu/Application menu shortcut. This setting will be ignored if you choose NOT to create shortcuts. ProgramGroupFolder=Xilinx Design Tools # Choose whether shortcuts will be created for All users or just the Current user. Shortcuts can be created for all users only if you run the installer as administrator. CreateShortcutsForAllUsers=0 # Choose whether shortcuts will be created on the desktop or not. CreateDesktopShortcuts=0 # Choose whether file associations will be created or not. CreateFileAssociation=0
その後、Jupyter Notebook上でGoogle Driveをマウントします。インストーラはパスにスペースがあるとダメっぽいので、適当にシンボリックリンクをはります。
from google.colab import drive drive.mount('/content/drive') !ln -s "/content/drive/My Drive/tools/installer/Xilinx_Vivado_SDK_2018.2_0614_1954/" /tmp/installer
実行権限がないと言われたので、適当にchmod
を行います。その後、インストールを行います。10数分後、ストレージが少なくなってきたという警告がGoogle Colaboratoryから出ますが、無視して進めます。
!chmod a+x /tmp/installer/xsetup !chmod a+x /tmp/installer/bin/* !chmod a+x /tmp/installer/tps/lnx64/jre/bin/java !/tmp/installer/xsetup --agree XilinxEULA,3rdPartyEULA,WebTalkTerms --batch Install --config /tmp/installer/install_config.txt
Running in batch mode... Copyright (c) 1986-2018 Xilinx, Inc. All rights reserved. INFO : Log file location - /root/.Xilinx/xinstall/xinstall_1545698669953.log INFO : Edition Selected to be installed: Vivado HL WebPACK INFO : Installing Edition: Vivado HL WebPACK INFO : Installation directory is /opt/Xilinx . INFO : Installing................................................................................................................................................................................................................................................................................................................................................................ INFO : Running post-install tasks..................... INFO : Log file is copied to : /opt/Xilinx/.xinstall/Vivado_2018.2/xinstall.log INFO : Installation completed successfully.
成功した!
インストール完了後のdf
Filesystem 1K-blocks Used Available Use% Mounted on overlay 41022688 40212700 0 100% / tmpfs 6667604 0 6667604 0% /dev tmpfs 6667604 0 6667604 0% /sys/fs/cgroup tmpfs 6667604 4 6667600 1% /var/colab /dev/sda1 47259264 41276756 5966124 88% /etc/hosts shm 6291456 0 6291456 0% /dev/shm tmpfs 6667604 0 6667604 0% /sys/firmware drive 41022688 40253200 769488 99% /content/drive
ぎりぎり入ってる!
!source /opt/Xilinx/Vivado/2018.2/settings64.sh && vivado -mode tcl
起動した!しかも、Tclコマンドをインタラクティブに使える!
合成等はやってませんが、Vivadoの起動ができました。 これでiphoneからでもVivadoを実行することがデキるわけです!
残念なところはTclコマンドがパスワードと同じように入力文字が見えないことですかね。
なお、Vivadoインストールデータが大きいため昨日Google Driveに課金しました。