Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to py39 / tf 29 #48

Merged
merged 31 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f993636
Update RPi installation doc.
DocGarbanzo Feb 19, 2023
24de95f
Update Nano installation doc. Also add missing image for RPi Imager app
DocGarbanzo Feb 19, 2023
7bf5fc6
Fix formatting and section levels in RPi doc
DocGarbanzo Feb 19, 2023
accc1cb
Integrate feedback from Tom for RPI and jetson install.
DocGarbanzo Feb 20, 2023
2f2b391
Update jetson doc
DocGarbanzo Feb 24, 2023
749f09f
Update jetson doc
DocGarbanzo Mar 7, 2023
6a0474b
Fix jetson nano install using help from Tom.
DocGarbanzo Mar 8, 2023
546114c
Update jetson doc
DocGarbanzo Mar 23, 2023
d782a92
Fix some install commands
DocGarbanzo Apr 1, 2023
0571db6
Corred LDPRELOAD for jetson
DocGarbanzo Apr 1, 2023
c5ec8eb
SSD swapfile hint for Xavier
DocGarbanzo Apr 1, 2023
14233a3
Fix typo
DocGarbanzo Apr 1, 2023
8afe3ae
Update jetson doc
DocGarbanzo Apr 1, 2023
d25d1f7
Update jetson doc
DocGarbanzo Apr 2, 2023
8c54eb7
Merge branch 'master' into Update_to_tf_29
DocGarbanzo Apr 2, 2023
fbafdd0
Update jetson doc
DocGarbanzo Apr 2, 2023
b14ffb2
Update jetson doc
DocGarbanzo Apr 2, 2023
465bfbd
Separate nano / xavier in setup because the former needs kivy-jetson …
DocGarbanzo Apr 4, 2023
e0ebadd
Correct separation of nano 45, 46 and xavier 50 in setup because the …
DocGarbanzo Apr 5, 2023
7720178
Correct DC version in RPi setup.
DocGarbanzo Apr 5, 2023
ffae450
Updated jetson doc with the feedback from @BrianHenryIE on the PR #48.
DocGarbanzo Apr 10, 2023
c3ea517
Updated RPi doc with the feedback from @francisduvivier on the PR #48.
DocGarbanzo Apr 12, 2023
7295599
Fix latest DC version and add alternative Q-Engineering install of Op…
DocGarbanzo Apr 12, 2023
cc67724
Set access rights to GPIO pins
DocGarbanzo Apr 24, 2023
e52b382
Update install so albumentations
DocGarbanzo Apr 25, 2023
57218a1
Remove camera setup in bullseye, as it's not relevant any longer.
DocGarbanzo May 4, 2023
492bec7
Merge remote-tracking branch 'origin/Update_to_tf_29' into Update_to_…
DocGarbanzo May 4, 2023
a643b4e
Missing albumentations and gpiochip instructions in JP 5.0.X install.
DocGarbanzo May 8, 2023
16e7b25
Remove opencv-headless according to Tom's suggestion.
DocGarbanzo Jun 5, 2023
81f4fea
Remove the Jetson Nano install for donkey 5.X as it's not working.
DocGarbanzo Jun 20, 2023
b60b3a3
Merge remote-tracking branch 'donkeydocs/Update_to_tf_29' into Update…
DocGarbanzo Jun 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/push-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ jobs:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2.1.1
with:
python-version: 3.7
python-version: 3.x
auto-activate-base: true
channels: defaults, conda-forge
- run: |
conda info
conda list
conda install mkdocs
pip install mkdocs-redirects
pip install mkdocs-material
mkdocs gh-deploy --force -v
echo Docs were made and pushed to docs.donkeycar.com
Binary file added docs/assets/rpi_imager.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
268 changes: 216 additions & 52 deletions docs/guide/robot_sbc/setup_jetson_nano.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,102 @@

![donkey](/assets/logos/nvidia_logo.png)

