We have a different approaches to installing the software depending on the version of Donkey Car. For Donkey Car <= 4.5.X we are using Jetpack 4.5.X which comes with Tensorflow 2.3.1. The python installation is using virtual env, i.e. it is based on the system python with version 3.6. This is the only version that is working on the old Jetson Nano.
For the main branch we have updated Tensorflow to 2.9 and python to 3.8 or
3.9. This is running on a newer version of Jetpack. You will need a Jetson
Xavier or any of the newer Jetsons like the Orin, to use Jetpack 5.0.2. To
decouple the python installation from the system python we are using Miniforge
which is a mamba based version of Miniconda that works on the aarm architecture.
For Donkey Car <= 4.5.X please go to the next section. For the latest
version on the main branch please jump
to this section.
We recommend to use 4GB version of the Jetson Nano or the Jetson Xavier to run the software without issues. It's also recommended using a 128GB microSD card with U3 speed, like for example this SanDisk SD Card.
These are the supported versions:
| Jetson | Jetpack | Python | Donkey | Tensorflow |
|---|---|---|---|---|
| Nano | 4.5.1 | 3.6 | <= 4.5.X | 2.3.1 |
| Xavier/Orin | 5.0.2 | 3.8 | >= 5.X | 2.9 |
Then Create your Donkeycar Application
Note: These instructions are working for DC 4.3.6 and DC 4.4.0 only at the moment. We are working on a patch to have support for 4.5.X too.
- Step 1a: Flash Operating System
- Step 2a: Free up the serial port
- Step 3a: Install Dependencies
- Step 4a: Setup Python Environment
- Step 5a: (Optional) Install PyGame for USB camera
These instructions work for Jetpack 4.5.1.
- If you have a 4gb Jetson Nano then download Jetpack 4.5.1 from Nvidia here; jetson-nano-jp451-sd-card-image.zip
- If you have a 2gb Jetson Nano the download Jetpack 4.5.1from Nvidia here; jetson-nano-2gb-jp451-sd-card-image.zip
This installs the official Nvidia build of Tensorflow 2.3.1; make sure you are using the same version of Tensorflow on your host PC if you are using one. Using a different version of Tensorflow to train your network may result in errors when you attempt to use it as an autopilot.
Visit the official Nvidia Jetson Nano Getting Started Guide or Nvidia Xavier NX Getting Started Guide. Work through the Prepare for Setup, Writing Image to the microSD Card, and Setup and First Boot instructions, then return here.
Once you're done with the setup, ssh into your vehicle. Use the terminal for Ubuntu or Mac. Putty for windows.
Remove Libre Office:
sudo apt-get remove --purge libreoffice*
sudo apt-get clean
sudo apt-get autoremoveAnd add a 8GB swap file:
git clone https://github.com/JetsonHacksNano/installSwapfile
cd installSwapfile
./installSwapfile.sh
sudo reboot now sudo usermod -aG dialout <your username>
sudo systemctl disable nvgettyFirst install some packages with apt-get.
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install -y libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran
sudo apt-get install -y python3-dev python3-pip
sudo apt-get install -y libxslt1-dev libxml2-dev libffi-dev libcurl4-openssl-dev libssl-dev libpng-dev libopenblas-dev
sudo apt-get install -y git nano
sudo apt-get install -y openmpi-doc openmpi-bin libopenmpi-dev libopenblas-devpip3 install virtualenv
python3 -m virtualenv -p python3 env --system-site-packages
echo "source ~/env/bin/activate" >> ~/.bashrc
source ~/.bashrcNext, you will need to install packages with pip:
pip3 install -U pip testresources setuptools
pip3 install -U futures==3.1.1 protobuf==3.12.2 pybind11==2.5.0
pip3 install -U cython==0.29.21 pyserial
pip3 install -U future==0.18.2 mock==4.0.2 h5py==2.10.0 keras_preprocessing==1.1.2 keras_applications==1.0.8 gast==0.3.3
pip3 install -U absl-py==0.9.0 py-cpuinfo==7.0.0 psutil==5.7.2 portpicker==1.3.1 six requests==2.24.0 astor==0.8.1 termcolor==1.1.0 wrapt==1.12.1 google-pasta==0.2.0
pip3 install -U gdown
# This will install tensorflow as a system package
pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v45 tensorflow==2.3.1Change to a dir you would like to use as the head of your projects. Assuming
you've already made the projects directory above, you can use that. Get
the latest 4.5.X release and install that into the venv.
mkdir projects
cd ~/projects
git clone https://github.com/autorope/donkeycar
cd donkeycar
git fetch --all --tags -f
git checkout 4.5.0
pip install -e .[nano]
If you plan to use a USB camera, you will also want to setup pygame:
sudo apt-get install python-dev libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion libportmidi-dev ffmpeg libswscale-dev libavformat-dev libavcodec-dev libfreetype6-dev
pip install pygameLater on you can add the CAMERA_TYPE="WEBCAM" in myconfig.py.
Instructions for the latest code from the main branch. Note the
installation differs between the two available OSs. On Jetson you need to
install Jetpack 5.1.2.
- Step 1c: Flash Operating System
- Step 2c: Free up the serial port
- Step 3c: Setup Python Environment
- Step 4c: (Optional) Install PyGame for USB camera
These instructions work for Jetpack 5.1.2.
Please install the Jetpack image from jetson-nx-developer-kit-sd-card-image.zip.
Visit the official Nvidia Xavier NX Getting Started Guide. Work through the Prepare for Setup, Writing Image to the microSD Card, and Setup and First Boot instructions, then return here.
Once you're done with the setup, ssh into your vehicle. Use the terminal for Ubuntu or Mac. Putty for windows.
Remove Libre Office:
sudo apt-get remove --purge libreoffice*
sudo apt-get clean
sudo apt-get autoremoveAnd add a 8GB swap file. Note, if you intend to run from an SSD, perform the swap file setup only after booting from the SSD:
git clone https://github.com/JetsonHacksNano/installSwapfile
cd installSwapfile
./installSwapfile.sh -s 8
reboot sudo usermod -aG dialout <your username>
sudo systemctl disable nvgetty- Step 1: Install virtualenv
Download and install virtualenv.
pip3 install virtualenv
python3 -m virtualenv -p python3 env --system-site-packages
echo "source env/bin/activate" >> ~/.bashrc
source ~/.bashrc- Step 2: Download and install Donkey Car
Downloading Donkey Car from GitHub
mkdir projects
cd projects
git clone https://github.com/autorope/donkeycar
cd donkeycar
git checkout main
pip3 install -e .[nano]
pip install -U albumentations --no-binary qudida,albumentations
sudo chmod 666 /dev/gpiochip*- Step 2a: Download and install tensorflow Follow the NVIDIA instructions to install tensorflow
pip3 install -U numpy grpcio absl-py py-cpuinfo psutil portpicker six mock requests gast h5py astor termcolor protobuf keras-applications keras-preprocessing wrapt google-pasta setuptools testresources
pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v512 tensorflow==2.12.0+nv23.06- Step 2b: additional installs
pip install kivy==2.1.0 pillow pylint pytest pytest-cov codecov moviepy PrettyTable mypy pyyaml fastai
pip uninstall opencv-python-headless- Step 3: Check the TF and OpenCV installation
Run python and verify that tensorflow is version 2.9 and trt is version 8.2.1.
To get the tensorrt shared libraries to load correctly we must set the
environment variable LD_PRELOAD as:
export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libnvinfer.so.8:/usr/lib/aarch64-linux-gnu/libgomp.so.1Note, this has to be done either every time you run donkeycar or tensorflow, or
you put the above line into your .bashrc.
python
>>> import tensorflow as tf
>>> tf.__version__
>>> from tensorflow.python.compiler.tensorrt import trt_convert as trt
>>> trt._check_trt_version_compatibility()
>>> import cv2
>>> print(cv2.getBuildInformation())If you plan to use a USB camera, you will also want to setup pygame:
pip install pygameLater on you can add the CAMERA_TYPE="WEBCAM" in myconfig.py.
This applies to any installation you did above, either JP 4.6.X or 5.0.X. If you're using a CSIC camera you may have a pink tint on the images. As described here, this fix will remove it.
wget https://www.dropbox.com/s/u80hr1o8n9hqeaj/camera_overrides.isp
sudo cp camera_overrides.isp /var/nvidia/nvcam/settings/
sudo chmod 664 /var/nvidia/nvcam/settings/camera_overrides.isp
sudo chown root:root /var/nvidia/nvcam/settings/camera_overrides.isp