Skip to content

Commit

Permalink
Merge pull request #176 from NVIDIA-AI-IOT/dev-sdcard
Browse files Browse the repository at this point in the history
update to JetPack 4.3 - sdcard v0.4.0
  • Loading branch information
jaybdub authored Jan 16, 2020
2 parents c18fd9b + cc1112a commit 65d9eec
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 15 deletions.
2 changes: 1 addition & 1 deletion jetbot/ssd_tensorrt/FlattenConcat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ using namespace nvinfer1;
namespace
{
const char* FLATTENCONCAT_PLUGIN_VERSION{"1"};
const char* FLATTENCONCAT_PLUGIN_NAME{"FlattenConcat_TRT"};
const char* FLATTENCONCAT_PLUGIN_NAME{"FlattenConcat_TRT_jetbot"};
}

// Flattens all input tensors and concats their flattened version together
Expand Down
10 changes: 5 additions & 5 deletions jetbot/ssd_tensorrt/ssd_tensorrt.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import ctypes
import graphsurgeon as gs
import numpy as np
import os
import subprocess
import tensorrt as trt
import uff

TRT_INPUT_NAME = 'input'
TRT_OUTPUT_NAME = 'nms'
Expand Down Expand Up @@ -86,9 +84,10 @@ def _load_config(config_path):

def ssd_pipeline_to_uff(checkpoint_path, config_path,
tmp_dir='exported_model'):

import graphsurgeon as gs
from object_detection import exporter
import tensorflow as tf
import uff

# TODO(@jwelsh): Implement by extending model builders with
# TensorRT plugin stubs. Currently, this method uses pattern
Expand Down Expand Up @@ -177,13 +176,13 @@ def ssd_pipeline_to_uff(checkpoint_path, config_path,

boxloc_concat_plugin = gs.create_plugin_node(
"boxloc_concat",
op="FlattenConcat_TRT",
op="FlattenConcat_TRT_jetbot",
dtype=tf.float32,
)

boxconf_concat_plugin = gs.create_plugin_node(
"boxconf_concat",
op="FlattenConcat_TRT",
op="FlattenConcat_TRT_jetbot",
dtype=tf.float32,
)

Expand Down Expand Up @@ -224,6 +223,7 @@ def ssd_uff_to_engine(uff_buffer,
strict_type_constraints=False,
log_level=trt.Logger.INFO):

import uff
# create the tensorrt engine
with trt.Logger(log_level) as logger, trt.Builder(logger) as builder, \
builder.create_network() as network, trt.UffParser() as parser:
Expand Down
9 changes: 7 additions & 2 deletions notebooks/collision_avoidance/live_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,12 @@
},
"outputs": [],
"source": [
"import time\n",
"\n",
"camera.unobserve(update, names='value')\n",
"\n",
"time.sleep(0.1) # add a small sleep to make sure frames have finished processing\n",
"\n",
"robot.stop()"
]
},
Expand Down Expand Up @@ -302,9 +307,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
"version": "3.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
9 changes: 7 additions & 2 deletions notebooks/road_following/live_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,12 @@
"metadata": {},
"outputs": [],
"source": [
"import time\n",
"\n",
"camera.unobserve(execute, names='value')\n",
"\n",
"time.sleep(0.1) # add a small sleep to make sure frames have finished processing\n",
"\n",
"robot.stop()"
]
},
Expand Down Expand Up @@ -348,9 +353,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
"version": "3.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
8 changes: 4 additions & 4 deletions notebooks/road_following/train_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
" optimizer.zero_grad()\n",
" outputs = model(images)\n",
" loss = F.mse_loss(outputs, labels)\n",
" train_loss += loss\n",
" train_loss += float(loss)\n",
" loss.backward()\n",
" optimizer.step()\n",
" train_loss /= len(train_loader)\n",
Expand All @@ -258,7 +258,7 @@
" labels = labels.to(device)\n",
" outputs = model(images)\n",
" loss = F.mse_loss(outputs, labels)\n",
" test_loss += loss\n",
" test_loss += float(loss)\n",
" test_loss /= len(test_loader)\n",
" \n",
" print('%f, %f' % (train_loss, test_loss))\n",
Expand Down Expand Up @@ -293,9 +293,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
"version": "3.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
75 changes: 75 additions & 0 deletions scripts/create-sdcard-image-from-scratch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash

password='jetbot'

# Keep updating the existing sudo time stamp
sudo -v
while true; do sudo -n true; sleep 120; kill -0 "$$" || exit; done 2>/dev/null &

# Enable i2c permissions
sudo usermod -aG i2c $USER

# Install pip and some python dependencies
sudo apt-get update
sudo apt install -y python3-pip python3-pil
sudo pip3 install --upgrade numpy

# Install the pre-built TensorFlow pip wheel
sudo apt-get update
sudo apt-get install -y libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev
sudo apt-get install -y python3-pip
sudo pip3 install -U pip
sudo pip3 install -U numpy==1.16.1 future==0.17.1 mock==3.0.5 h5py==2.9.0 keras_preprocessing==1.0.5 keras_applications==1.0.6 enum34 futures testresources setuptools protobuf
sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 tensorflow-gpu==1.14.0+nv19.10

# Install the pre-built PyTorch pip wheel
wget https://nvidia.box.com/shared/static/phqe92v26cbhqjohwtvxorrwnmrnfx1o.whl -O torch-1.3.0-cp36-cp36m-linux_aarch64.whl
sudo pip3 install numpy torch-1.3.0-cp36-cp36m-linux_aarch64.whl

# Install torchvision package
git clone https://github.com/pytorch/vision
cd vision
git checkout v0.4.0
sudo python3 setup.py install

# Install traitlets (master, to support the unlink() method)
sudo python3 -m pip install git+https://github.com/ipython/traitlets@master

# Install jupyter lab
sudo apt install -y nodejs npm
sudo pip3 install jupyter jupyterlab
sudo jupyter labextension install @jupyter-widgets/jupyterlab-manager

jupyter lab --generate-config
#jupyter notebook password
python3 -c "from notebook.auth.security import set_password; set_password('$password', '$HOME/.jupyter/jupyter_notebook_config.json')"

# install jetbot python module
cd
sudo apt install -y python3-smbus
cd ~/jetbot
sudo apt-get install -y cmake
sudo python3 setup.py install

# Install jetbot services
cd jetbot/utils
python3 create_stats_service.py
sudo mv jetbot_stats.service /etc/systemd/system/jetbot_stats.service
sudo systemctl enable jetbot_stats
sudo systemctl start jetbot_stats
python3 create_jupyter_service.py
sudo mv jetbot_jupyter.service /etc/systemd/system/jetbot_jupyter.service
sudo systemctl enable jetbot_jupyter
sudo systemctl start jetbot_jupyter

# Make swapfile
cd
sudo fallocate -l 4G /var/swapfile
sudo chmod 600 /var/swapfile
sudo mkswap /var/swapfile
sudo swapon /var/swapfile
sudo bash -c 'echo "/var/swapfile swap swap defaults 0 0" >> /etc/fstab'

# Copy JetBot notebooks to home directory
cp -r ~/jetbot/notebooks ~/Notebooks

3 changes: 3 additions & 0 deletions scripts/run-script-and-save-log.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

./create-sdcard-image-from-scratch.sh 2>&1 | tee ~/jetbot-create-sdcard-image.log
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def build_libs():

setup(
name='jetbot',
version='0.3.0',
version='0.4.0',
description='An open-source robot based on NVIDIA Jetson Nano',
packages=find_packages(),
install_requires=[
Expand Down

0 comments on commit 65d9eec

Please sign in to comment.