The compulation of the onnx file (made here) to a hef file that runs on you Raspberry Pi5 AI kit
- Google account
- Paid subscription to Google Cloud Platform (GCP)
- Create a VM with GPU
- Generate public- and private SSH key
- Upload public key to CGP
- Use private key to connect VM with local terminal
- NVIDIA installation in GCP
- Install and access Jupyter.
- Create or Select a Project: Creat a
NEW PROJECTor use an excisting project in Google Cloud Platform (cloud.google.com) - Create VM instance: In the Navigation Menu (top left) navigate to
Compute Engine>VM instances> clickCREATE INSTANCE(top middel) - Configure the VM instance:
Name: choose a descriptive name such as
hailo-gpu.
Region/Zone: Select a region based on your location or target audience (affects latency). Choose a zone within the region for redundancy (availability).
Machine configuration: select GPU -> n1-standard-8 (8 vCPU, 30 GB memory). GCP offers Spot VMs for lower costs. However, these VMs can be interrupted if needed by GCP, but 60-90% discount.
Boot disk:
Click SWITCH IMAGE and select
- Image: Ubuntu 20.04 LTS x86/64
- Standard persistent disk
- Size: 200 GB
- Standard persistent disk to save costs.
- Size (GB): 200 GB and resize upwars later if needed. Downgrading size is not possible.
Firewall: activate allow HTTP traffic (needed for Jupyter notebook on local browser).
5. Click CREATE
In your local terminal generate a public- and private key with the following command below. Replace PATH with a secure location on your local drive where you store your keys (for example ~/.ssh/). Replace KEYNAME with a descriptive name (for example CGPkey). Replace USERNAME with your username in GCP. (Optional: a strong passphrase for added security).
ssh-keygen -t rsa -b 4096 -f PATH/KEYNAME -C USERNAME- In GCP Navigation Menu navigate to
Compute Engine>Metadata>SSH KEYS>EDIT>+ADD ITEM - Open your public key in your local terminal (for example with nano GCPkey.pub)
- Copy this key
- In GCP click
ADD SSH KEY - Paste the key in SSH key #
- click 'SAVE'
- Obtain VM External IP: In the GCP Navigation Menu, navigate to Compute Engine > VM instances. Ensure the VM instance is active. If not, click Start/resume in the instance's menu. Copy External IP address of the instance.
- Establish SSH Connection: Open a terminal in your local machine. Use the following command, replacing ~/.ssh with the path you use to store public- and private keys. Replace KEYNAME with your key-name (such as GCPkey), USERNAME with your GCP username and EXTERNALIP with the copied IP, confirm the connection when prompted.
ssh -i ~/.ssh/KEYNAME USERNAME@EXTERNALIP- Install the NVIDIA Driver 525:
sudo apt install libnvidia-common-525 libnvidia-gl-525 nvidia-driver-525 -yReboot after installation and SSH to the instance again as described before.
sudo rebootssh -i ~/.ssh/KEYNAME USERNAME@EXTERNALIP- Install NVIDIA Container Toolkit:
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
sudo systemctl restart docker- Install CUDA 11.8:
wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run
sudo sh cuda_11.8.0_520.61.05_linux.run- Select
continuewhen installer finds an existing package manager installation of the driver. - Uncheck the driver installation as we've already installed driver 525.
- Then select
installinstallation option.
- Set up environment variables. Add the following lines to your ~/.bashrc file:
echo 'export PATH=/usr/local/cuda-11.8/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH' >> ~/.bashrcApply the changes:
source ~/.bashrc- Verify the installation with:
nvidia-smi
nvcc -V- Activate your virtual environment:
. hailo-dfc/bin/activate- Install jupyter-notebook
sudo apt-get install jupyter-notebook- Run Jupyter Notebook:
jupyter notebook --no-browser --ip=0.0.0.0 --port=8888After starting Jupyter, you'll see the URLs in the terminal with a token:Or copy and paste one of these URLs: http://hailo-dfc:8888/?token= followed by the token.
Copy this token.
4. Option A: Open your browser and use this URL:
http://EXTERNALIP:8888Enter the token to get access to the Jupyter notebook. 4. Option B: When you have firewall issues run this on your local terminal:
ssh -N -L localhost:8888:localhost:8888 USERNAME@EXTERNALIPAccess Jupyter notebook by typing this in your local browser
http://localhost:8888Enter the token to get access to the Jupyter notebook.
After this installation next time to use Jupyter
- Start the VM
- Activate your virtual environment:
. hailo-dfc/bin/activate- Run Jupyter Notebook:
jupyter notebook --no-browser --ip=0.0.0.0 --port=8888After starting Jupyter, you'll see the URLs in the terminal with a token:Or copy and paste one of these URLs: http://hailo-dfc:8888/?token= followed by the token.
Copy this token.
4. Option A: Open your browser and use this URL:
http://EXTERNALIP:8888Enter the token to get access to the Jupyter notebook. 4. Option B: When you have firewall issues run this on your local terminal:
ssh -N -L localhost:8888:localhost:8888 USERNAME@EXTERNALIP