This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

project

Message Relay Agent

  • Role: Facilitates seamless communication and transfer of information between different crews and their respective agents.
  • Functionality: Receives notes, codes, and text from one crew’s agents and efficiently delivers them to the appropriate agents in other crews.
  • Responsibilities:
    • Ensuring timely and accurate transmission of information.
    • Maintaining confidentiality and integrity of transferred data.
    • Facilitating collaboration and coordination among crews.

Research Crew

  • Focus: Gather in-depth knowledge and insights about the operating system. Identify key features, advancements, user needs, and common challenges.
  • Agents:
    1. Deep Researcher: Conducts thorough research into technical specifications, history, and ecosystem of the operating system.
    2. Subject Matter Expert (SME): Provides authoritative insights into specific areas of the operating system, based on the tutorial’s focus.
    3. Data Analyst: Analyzes trends, user data, and feedback to guide the tutorial’s scope and focus areas.
    4. Librarian/Information Specialist: Sources and organizes high-quality resources, academic papers, and documentation for reference.

Design Crew

  • Focus: Design the tutorial’s structure, ensuring it’s engaging, educational, and accessible to the target audience.
  • Agents:
    1. CPO (Chief Product Officer): Ensures the tutorial aligns with user needs and product goals.
    2. CTO (Chief Technology Officer): Provides technical oversight, ensuring the tutorial’s content is accurate and feasible.
    3. Designer: Focuses on the tutorial’s visual and UX aspects, including diagrams, interface designs, and multimedia elements.
    4. CEO: Reviews the design for strategic alignment with company vision and market positioning.

Coding Crew

  • Focus: Develop code examples, demos, or scripts that illustrate the operating system’s functionalities and features.
  • Agents:
    1. Programmer: Implements and tests the code examples, ensuring they are clear, functional, and well-commented.
    2. CTO: Reviews code for technical accuracy, best practices, and security considerations.
    3. Designer: Works on any UI/UX aspects related to the code examples or demos, ensuring they are user-friendly and visually appealing.

Testing Crew

  • Focus: Thoroughly test the code examples, demos, and any associated applications to ensure they work as expected across different environments.
  • Agents:
    1. Tester: Executes test plans, reports issues, and verifies bug fixes for the code examples and demos.
    2. Programmer: Addresses any bugs or issues found during testing, refining the code as needed.
    3. Reviewer: Conducts code reviews for quality assurance, focusing on maintainability, performance, and adherence to standards.

Documentation Crew

  • Focus: Create the final tutorial content, integrating research findings, design principles, code examples, and testing insights.
  • Agents:
    1. CTO: Ensures technical accuracy and completeness of the tutorial content.
    2. Programmer: Provides detailed explanations and insights for code examples and technical processes.
    3. CEO: Reviews the final content for alignment with overarching goals, user engagement, and educational value.
    4. CPO: Ensures the tutorial meets user needs, is accessible, and aligns with product objectives.

Building the Project

  1. Research Phase: Start with the Research Crew to establish a solid foundation of knowledge. This step sets the direction and scope of the tutorial.
  2. Design Phase: With insights from research, move to the Design Crew to structure the tutorial, plan content segments, and design interactive elements.
  3. Message Relay Agent: Introduce the Message Relay Agent to facilitate seamless communication and transfer of information between crews. This ensures efficient collaboration and coordination throughout the project.
  4. Coding Phase: Develop and refine code examples or demos with the Coding Crew, ensuring they illustrate key concepts effectively.
  5. Testing Phase: Have the Testing Crew thoroughly test all code elements to ensure accuracy and reliability.
  6. Documentation Phase: Compile and refine the tutorial content with the Documentation Crew, integrating all elements into a cohesive, engaging educational resource.

1 - Jetson Nano Setup Guide

A comprehensive guide to setting up your Jetson Nano.

Introduction

Welcome to the Jetson Nano Setup Guide! This guide will walk you through the process of setting up your Jetson Nano developer kit, from downloading the system image to configuring advanced usage scenarios.