* [Step 1: Flash Operating System](#step-1-flash-operating-system)
* [Step 2: Install Dependencies](#step-2-install-dependencies)
* [Step 3: Setup Virtual Env](#step-3-setup-virtual-env)
* [Step 4: Install Donkeycar Python Code](#step-4-install-donkeycar-python-code)
* Then [Create your Donkeycar Application](/guide/create_application/)
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.

## Step 1: Flash Operating System
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.

These instructions work for Jetpack 4.5.1. They are known to *NOT* work on Jetpack 4.6 or 4.6.1.
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](#installation-for-donkey-car-main).

* If you have a 4gb Jetson Nano then download Jetpack 4.5.1 from Nvidia here; [jetson-nano-jp451-sd-card-image.zip](https://developer.nvidia.com/embedded/l4t/r32_release_v5.1/r32_release_v5.1/jeston_nano/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](https://developer.nvidia.com/embedded/l4t/r32_release_v5.1/r32_release_v5.1/jeston_nano_2gb/jetson-nano-2gb-jp451-sd-card-image.zip)
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.](https://www.amazon.com/SanDisk-128GB-Extreme-microSD-Adapter/dp/B07FCMKK5X/ref=sr_1_4?crid=1J19V1ZZ4EVQ5&keywords=SanDisk+128GB+Extreme+microSDXC+UHS-I&qid=1676908353&sprefix=sandisk+128gb+extreme+microsdxc+uhs-i%2Caps%2C121&sr=8-4)

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](https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-devkit#prepare) or [Nvidia Xavier NX Getting Started Guide](https://developer.nvidia.com/embedded/learn/get-started-jetson-xavier-nx-devkit). Work through the __Prepare for Setup__, __Writing Image to the microSD Card__, and __Setup and First Boot__ instructions, then return here.
These are the supported versions:

Once you're done with the setup, ssh into your vehicle. Use the the terminal for Ubuntu or Mac. [Putty](https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html) for windows.
| Jetson | Jetpack | Python | Donkey | Tensorflow |
|-------------|---------|--------|----------|------------|
| Nano | 4.5.2 | 3.6 | <= 4.5.X | 2.3.1 |
| Xavier/Orin | 4.6.2 | 3.8 | >= 5.X | 2.9 |

## Step 2: Free up the serial port (optional. Only needed if you're using the Robohat MM1)

Then [Create your Donkeycar Application](/guide/create_application/)


## Installation for Donkey Car <= 4.5.X

Instructions for the latest stable release 4.5.X.

* [Step 1a: Flash Operating System](#step-1a-flash-operating-system)
* [Step 2a: Free up the serial port](#step-2a-free-up-the-serial-port-optional-only-needed-if-youre-using-the-robohat-mm1)
* [Step 3a: Install Dependencies](#step-3a-install-system-wide-dependencies)
* [Step 4a: Setup Python Environment](#step-4a-setup-python-environment)
* [Step 5a: (Optional) Install PyGame for USB camera](#step-5a-optional-install-pygame-for-usb-camera)


### Step 1a: Flash Operating System


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](https://developer.nvidia.com/embedded/l4t/r32_release_v5.1/r32_release_v5.1/jeston_nano/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](https://developer.nvidia.com/embedded/l4t/r32_release_v5.1/r32_release_v5.1/jeston_nano_2gb/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](https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-devkit#prepare)
or [Nvidia Xavier NX Getting Started Guide](https://developer.nvidia.com/embedded/learn/get-started-jetson-xavier-nx-devkit).
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](https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html)
for windows.

Remove Libre Office:

```bash
sudo apt-get remove --purge libreoffice*
sudo apt-get clean
sudo apt-get autoremove
```

And add a 8GB swap file:

```bash
git clone https://github.com/JetsonHacksNano/installSwapfile
cd installSwapfile
./installSwapfile.sh
sudo reboot now
```

### Step 2a: Free up the serial port (optional. Only needed if you're using the Robohat MM1)

```bash
sudo usermod -aG dialout <your username>
sudo systemctl disable nvgetty
```

## Step 3: Install System-Wide Dependencies

### Step 3a: Install System-Wide Dependencies

First install some packages with `apt-get`.

```bash
sudo apt-get update -y
sudo apt-get upgrade -y
Expand All @@ -42,7 +108,9 @@ sudo apt-get install -y git nano
sudo apt-get install -y openmpi-doc openmpi-bin libopenmpi-dev libopenblas-dev
```

## Step 4: Setup Virtual Environment
### Step 4a: Setup Python Environment.

#### Setup Virtual Environment

```bash
pip3 install virtualenv
Expand All @@ -51,9 +119,10 @@ echo "source ~/env/bin/activate" >> ~/.bashrc
source ~/.bashrc
```

## Step 5: Setup Python Dependencies
#### Setup Python Dependencies

Next, you will need to install packages with `pip`:

```bash
pip3 install -U pip testresources setuptools
pip3 install -U futures==3.1.1 protobuf==3.12.2 pybind11==2.5.0
Expand All @@ -66,76 +135,171 @@ pip3 install -U gdown
pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v45 tensorflow==2.3.1
```

Finally, you can install PyTorch:
#### Install Donkeycar Python Code

Change 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.

```bash
mkdir projects
cd ~/projects
git clone https://github.com/autorope/donkeycar
cd donkeycar
git fetch --all --tags -f
latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $latestTag
pip install -e .[nano45]

```

### Step 5a: (Optional) Install PyGame for USB camera

If you plan to use a USB camera, you will also want to setup pygame:

```bash
wget https://nvidia.box.com/shared/static/p57jwntv436lfrd78inwl7iml6p13fzh.whl
cp p57jwntv436lfrd78inwl7iml6p13fzh.whl torch-1.8.0-cp36-cp36m-linux_aarch64.whl
pip3 install torch-1.8.0-cp36-cp36m-linux_aarch64.whl
sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libavcodec-dev libavformat-dev libswscale-dev
mkdir -p ~/projects; cd ~/projects
git clone -b v0.9.0 https://github.com/pytorch/vision torchvision
cd torchvision
python setup.py install
cd ../
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 pygame
```

Optionally, you can install the RPi.GPIO clone for Jetson Nano from [here](https://github.com/NVIDIA/jetson-gpio). This is not required for default setup, but can be useful if using LED or other GPIO driven devices.
Later on you can add the `CAMERA_TYPE="WEBCAM"` in myconfig.py.



## Installation for Donkey Car main

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.0.2.


### Installation on Jetson Xavier (or newer Jetson boards)

* [Step 1c: Flash Operating System](#step-1c-flash-operating-system)
* [Step 2c: Free up the serial port](#step-2c-free-up-the-serial-port-optional-only-needed-if-youre-using-the-robohat-mm1)
* [Step 3c: Setup Python Environment](#step-3c-setup-python-environment)
* [Step 4c: (Optional) Install PyGame for USB camera](#step-4c-optional-install-pygame-for-usb-camera)


## Step 5: Install Donkeycar Python Code
#### Step 1c: Flash Operating System

* Change 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:
These instructions work for Jetpack 5.0.2.

Please install the Jetpack image from [jetson-nx-developer-kit-sd-card-image.zip](https://developer.nvidia.com/jetson-nx-developer-kit-sd-card-image).


Visit the official [Nvidia Xavier NX Getting Started Guide](https://developer.nvidia.com/embedded/learn/get-started-jetson-xavier-nx-devkit).
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](https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html)
for windows.

Remove Libre Office:

```bash
cd ~/projects
sudo apt-get remove --purge libreoffice*
sudo apt-get clean
sudo apt-get autoremove
```

* Get the latest donkeycar from Github.
> Note: There are currently version updates happening on the `main` branch so you might rather want to checkout the latest stable release as explained below.
And 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:

```bash
git clone https://github.com/autorope/donkeycar
cd donkeycar
git checkout main
pip3 install -e .[nano]
git clone https://github.com/JetsonHacksNano/installSwapfile
cd installSwapfile
./installSwapfile.sh -s 8
reboot
```

* Alternatively, to get the latest stable release
#### Step 2c: Free up the serial port (optional. Only needed if you're using the Robohat MM1)

```bash
sudo usermod -aG dialout <your username>
sudo systemctl disable nvgetty
```

#### Step 3c: Setup python environment

* Step 1: Install mamba-forge

Download and install Miniconda and install `mamba`.

```bash
wget https://repo.anaconda.com/miniconda/Miniconda3-py38_23.1.0-1-Linux-aarch64.sh
chmod u+x ./Miniconda3-py38_23.1.0-1-Linux-aarch64.sh
bash ./Miniconda3-py38_23.1.0-1-Linux-aarch64.sh
conda install mamba -n base -c conda-forge
```

* Step 2: Download and install Donkey Car

Downloading Donkey Car from GitHub

```bash
mkdir projects
cd projects
git clone https://github.com/autorope/donkeycar
cd donkeycar
git fetch --all --tags -f
latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $latestTag
git checkout main
mamba env create -f install/envs/jetson.yml
conda activate donkey
pip install -e .[nano]
pip install -U albumentations --no-binary qudida,albumentations
sudo chmod 666 /dev/gpiochip*

```

## Step 6: (Optional) Fix for pink tint on CSIC cameras
* Step 3: Check the TF and OpenCV installation

If you're using a CSIC camera you may have a pink tint on the images. As described [here](https://jonathantse.medium.com/fix-pink-tint-on-jetson-nano-wide-angle-camera-a8ce5fbd797f), this fix will remove it.
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:

```bash
export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libnvinfer.so.8:/usr/lib/aarch64-linux-gnu/libgomp.so.1
```
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

Note, this has to be done either every time you run donkeycar or tensorflow, or
you put the above line into your `.bashrc`.

```bash
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())
```

## Step 7: (Optional) Install PyGame for USB camera
#### Step 4c: (Optional) Install PyGame for USB camera

If you plan to use a USB camera, you will also want to setup pygame:

```bash
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 pygame
```
Later on you can add the `CAMERA_TYPE="WEBCAM"` in myconfig.py.


## (Optional) Fix for pink tint on CSIC cameras

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](https://jonathantse.medium.com/fix-pink-tint-on-jetson-nano-wide-angle-camera-a8ce5fbd797f),
this fix will remove it.

```bash
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
```

Later on you can add the `CAMERA_TYPE="WEBCAM"` in myconfig.py.

----

### Next, [create your Donkeycar application](/guide/create_application).
## Next, [create your Donkeycar application](/guide/create_application).
Loading