LoginSignup
5
2

More than 3 years have passed since last update.

Google ColaboratoryによるDonkey Car 学習環境(3.1.0編)

Last updated at Posted at 2019-09-02

走行会などで円滑に学習が行えるように、Jupyter Notebookを作成しました。

Donkey Car(3.1.0)/TensorFlow 1.13.1環境(2019.09.01現在)
[Jupyter note]:(https://github.com/arigadget/donkeycar_colab )

以下にステップ毎の解説をしますので、カスタマイズの参考にどうぞ。

Install Tensorflow(1.13.1)

Colaboratoryでは現在Tensorflow 1.14.0がプレインストールされているため、GPU版の1.13.1をインストールします。

!pip uninstall -y tensorflow
!pip install tensorflow-gpu==1.13.1

Version check(Optional)

TensoFlow/cuda/cuDNNのバージョンを確認します。一度確認しておけばいいのでレース中は飛ばしても大丈夫です。

tensorflow-gpu : 1.13.1
cuda : 10.0.130
cuDNN : 7.6.2

!pip list | grep -i -e tensorflow
!nvcc --version
!ls -l /usr/lib/x86_64-linux-gnu/libcudnn.so*

Check GPU allocation(Optional)

GPUが割り当てられているかの確認です。これも飛ばしても大丈夫です。
If "Found GPU at: /device: GPU: 0" is displayed, the GPU is ready to use.

import tensorflow as tf
device_name = tf.test.gpu_device_name()
if device_name != '/device:GPU:0':
  raise SystemError('GPU device not found')
print('Found GPU at: {}'.format(device_name))

Install Donkeycar & Create Project

本来ならばセルを分けて記述すればいいのですが、手間を省くため一気にDonkey car(3.1.0 master)のインストールと環境設定をします。

!git clone https://github.com/autorope/donkeycar.git 
%cd donkeycar
!git checkout master
!pip3 install -e .[pc]
!donkey createcar --path /content/mycar

Upload datas.zip & unzip

ファイルのアップロードへのやり方には、主にGoogle Driveに格納する方法と、アップロードフォームを使う方法がありますが、転送の進捗が分かりやすいのとgoogle認証が必要でないことから、後者の方法でtubデータをアップロードします。

例)datas.zip(application/x-zip-compressed) - 2623504 bytes, last modified: 2019/8/31 - 62% done

「ファイル選択」でPC上にあるdatas.zipを選択し、アップロードする。
datas.zipは、実際の学習用フォルダである/content/mycar/dataに格納され、解凍します。

import os
from google.colab import files

if(os.path.exists("/content/mycar/data/datas.zip")):
   os.remove("/content/mycar/data/datas.zip")

%cd /content/mycar/data/
uploaded = files.upload()

!unzip -o datas.zip

Train your data

モデルの格納先をdefalutフォルダ、typeをlinearにしています。

/content/mycar/dataのフォルダー全てを学習対象にします。

%cd /content/mycar
!python manage.py train --model=/content/mycar/models/mypilot.h5 --type=linear

Copy the trained model back to Donkey Car

学習結果は、/content/mycar/models/mypilot.h5に保存される。
「ファイル」にあるmypilot.h5をダブルクリックしPCにダウンロードする。
WinSCP/SSHでRaspberryPiの~/mycar/models/mypilot.h5にコピーする。

以上

5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2