A tutorial and sample code for running a pytorch nerual network using c++ on Nvidia jetson nano computer.
Dr. Longhao Qian
-
Read this tutorial about how to correctly install pytorch c++ lib on jetson nano.
-
Run the
python/verify_pytorch.py
to verify whether pytorch c++ lib function correctly. -
run to train a simple neural network and save the trained network to
.pt
weights file. -
run to compile the
src/pytorchTest/pytorch_load_test.cpp
andsrc/pytorchTest/pytorch_load_test_gpu.cpp
to get the execution files. -
run to
build_release/pytorchTest/pytorch_load_test_gpu
andbuild_release/pytorchTest/pytorch_load_test
and observe the results.
- read this tutorial about cmake commands to incooperate pytorch lib in compilation.
- read this tutorial about tensor definition in c++
- read this tutorial about CPU/GPU nerual network execution.
- using libtorch to load pytorch model is in this link.