Skip to content

kunika/bonbon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐕 bonbon

Hardware

* Argon THRML 60mm Radiator Cooler may possibly be better cooling solution than the official Active Cooler if using the Pi to generate image/video/audio embeddings.


Operating System

  1. Install the OS.

    • Operating System: Raspberry Pi OS (Bookworm, 64-bit)
    • Hostname: bonbon
    • Username: pi
    • Password: let***n!**
  2. Configure the Raspberry Pi to boot from the NVMe SSD.

    See https://learn.pimoroni.com/article/getting-started-with-nvme-base#setting-the-raspberry-pi-to-boot-from-the-nvme-ssd


Docker

Source: https://docs.docker.com/engine/install/debian/

  1. Add Docker's GPG key.

    sudo apt update
    sudo apt install ca-certificates curl
    # If keyrings isn't already installed.
    #sudo install -m 0755 -d /etc/apt/keyrings
    sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
    sudo chmod a+r /etc/apt/keyrings/docker.asc
  2. Add Docker's repository to apt sources.

    echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  3. Update theapt list.

    sudo apt update
  4. Install Docker.

    sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

    To install a specific version:

    1. List the available versions.

      apt-cache madison docker-ce | awk '{ print $3 }'
      
      5:25.0.0-1~debian.12~bookworm
      5:24.0.7-1~debian.12~bookworm
      ...
    2. Select the desired version and install.

      VERSION_STRING=5:25.0.0-1~debian.12~bookworm
      sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin
  5. Verify that the installation is successful by running the example hello-world image.

    sudo docker run --rm hello-world

    The output will look like this:

    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    
    To generate this message, Docker took the following steps:
     1. The Docker client contacted the Docker daemon.
     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
        (arm64v8)
     3. The Docker daemon created a new container from that image which runs the
        executable that produces the output you are currently reading.
     4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.
    
    To try something more ambitious, you can run an Ubuntu container with:
     $ docker run -it ubuntu bash
    
    Share images, automate workflows, and more with a free Docker ID:
     https://hub.docker.com/
    
    For more examples and ideas, visit:
     https://docs.docker.com/get-started/
  6. Add the Raspberry Pi user to docker group so that Docker command can be run without sudo.

    sudo usermod -a pi -G docker

    This will come into effect on next reboot, but for now, add the user to the new group manually:

    newgrp docker

Manage Docker's disk usage

Docker persists build cache, containers, images, and volumes to disk, and over time, these artifacts can build up and take up a lot of space on a system.

Task Command
View disk usage. docker system df
List all running containers docker container ls
List all containers, both running and docker container ls -a
List unused containers. docker container ls -f status=exited -f status=dead
List all images docker image ls
List all images including intermediate images docker image ls -a
List danging images docker image ls -f dangling=true
Remove all stopped containers. docker container prune
Remove dangling images. docker image prune
Remove anonymous volumes. docker volume prune
Remove build cache. docker buildx prune
Remove unused networks. docker network prune
Remove all unused containers, networks, images (dangling) and build cache (unused). docker system prune
⚠️ ​​Remove all dangling and unused images. docker image prune -a
⚠️ ​Remove all anonymous and unused volumes. docker volume prune -a
⚠️ ​Remove all unused containers, networks, and images (both dangling and unused), and build cache (unused). docker system prune -a
⚠️ ​Remove all unused containers, networks, images (both dangling and unused), volumes (anonymous and unused) and build cache (all). docker system prune -a --volumes

Use the -f or --force option with prune to mute the prompts for confirmation e.g. docker image prune -f

See: https://docs.docker.com/reference/cli/docker/


Samba

