This adapts the 60 Minute Blitz PyTorch tutorial with deployment to Raspberry Pi.
From our Anaconda environment:
(torch) python nn_tutorial.py
This will save a nn_checkpoint.pt
file containing the example LeNet Neural Network.
You can view training progress via TensorBoard:
(torch) cd tutorials/nn_tutorial
(torch) tensorboard --logdir=logs --host=0.0.0.0
For more detailed timings (CPU and GPU profiling), this example also demonstrates how to save a nn.trace
Chrome trace file that can be viewed from the Google Chrome Browser using the URI: chrome://tracing
.
More details on Chrome Tracing: https://aras-p.info/blog/2017/01/23/Chrome-Tracing-as-Profiler-Frontend/
- [Optional] Copy the
nn_checkpoint.pt
file to the tutorials/train folder on the Raspberry Pi if you have re-trained it. - Launch the Raspberry Pi PyTorch docker image.
cd ~/stackup-workshops/pi-pytorch/docker
sh launch_docker.sh
- From the docker image, run the following test script to load and evalute a neural network. You should see output like below (actual values will differ because of random seed).
root@xxxxx:/code# cd /tutorials/train
root@xxxxx:/code/tutorials/train# python3 nn_eval.py
result tensor([[-1.3430, 0.3558, -1.3451, 0.6432, -0.6340, -0.1667, -0.5551,
0.3526, -0.1512, -0.1724]])