Download Jetson Nano Image

Before you begin, you’ll need to download the system image for your Jetson Nano model:

Setting up the MicroSD with Ubuntu using balenaEther

  1. Go to this website
  2. Find and download Jetson Nano Developer Kit SD Card Image
  3. Download and install balenaEtcher
  4. Open balenaEthcer
    1. Select: Flash from file
    2. Select: jetson-nano-jp461-sd-card-image.zip
    3. Select the MicroSD card
    4. Flash!
  5. Place the MicroSD back into the jetson nano and start.

Fresh Install Setup Guide for Jetson Nano

Once your Jetson Nano board is up and running with Ubuntu Desktop, let’s kickstart the setup process by opening the terminal and following these steps:

Step 1: Update System

First, let’s ensure your system is up to date:

sudo apt update

Next, upgrade your Jetson Nano:

sudo apt upgrade -y

During the upgrade process, you may encounter prompts for configuration files.

Select Y to install the package maintainer’s version.

Configuration file '/etc/ld.so.conf.d/nvidia-tegra.conf'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** nvidia-tegra.conf (Y/I/N/O/D/Z) [default=N] ? Y

Again select Y to install the package maintainer’s version.

Configuration file '/etc/systemd/nv-oem-config-post.sh'
 ==> Deleted (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** nv-oem-config-post.sh (Y/I/N/O/D/Z) [default=N] ? Y

Additionally, if prompted to restart Docker, select YES.

Now, let’s perform a distribution upgrade:

sudo apt dist-upgrade -y

Step 2: Clean Up

Once the upgrade process is complete, let’s tidy up by removing old packages:

sudo apt autoremove -y

And finally, let’s clean up the cache:

sudo apt clean

Step 3: Reboot

After these maintenance tasks, it’s recommended to reboot your Jetson Nano for changes to take effect:

sudo reboot now

Install Useful Tools

Here are some essential tools that are handy for almost every project:

sudo apt install git nano curl wget -y

Uninstall LibreOffice

If you no longer need LibreOffice and want to reclaim some disk space, follow these steps to remove it:

sudo apt autoremove libreoffice* -y

This command will uninstall all LibreOffice packages from your system.

After removing LibreOffice, let’s clean up the residual files:

sudo apt clean

This command will clean the package cache, freeing up additional disk space.

Your system is now free of LibreOffice and optimized for your needs.

Installing pip and pip3

To install both pip and pip3, which are package managers for Python 2 and Python 3 respectively, run the following command:

sudo apt install python-pip python3-pip -y

This command will install pip for Python 2 and pip3 for Python 3 on your system.

You’re all set with pip and pip3 installed and ready to manage Python packages!

Installing Jetson Stats

To install Jetson Stats, a utility for monitoring and controlling NVIDIA Jetson devices, follow these steps:

sudo pip3 install -U jetson-stats

This command will install Jetson Stats and ensure that you have the latest version.

After installation, reboot your Jetson Nano to enable the jtop command:

sudo reboot now

Once your device has rebooted, reopen the terminal and type the following command to launch Jetson Stats:

jtop

This will open the Jetson Stats interface, allowing you to monitor various aspects of your Jetson Nano’s performance.

You’re now ready to utilize Jetson Stats for optimizing your Jetson Nano’s performance!

Configuring Jetson Fan to Start at Boot

To ensure your Jetson Nano’s fans start automatically at boot, follow these steps:

  1. Open and edit the rc.local file using the Nano text editor:
sudo nano /etc/rc.local

Paste the following lines into the file:

#!/bin/bash
sleep 10
sudo /usr/bin/jetson_clocks
sudo sh -c 'echo 255 > /sys/devices/pwm-fan/target_pwm'
exit 0
  1. Next, create and edit the rc-local.service file:
sudo nano /etc/systemd/system/rc-local.service

Insert the following content:

[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target
  1. Ensure the rc.local file has execute permissions:
sudo chmod +x /etc/rc.local
  1. Now, enable the rc-local service to run on system boot:
sudo systemctl enable rc-local
  1. Start the rc-local service:
sudo systemctl start rc-local.service

Your Jetson Nano’s fans will now start automatically at boot, ensuring optimal cooling performance.

Increase Swap Space

To increase the swap space on your Jetson Nano, follow these steps:

  1. Clone the resizeSwapMemory repository:
git clone https://github.com/JetsonHacksNano/resizeSwapMemory
  1. Navigate to the cloned repository:
cd resizeSwapMemory
  1. Set the entire swap memory size to 8GB:
./setSwapMemorySize.sh -g 8

This will ensure sufficient memory for the OpenCV installation.

OpenCV Installation Guide

Before installing OpenCV on your Jetson Nano, ensure that your system has sufficient memory by following the steps above to increase swap space if needed.

Next, download the OpenCV installation script:

wget https://github.com/Qengineering/Install-OpenCV-Jetson-Nano/raw/main/OpenCV-4-8-0.sh

Set the appropriate permissions for the script:

sudo chmod 755 ./OpenCV-4-8-0.sh

Run the installation script:

./OpenCV-4-8-0.sh

Once the installation is complete, you can remove the installation script:

rm OpenCV-4-8-0.sh

Finally, you can remove the dphys-swapfile:

sudo /etc/init.d/dphys-swapfile stop
sudo apt-get remove --purge dphys-swapfile

As a tip to save additional space, you can remove the OpenCV and OpenCV_contrib directories:

sudo rm -rf ~/opencv
sudo rm -rf ~/opencv_contrib

Congratulations! You’ve successfully installed OpenCV on your Jetson Nano.

Install Python 3.12 on Jetson Nano From Source

Python 3.12 brings new features, improvements, and optimizations to the language, making it desirable for developers who want to leverage the latest capabilities.

To install Python 3.12 on your Jetson Nano from source, follow these steps:

  1. Update your system’s package list:
sudo apt update
  1. Install the necessary dependencies for building Python:
sudo apt install wget build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev -y
  1. Create a directory for the Python source code and navigate to it:
mkdir ./python && cd ./python
  1. Download the Python source code. Replace 3.12.0 with the desired Python version:
wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz
  1. Extract the downloaded archive:
tar -xvf Python-3.12.0.tgz
  1. Navigate to the extracted directory:
cd Python-3.12.0
  1. Configure the build with optimizations enabled:
./configure --enable-optimizations
  1. Compile and install Python:
sudo make install
  1. After completing the installation, reboot your Jetson Nano:
sudo reboot now

After rebooting, Python 3 will be installed on your Jetson Nano from the source code. You can verify the installation by running python3 --version.

Install CrewAI on Jetson Nano

CrewAI is a powerful AI platform designed to assist with a variety of tasks. To install CrewAI on your Jetson Nano, follow these steps:

To install the main CrewAI package, which includes core functionalities, run the following command:

pip3 install crewai

If you also want to install the tools package, which includes a series of helpful tools for your agents, you can use the following command:

pip3 install 'crewai[tools]'

This command will install the main CrewAI package along with additional tools to enhance your CrewAI experience.

Once installed, you can start using CrewAI to develop and deploy AI solutions on your Jetson Nano.

Make test script for crewAI (Testing)

mkdir test_ai && cd test_ai
nano .env

and then add this

ANTHROPIC_API_KEY=your_anthropic_api_key

Now save and close nano

now let’s create our main.py

nano main.py

And then add this code below

import os
from dotenv import load_dotenv
from crewai import Agent, Task, Crew
from langchain.llms import Anthropic
from textwrap import dedent

# Load the API key from the .env file
load_dotenv()
ANTHROPIC_API_KEY = os.getenv("ANTHROPIC_API_KEY")

# Define a simple agent
class SimpleAgent:
    def __init__(self):
        self.Claude = Anthropic(anthropic_api_key=ANTHROPIC_API_KEY, temperature=0.7)

    def create_agent(self):
        return Agent(
            role="Simple Test Agent",
            backstory=dedent("""You are a helpful assistant."""),
            goal=dedent("""Your goal is to assist the user with their query."""),
            allow_delegation=False,
            verbose=True,
            llm=self.Claude,
        )

# Define a simple task
class SimpleTask:
    def __init__(self, user_query):
        self.user_query = user_query

    def create_task(self, agent):
        return Task(
            description=dedent(
                f"""
            Please assist with the following query:
            
            {self.user_query}
        """
            ),
            agent=agent,
        )

# Main function
if __name__ == "__main__":
    print("## Welcome to the Crew AI Test")
    print("-------------------------------")

    user_query = input(dedent("""Enter your query: """))

    simple_agent = SimpleAgent().create_agent()
    simple_task = SimpleTask(user_query).create_task(simple_agent)

    crew = Crew(agents=[simple_agent], tasks=[simple_task], verbose=True)
    result = crew.kickoff()

    print("\n\n########################")
    print("## Here is the result:")
    print("########################\n")
    print(result)

1.1 - step one

Required Items

  • Nvidia Jeton Nano
  • MicroSD card
  • Nocuafan
  • Powersupply 5w
  • Keyboard/mouse
  • Internet cable
  • External SSD or M2 harddrive
  • WiFi

NOTE: This will eb the simpel version as i will make an other guide how to update the iso with new kernel without breaking stuff. It has been a while that Nvidia has been updating there Jetson Nano iso.

Setting up the MicroSD with Ubuntu using balenaEther

  1. Go to this website
  2. Find and download Jetson Nano Developer Kit SD Card Image
  3. Download and install balenaEtcher
  4. Open balenaEthcer
    1. Select: Flash from file
    2. Select: jetson-nano-jp461-sd-card-image.zip
    3. Select the MicroSD card
    4. Flash!
  5. Place the MicroSD back into the jetson nano and start.

Setting up Ubuntu on Jetson Nano

  1. Powerup the Jetson Nano and let the device bootup fully

Make Jetson Nano ready

sudo systemctl enable ssh
sudo reboot now

check what versions we have

docker --version
python --version
python3 --version
git --version

Login with

sudo apt update && sudo apt upgrade
git clone https://github.com/jetsonhacksnano/bootFromUSB
cd bootFromUSB
./copyRootToUSB.sh -p /dev/sda1

Jetson Nano with CrewAI, Claude and OpenAI

Yes you read this right im gonna build an nice system with the jetson nano that use ai and camera

  • Face Reconiziion
  • Speeche Reconigzion

Items

BootfromUSB


LABEL primary
      MENU LABEL primary kernel
      LINUX /boot/Image
      INITRD /boot/initrd
      APPEND ${cbootargs} root=PARTUUID=b49df390-238c-4497-99a6-0643b9077530 rootwait rootfstype=ext4

LABEL secondary
      MENU LABEL secondary kernel
      LINUX /boot/Image
      INITRD /boot/initrd
      APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0

Other

sudo nano /etc/apt/sources.list.d/nvidia-l4t-apt-source.list
# SPDX-FileCopyrightText: Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: LicenseRef-NvidiaProprietary
#
# NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
# property and proprietary rights in and to this material, related
# documentation and any modifications thereto. Any use, reproduction,
# disclosure or distribution of this material and related documentation
# without an express license agreement from NVIDIA CORPORATION or
# its affiliates is strictly prohibited.

deb https://repo.download.nvidia.com/jetson/common r32.7 main
deb https://repo.download.nvidia.com/jetson/t210 r32.7 main

IMX298 CAM Arducam

CSI Camera

sudo apt install libcanberra-gtk-module libcanberra-gtk3-module -y

pip tools needed

sudo pip3 install -U jetson-stats v4l2-fix

Advanced Usage Examples

1. Machine Learning Frameworks

Example: Install and configure popular machine learning frameworks like TensorFlow, PyTorch, or MXNet to leverage the Jetson Nano’s GPU for accelerated deep learning tasks.

Guide:

  • Follow the official documentation or community tutorials for each framework to install the required dependencies and set up GPU support.
  • Utilize pre-trained models or train custom models using datasets optimized for inference on edge devices.
  • Explore optimizations such as TensorRT integration for improved inference performance on the Jetson Nano.

2. Dockerized Applications

Example: Containerize applications using Docker to simplify deployment and manage dependencies on the Jetson Nano.

Guide:

  • Install Docker CE (Community Edition) on the Jetson Nano by following the official Docker documentation.
  • Create Dockerfiles to define the application environment and dependencies.
  • Build Docker images for your applications and run them in containers on the Jetson Nano.
  • Explore Docker Compose for orchestrating multi-container applications or deploying services with dependencies.

3. IoT Integration

Example: Integrate the Jetson Nano into IoT (Internet of Things) projects for edge computing and sensor data processing.

Guide:

  • Interface sensors or peripherals with the Jetson Nano using GPIO pins, I2C, SPI, or USB interfaces.
  • Develop applications to collect, process, and transmit sensor data to cloud services or local IoT gateways.
  • Implement edge AI algorithms for real-time analytics, anomaly detection, or predictive maintenance in IoT deployments.
  • Explore MQTT (Message Queuing Telemetry Transport) or other IoT protocols for communication between devices and cloud services.

4. Computer Vision Applications

Example: Build computer vision applications using libraries like OpenCV or specialized frameworks for object detection, image recognition, or facial recognition.

Guide:

  • Install OpenCV and other relevant libraries using package managers or by compiling from source.
  • Experiment with pre-trained models for tasks like object detection (YOLO, SSD), image classification (ResNet, MobileNet), or semantic segmentation (DeepLab, Mask R-CNN).
  • Capture and process video streams from cameras or video files for real-time analysis or surveillance applications.
  • Explore techniques for optimizing computer vision algorithms for performance on resource-constrained devices like the Jetson Nano.

5. Robotics Projects

Example: Use the Jetson Nano as the brain of robotic systems for tasks such as autonomous navigation, object manipulation, or drone control.

Guide:

  • Interface sensors, actuators, and motor controllers with the Jetson Nano to enable sensing and control capabilities.
  • Develop control algorithms using frameworks like ROS (Robot Operating System) or libraries like Jetson.GPIO for GPIO control.
  • Implement perception algorithms for environment mapping, obstacle detection, or localization using onboard sensors or external cameras.
  • Integrate AI models for tasks like object detection, gesture recognition, or path planning to enable autonomous behavior in robotic systems.

These advanced usage examples demonstrate the versatility of the Jetson Nano for a wide range of applications beyond basic system setup and configuration.

Troubleshooting

1. Network Connectivity Issues

Problem: Unable to connect to the internet or download packages during setup.

Solution:

  • Check the network connection by running ping google.com. If there is no response, ensure that the Jetson Nano is properly connected to the network and that the router or modem is functioning correctly.
  • Verify network settings, including IP configuration and DNS servers, by running ifconfig and cat /etc/resolv.conf.
  • If using Wi-Fi, ensure that the correct SSID and password are entered, and try restarting the network interface with sudo systemctl restart networking.

2. Package Installation Errors

Problem: Encounter errors while installing packages with apt.

Solution:

  • Check for any typos in the package names or repository URLs.
  • Ensure that the package repositories are configured correctly by inspecting /etc/apt/sources.list and files in /etc/apt/sources.list.d/.
  • If encountering dependency issues, try running sudo apt --fix-broken install to resolve them automatically.

3. Hardware Compatibility Issues

Problem: Certain hardware components or peripherals are not recognized or functioning properly.

Solution:

  • Verify that the hardware is compatible with the Jetson Nano by checking manufacturer specifications or community forums.
  • Check for any firmware updates or driver installations required for the hardware to work with the Jetson Nano.
  • Test the hardware on another device or platform to confirm functionality, if possible.

4. System Freezes or Crashes

Problem: The Jetson Nano freezes or crashes unexpectedly during operation.

Solution:

  • Check system resource usage using tools like top or htop to identify any processes consuming excessive CPU or memory.
  • Ensure that the power supply is adequate and stable, as insufficient power can cause system instability.
  • Check system logs for error messages or warnings that might indicate the cause of the issue (/var/log/syslog, /var/log/kern.log, etc.).

5. Display or Graphics Issues

Problem: Encounter issues with the display output or graphics acceleration.

Solution:

  • Verify that the display cable is securely connected to the Jetson Nano’s HDMI or DisplayPort interface.
  • Check display settings and resolution configuration using the system settings or xrandr command.
  • Ensure that the appropriate NVIDIA drivers are installed and configured correctly for graphics acceleration.

If you encounter any other issues not covered here, feel free to seek assistance from the Jetson Nano community forums or NVIDIA support resources.

2 - OpenDevin Project Setup

A guide to set up your development environment for the OpenDevin project

Setting Up Your Development Environment

This guide will walk you through the steps to set up your development environment for the OpenDevin project. We’ll cover the installation of required tools, libraries, and dependencies, as well as the configuration of your project environment.

Prerequisites

Before you begin, ensure that you have the following prerequisites installed:

  • Ubuntu 22.04 LTS
  • Git

Step 1: Download Ubuntu 22.04

If you haven’t already, download the Ubuntu 22.04 LTS desktop version from the official Ubuntu website.

Step 2: Install Required Packages

Open the terminal and run the following commands to install the necessary packages:

1. NVIDIA Drivers

sudo ubuntu-drivers install

2. CUDA Toolkit

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda-repo-ubuntu2204-12-4-local_12.4.0-550.54.14-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2204-12-4-local_12.4.0-550.54.14-1_amd64.deb
sudo cp /var/cuda-repo-ubuntu2204-12-4-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda-toolkit-12-4
sudo apt-get install -y cuda-drivers

3. Docker Engine

sudo apt-get update
sudo apt-get install -y ca-certificates curl software-properties-common
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

After installing Docker, you need to be able to run Docker commands without sudo. To achieve this, follow these steps:

  1. Create a Unix group for Docker:
sudo groupadd docker
  1. Add your user to the Docker group:
sudo usermod -aG docker $USER
  1. Log out and log back in for the changes to take effect.

After logging back in, you should be able to run Docker commands without sudo. Verify this by running:

docker run hello-world

If the command runs without requiring sudo, you’ve successfully set up Docker to run without root privileges.

4. Anaconda

sudo apt-get install -y libgl1-mesa-glx libegl1-mesa libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6
curl -o ~/Downloads/Anaconda3-2024.02-1-Linux-x86_64.sh https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Linux-x86_64.sh
chmod +x ~/Downloads/Anaconda3-2024.02-1-Linux-x86_64.sh
bash ~/Downloads/Anaconda3-2024.02-1-Linux-x86_64.sh

After installing Anaconda, run the following commands to initialize and activate the base environment:

conda init
conda activate base

5. Ollama

curl -fsSL https://ollama.com/install.sh | sh

6. Node.js and npm

sudo apt update
sudo apt install -y nodejs npm

7. Pull Docker Image

docker pull ghcr.io/opendevin/sandbox:latest

Step 3: Set Up Your Project Environment

Now that you have all the required tools and libraries installed, it’s time to set up your project environment.

1. Create and Activate a Conda Environment

First, create a new Conda environment for your project:

conda create -n opendevin python=3.12 -y
conda activate opendevin

2. Install Pipenv

With your Conda environment activated, install Pipenv:

python -m pip install pipenv

3. Set Up Your Project with Pipenv

Navigate to your project directory and initialize your environment with Pipenv:

python -m pipenv install -v

4. Activate the Pipenv Shell

To work within your project’s virtual environment, activate the Pipenv shell:

python -m pipenv shell

5. Run Your Application

With the project’s virtual environment activated, you can start your application. For example, to run a FastAPI application using uvicorn:

uvicorn your_project.server:app --port 3000

Replace your_project.server:app with the appropriate Python module path for your application.

6. Set Up the Frontend (if applicable)

If your project includes a frontend that uses Node.js and npm, navigate to the frontend directory from a new terminal or tab (to keep the backend server running). Install the required npm packages:

cd frontend
npm install

Start the frontend development server:

npm start

Resuming Your Project Work

Whenever you start a new terminal session and want to work on your project, follow these steps:

  1. Activate your Conda environment:
conda activate opendevin
  1. Navigate to your project directory and activate the Pipenv environment:
cd /path/to/your/project
python -m pipenv shell
  1. Start your backend application (if applicable):
uvicorn your_project.server:app --port 3000
  1. If you have a separate frontend, open a new terminal or tab, activate your Conda environment (conda activate opendevin), navigate to the frontend directory, and start the development server:
cd /path/to/your/frontend
npm start

Resuming Your Project Work

  1. Activate Your Conda Environment: Whenever you start a new terminal session and want to work on your project, the first step is to activate the Conda environment you created for your project. Use the command below, replacing myenv with the name of your Conda environment:

    conda activate myenv
    

    This step ensures that any Python or command-line tools you use are limited to the dependencies and versions installed within this environment, maintaining project consistency and avoiding conflicts with other projects.

  2. Activate Your Pipenv Environment: Next, navigate to your project directory where your Pipfile exists and activate the Pipenv environment. This step is crucial if you’re working on Python projects managed by Pipenv, as it ensures you’re using the correct versions of Python packages specified for your project:

    cd /path/to/your/project
    python -m pipenv shell
    

    This command activates the virtual environment for your project, configured by Pipenv. You’ll need to do this every time you work on your project to ensure you’re using the right Python environment.

  3. Start Your Backend Application: If your project includes a backend component (like a FastAPI application), start it with the relevant command. For a FastAPI app using Uvicorn, for example:

    uvicorn your_project.server:app --port 3000
    

    Make sure to replace your_project.server:app with the path to your application’s main module. This command needs to be run from within the Pipenv shell activated in step 2.

  4. Start Your Frontend Development Server: If you have a frontend that runs separately (like a React or Vue application), you’ll need to open a new terminal or a new tab. If the frontend requires any environment configurations from the Conda environment, activate the Conda environment again with conda activate myenv. Then navigate to your frontend directory:

    cd /path/to/your/frontend
    npm start
    

    This step launches the development server for your frontend, often with live reloading enabled, so you can continue working on the frontend with immediate feedback on changes.

Code example

#!/bin/bash

# Set configuration variables
CUDA_VERSION="12.4.0"
ANACONDA_VERSION="2024.02-1"
UBUNTU_VERSION=$(lsb_release -rs)

# Define functions
install_nvidia_drivers() {
    echo "Installing NVIDIA drivers..."
    sudo ubuntu-drivers install
}

install_cuda() {
    echo "Installing CUDA Toolkit $CUDA_VERSION..."
    wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION/./}/x86_64/cuda-ubuntu${UBUNTU_VERSION//.}.pin
    sudo mv cuda-ubuntu${UBUNTU_VERSION//.}.pin /etc/apt/preferences.d/cuda-repository-pin-600
    wget https://developer.download.nvidia.com/compute/cuda/${CUDA_VERSION}/local_installers/cuda-repo-ubuntu${UBUNTU_VERSION/./}-${CUDA_VERSION/-/_}-local_${CUDA_VERSION/-/_}-550.54.14-1_amd64.deb
    sudo dpkg -i cuda-repo-ubuntu${UBUNTU_VERSION/./}-${CUDA_VERSION/-/_}-local_${CUDA_VERSION/-/_}-550.54.14-1_amd64.deb
    sudo cp /var/cuda-repo-ubuntu${UBUNTU_VERSION/./}-${CUDA_VERSION/-/_}-local/cuda-*-keyring.gpg /usr/share/keyrings/
    sudo apt-get update
    sudo apt-get -y install cuda-toolkit-${CUDA_VERSION/-/.}
    sudo apt-get install -y cuda-drivers
}

install_docker() {
    echo "Installing Docker..."
    sudo apt-get install -y ca-certificates curl software-properties-common
    sudo mkdir -p /etc/apt/keyrings
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
    echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    sudo apt-get update
    sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

    echo "Setting up Docker to run without sudo..."
    sudo groupadd docker
    sudo usermod -aG docker $USER

    echo "Log out and log back in for the changes to take effect."
    echo "After logging back in, you can run 'docker run hello-world' to verify that Docker is running without sudo."
}

install_anaconda() {
    echo "Installing Anaconda $ANACONDA_VERSION..."
    sudo apt-get install -y libgl1-mesa-glx libegl1-mesa libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6
    curl -o ~/Downloads/Anaconda3-${ANACONDA_VERSION}-Linux-x86_64.sh https://repo.anaconda.com/archive/Anaconda3-${ANACONDA_VERSION}-Linux-x86_64.sh
    chmod +x ~/Downloads/Anaconda3-${ANACONDA_VERSION}-Linux-x86_64.sh
    bash ~/Downloads/Anaconda3-${ANACONDA_VERSION}-Linux-x86_64.sh -b
}

install_ollama() {
    echo "Installing Ollama..."
    curl -fsSL https://ollama.com/install.sh | sh
}

install_nodejs() {
    echo "Installing Node.js and npm..."
    sudo apt update
    sudo apt install -y nodejs npm
}

pull_docker_image() {
    echo "Pulling Docker image..."
    docker pull ghcr.io/opendevin/sandbox:latest
}

# Check for prerequisites
check_prerequisites() {
    if [ ! -d /etc/apt/keyrings ]; then
        sudo mkdir -p /etc/apt/keyrings
    fi

    if ! command -v wget &> /dev/null; then
        sudo apt-get install -y wget
    fi

    if [ "$(uname -m)" != "x86_64" ]; then
        echo "This script is only supported on x86_64 architecture."
        exit 1
    fi

    if [ ! -d ~/Downloads ]; then
        mkdir ~/Downloads
    fi
}

# Uninstall function
uninstall() {
    echo "Uninstalling installed packages..."
    sudo apt-get remove -y --autoremove cuda-toolkit-${CUDA_VERSION/-/.} cuda-drivers docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin nodejs npm
    rm -rf ~/anaconda3
    sudo rm -rf /etc/apt/keyrings/docker.gpg /etc/apt/sources.list.d/docker.list /var/lib/docker /var/lib/containerd
}

# Main script
check_prerequisites

echo "This script will install the following packages:"
echo "- NVIDIA drivers"
echo "- CUDA Toolkit $CUDA_VERSION"
echo "- Docker Engine"
echo "- Anaconda $ANACONDA_VERSION"
echo "- Ollama"
echo "- Node.js and npm"
echo "- Docker image: ghcr.io/opendevin/sandbox:latest"

read -p "Do you want to continue? (y/n) " choice
case "$choice" in
    y|Y)
        install_nvidia_drivers
        install_cuda
        install_docker
        install_anaconda
        install_ollama
        install_nodejs
        pull_docker_image
        ;;
    n|N)
        echo "Installation canceled."
        exit 0
        ;;
    *)
        echo "Invalid choice."
        exit 1
        ;;
esac

echo "Anaconda is installed. Please manually run 'source ~/anaconda3/bin/activate' and then 'conda init' to finish setting it up."
echo "Remember to activate the Conda environment and follow the guide for any application-specific setup."