Source: https://www.jeffgeerling.com/blog/2021/htgwa-create-samba-smb-share-on-raspberry-pi

  1. Install Samba.

    sudo apt install samba samba-common-bin
  2. Create the directory to share.

    mkdir /home/pi/Projects
  3. Configure samba share.

    sudo nano /etc/samba/smb.conf

    At the bottom of the file, add the following lines:

    [pi-share]
    path=/home/pi/Projects
    writable=yes
    create mask=0775
    directory mask=0775
    public=no
  4. Restart Samba.

    sudo systemctl restart smbd
  5. Create a user and password for Samba access.

    sudo smbpasswd -a pi # e.g. raspberry
  6. Connect to the share.

    Find the IP address or host name of your Raspberry Pi.

    hostname -I
    # Output: 192.168.1.173 172.17.0.1
    
    hostname
    # Output: bonbon

    Use the first IP address i.e. 192.168.1.173 to connect to the samba share.


RAM Optimisation

Disabling the Dektop GUI

Disable/enable GUI temporarily

  • To disable, press the Ctrl+Alt+F1 keys to enter console mode, and then run the command:

    sudo systemctl isolate multi-user.target
  • To enable, run the following command, and then press the Ctrl+Alt+F1 keys to switch to Desktop.

    sudo systemctl isolate graphical.target

Disable/enable GUI by default

  • To disable, press the Ctrl+Alt+F1 keys to enter console mode, and then run the commands:

    sudo systemctl set-default multi-user.target
    sudo reboot
  • To enable, run the commands:

    sudo systemctl set-default graphical.target
    sudo reboot

Mounting swap

Disabling, enabling and modifying Raspberry Pi's default swap on the boot microSD Card or SSD.

Enable swap file service

  1. Check if the swapfile service is enabled.

    systemctl is-enabled dphys-swapfile

    If the output is disabled, enable it with the command:

    sudo systemctl enable dphys-swapfile
  2. Check if the swapfile service is active/running.

    systemctl is-active dphys-swapfile

    If the output is inactive, start it with the command:

    sudo systemctl start dphys-swapfile

Increase/decrease swap size

  1. Turn the swap off.

    sudo dphys-swapfile swapoff
  2. Open and edit the configuration file.

    sudo nano /etc/dphys-swapfile

    Search for the following line in the file (e.g. use the Ctrl+W shortcut to search in-file) and edit the swap size. The size must given in megabytes, and the specified size must be available on the boot microSD card/SSD.

    CONF_SWAPSIZE=100

    e.g. increase the swapsize to 1GB:

    CONF_SWAPSIZE=1024

    e.g. increase the swapsize to 2GB:

    CONF_SWAPSIZE=2048
  3. Reinitialize the swap file.

    sudo dphys-swapfile setup

    The command will delete the original/previous swap file and recreate it with the new size.

  4. Turn the swap on.

    sudo dphys-swapfile swapon
  5. Reboot.

    sudo reboot
  6. Verify.

    free -h
                   total        used        free      shared  buff/cache   available
    Mem:           7.9Gi       642Mi       6.5Gi        45Mi       866Mi       7.2Gi
    Swap:          2.0Gi          0B       2.0Gi

Disable swap file service

  1. Turn the swap off.

    sudo dphys-swapfile swapoff
  2. Uninstall the swap file.

    sudo dphys-swapfile uninstall
  3. Stop the swap file service.

    sudo systemctl stop dphys-swapfile
  4. Disable the swap file service.

    sudo systemctl disable dphys-swapfile
  5. Reboot.

    sudo reboot

GitHub SSH Access

Source:

  1. Generate a new GitHub SSH key.

    ssh-keygen -t ed25519 -C "your_email@example.com"
  2. Add SSH key to the ssh-agent.

    1. Start the ssh-agent in the background.

      eval "$(ssh-agent -s)"
    2. Add SSH private key to the ssh-agent.

      ssh-add ~/.ssh/id_github
  3. Add the public key to GitHub.

    cat ~/.ssh/id_github.pub
    # Then select and copy the contents of the id_github.pub file
    # displayed in the terminal as a new SSH key at https://github.com/settings/keys
  4. Authenticate and verify access.

    ssh -T git@github.com

Pyenv

Source: https://github.com/pyenv/pyenv

  1. Install build dependencies.

    sudo apt update; sudo apt install build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev llvm

    See: https://github.com/pyenv/pyenv/wiki#suggested-build-environment

  2. Install Pyenv.

    curl https://pyenv.run | bash
  3. Set up shell environment for Pyenv.

    Add the following to ~/.bashrc:

    export PYENV_ROOT="$HOME/.pyenv"
    command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
    eval "$(pyenv init -)"

    If there is ~/.bash_profile, add the following to it:

    export PYENV_ROOT="$HOME/.pyenv"
    [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
    eval "$(pyenv init -)"

    Otherwise, add the following to ~/.profile:

    export PYENV_ROOT="$HOME/.pyenv"
    command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
    eval "$(pyenv init -)"
  4. Reload ~/.bashrc settings.

    source ~/.bashrc

Visual Studio Code/VSCodium

Visual Studio Code (VS Code)

Source: https://code.visualstudio.com/docs/setup/linux

  1. Download the .deb package from https://code.visualstudio.com/download.

    wget https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64
  2. Install.

    sudo apt install code_1.90.2-1718751586_amd64.deb

    Installing the .deb package will automatically install the apt repository and signing key to enable auto-updating using the system's package manager.

VSCodium

Source: https://vscodium.com/

  1. Add VSCodium's GPG key.

    wget -qO - https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg | gpg --dearmor | sudo dd of=/usr/share/keyrings/vscodium-archive-keyring.gpg
  2. Add VSCodium's repository to apt sources.

    echo 'deb [ signed-by=/usr/share/keyrings/vscodium-archive-keyring.gpg ] https://download.vscodium.com/debs vscodium main' | sudo tee /etc/apt/sources.list.d/vscodium.list
  3. Update theapt list.

    sudo apt update
  4. Install VSCodium.

    sudo apt install codium

Use Visual Studio Code/VSCodium without installing on Raspberry Pi

This involves accessing files on Raspberry Pi from another/remote computer that is on the same network as your Raspberry Pi via Visual Studio Code/VSCodium and SSH.

  1. In Visual Studio Code/VSCodium on your remote computer, open the Command Palette, using Shift + Command + P (Mac) / Ctrl + Shift + P (Windows/Linux).
  2. Search for Remote-SSH: Connect to Host...
  3. Enter your username and hostname for your Raspberry Pi e.g. pi@bonbon.local.
  4. When prompted, enter your password for your user account on your Raspberry Pi.
  5. Select the directory to open.

Use remote Python kernel in Visual Studio Code/VSCodium

Source: https://code.visualstudio.com/docs/datascience/jupyter-kernel-management#_existing-jupyter-server

  1. On your Raspberry Pi, start Jupyter Notebook or Jupyter Lab, either on the Pi or in Docker container.

  2. On another computer that is on the same network as your Raspberry Pi, open a new or existing notebook in VSCodium or Visual Studio Code.

  3. Click the Select Kernel button (top right hand of VSCodium/Visual Sudio Code window), and select Existing Jupyter Server (the options will appear in the address bar).

  4. Enter the URL of your Jupyter Notebook or Jupyter Lab running on the Raspberry Pi.

  5. Enter the password or token for your Jupyter Notebook or Jupyter Lab.

  6. For Change server display name, accept the given name or delete it.

  7. Select Python 3 (ipykernel).

  8. Verify by putting the following in a cell and running the cell.

    import os
    os.listdir()

    This should output a list of directories on Raspberry Pi e.g. in Docker container:

    ['sbin',
     'media',
     'lib',
     'opt',
     'etc',
     'sys',
     'usr',
     'home',
     'run',
     'tmp',
     'boot',
     'srv',
     'root',
     'dev',
     'bin',
     'var',
     'proc',
     'mnt',
     'app',
     '.dockerenv']

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published