### Quick Start Installation Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/README.md Installs the openpilot software using a curl command. This is the primary method for getting started with openpilot on supported hardware. ```bash bash <(curl -fsSL openpilot.comma.ai) ``` -------------------------------- ### Run openpilot Setup Script Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tools/README.md Navigates into the cloned openpilot directory and executes the primary setup script. This script handles initial environment configuration and dependency installation. ```bash cd openpilot tools/op.sh setup ``` -------------------------------- ### Setup Openpilot Development Environment Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/docs/how-to/turn-the-speed-blue.md Clones the openpilot repository and installs all necessary dependencies using a provided bash script. This is the initial step for setting up a local development environment. ```bash bash <(curl -fsSL openpilot.comma.ai) ``` -------------------------------- ### Import necessary libraries Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/docs/quickstart.md Imports required modules for numerical operations and timing, setting up the environment for using tinygrad. ```python import numpy as np from tinygrad.helpers import Timing ``` -------------------------------- ### Install Data and ML Libraries (Python) Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v5.1/tinycorp/benchmarks/bert/implementations/tinybox_8xMI300X/README.md Installs essential Python libraries for data handling and machine learning tasks. Includes gdown for dataset downloads, numpy for numerical operations, tqdm for progress bars, and tensorflow for machine learning. ```shell pip install gdown numpy tqdm tensorflow ``` -------------------------------- ### Install Data and ML Libraries (Python) Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v5.0/tinycorp/benchmarks/bert/implementations/tinybox_8xMI300X/README.md Installs essential Python libraries for data handling and machine learning tasks. Includes gdown for dataset downloads, numpy for numerical operations, tqdm for progress bars, and tensorflow for machine learning. ```shell pip install gdown numpy tqdm tensorflow ``` -------------------------------- ### Install Data and ML Libraries (Python) Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v5.1/tinycorp/benchmarks/bert/implementations/tinybox_red/README.md Installs essential Python libraries for data handling and machine learning tasks. Includes gdown for dataset downloads, numpy for numerical operations, tqdm for progress bars, and tensorflow for machine learning. ```shell pip install gdown numpy tqdm tensorflow ``` -------------------------------- ### Setup Snapdragon Profiler Scripts Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tools/profiling/snapdragon/README.md Commands to set up the Snapdragon Profiler environment. This includes running the initial installation scripts and establishing a connection to the target device using ADB. ```shell ./setup-profiler.sh ./setup-agnos.sh ``` ```shell adb connect xxx ``` -------------------------------- ### Install tinygrad and mlperf-logging (Python) Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v5.1/tinycorp/benchmarks/bert/implementations/tinybox_8xMI300X/README.md Installs the tinygrad library and mlperf-logging from a specific branch. Requires cloning the tinygrad repository first. This is a prerequisite for using MLPerf features. ```shell git clone https://github.com/tinygrad/tinygrad.git python3 -m pip install -e ".[mlperf]" ``` -------------------------------- ### Install Data and ML Libraries (Python) Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v5.0/tinycorp/benchmarks/bert/implementations/tinybox_green/README.md Installs essential Python libraries for data handling and machine learning tasks. Includes gdown for dataset downloads, numpy for numerical operations, tqdm for progress bars, and tensorflow for machine learning. ```shell pip install gdown numpy tqdm tensorflow ``` -------------------------------- ### Install tinygrad and mlperf-logging (Python) Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v5.0/tinycorp/benchmarks/bert/implementations/tinybox_8xMI300X/README.md Installs the tinygrad library and mlperf-logging from a specific branch. Requires cloning the tinygrad repository first. This is a prerequisite for using MLPerf features. ```shell git clone https://github.com/tinygrad/tinygrad.git python3 -m pip install -e ".[mlperf]" ``` -------------------------------- ### Install Data and ML Libraries (Python) Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v5.0/tinycorp/benchmarks/bert/implementations/tinybox_red/README.md Installs essential Python libraries for data handling and machine learning tasks. Includes gdown for dataset downloads, numpy for numerical operations, tqdm for progress bars, and tensorflow for machine learning. ```shell pip install gdown numpy tqdm tensorflow ``` -------------------------------- ### Install tinygrad and mlperf-logging (Python) Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v5.1/tinycorp/benchmarks/bert/implementations/tinybox_red/README.md Installs the tinygrad library and mlperf-logging from a specific branch. Requires cloning the tinygrad repository first. This is a prerequisite for using MLPerf features. ```shell git clone https://github.com/tinygrad/tinygrad.git python3 -m pip install -e ".[mlperf]" ``` -------------------------------- ### Install Data and ML Libraries (Python) Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v5.1/tinycorp/benchmarks/bert/implementations/tinybox_green/README.md Installs essential Python libraries for data handling and machine learning tasks. Includes gdown for dataset downloads, numpy for numerical operations, tqdm for progress bars, and tensorflow for machine learning. ```shell pip install gdown numpy tqdm tensorflow ``` -------------------------------- ### Install tinygrad and mlperf-logging (Python) Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v5.1/tinycorp/benchmarks/bert/implementations/tinybox_green/README.md Installs the tinygrad library and mlperf-logging from a specific branch. Requires cloning the tinygrad repository first. This is a prerequisite for using MLPerf features. ```shell git clone https://github.com/tinygrad/tinygrad.git python3 -m pip install -e ".[mlperf]" ``` -------------------------------- ### Install tinygrad and mlperf-logging (Python) Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v5.0/tinycorp/benchmarks/bert/implementations/tinybox_red/README.md Installs the tinygrad library and mlperf-logging from a specific branch. Requires cloning the tinygrad repository first. This is a prerequisite for using MLPerf features. ```shell git clone https://github.com/tinygrad/tinygrad.git python3 -m pip install -e ".[mlperf]" ``` -------------------------------- ### Install tinygrad and mlperf-logging (Python) Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v5.0/tinycorp/benchmarks/bert/implementations/tinybox_green/README.md Installs the tinygrad library and mlperf-logging from a specific branch. Requires cloning the tinygrad repository first. This is a prerequisite for using MLPerf features. ```shell git clone https://github.com/tinygrad/tinygrad.git python3 -m pip install -e ".[mlperf]" ``` -------------------------------- ### Launch Snapdragon Profiler Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tools/profiling/snapdragon/README.md Steps to navigate to the Snapdragon Profiler directory and execute the main script to start the application. This allows you to connect to the device and begin profiling sessions. ```shell cd SnapdragonProfiler ./run_sdp.sh ``` -------------------------------- ### Install and Launch Jupyter Notebooks Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tools/car_porting/README.md Instructions for installing Jupyter and its kernel within the openpilot virtual environment, and how to launch the Jupyter notebook server. This enables the use of provided example notebooks for data analysis. ```bash uv pip install jupyter ipykernel jupyter notebook ``` -------------------------------- ### Project Setup and Testing Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/opendbc_repo/README.md Commands to clone the repository, install dependencies, build the project, run tests, and lint the code. This sequence ensures the development environment is correctly set up and the project integrity is maintained. ```bash git clone https://github.com/commaai/opendbc.git cd opendbc ./test.sh ``` ```bash # Install dependencies, including testing and documentation tools pip3 install -e .[testing,docs] ``` ```bash # Build the project using scons with parallel execution scons -j8 ``` ```bash # Run project tests using pytest pytest . ``` ```bash # Run pre-commit hooks to lint and format all files pre-commit run --all-files ``` -------------------------------- ### Using openpilot in a Car Setup Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/README.md Details the requirements for using openpilot in a vehicle, including the necessary hardware (comma 3/3X), software installation URL, car compatibility, and car harness. ```markdown Using openpilot in a car ------ To use openpilot in a car, you need four things: 1. **Supported Device:** a comma 3/3X, available at [comma.ai/shop](https://comma.ai/shop/comma-3x). 2. **Software:** The setup procedure for the comma 3/3X allows users to enter a URL for custom software. Use the URL `openpilot.comma.ai` to install the release version. 3. **Supported Car:** Ensure that you have one of [the 275+ supported cars](docs/CARS.md). 4. **Car Harness:** You will also need a [car harness](https://comma.ai/shop/car-harness) to connect your comma 3/3X to your car. We have detailed instructions for [how to install the harness and device in a car](https://comma.ai/setup). Note that it's possible to run openpilot on [other hardware](https://blog.comma.ai/self-driving-car-for-free/), although it's not plug-and-play. ``` -------------------------------- ### One-time setup for tinybox_red Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v4.1/tinycorp/benchmarks/bert/implementations/tinybox_red/README.md Performs the one-time setup required for the tinybox_red environment. This script configures the system before running benchmarks. ```shell examples/mlperf/training_submission_v4.1/tinycorp/benchmarks/bert/implementations/tinybox_red/setup.sh ``` -------------------------------- ### Saving and Loading Model Weights with Safetensors Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/docs/quickstart.md Provides an API reference for saving and loading neural network model weights using the safetensors format. It details the functions available in tinygrad.nn.state for managing model state dictionaries, including getting, saving, and loading. ```APIDOC tinygrad.nn.state: - safe_save(state_dict: dict, filename: str): Saves a model's state dictionary to a file in safetensors format. Parameters: state_dict: A dictionary containing the model's weights and parameters. filename: The path to the file where the state dictionary will be saved. - safe_load(filename: str) -> dict: Loads a state dictionary from a safetensors file. Parameters: filename: The path to the safetensors file. Returns: A dictionary representing the loaded state dictionary. - get_state_dict(model: object) -> dict: Retrieves the state dictionary from a given model object. Parameters: model: The model object from which to extract the state dictionary. Returns: A dictionary containing the model's state. - load_state_dict(model: object, state_dict: dict): Loads a state dictionary into a model object. Parameters: model: The model object to load the state into. state_dict: The state dictionary to load. Example Usage: ```python from tinygrad.nn.state import safe_save, safe_load, get_state_dict, load_state_dict # Assume 'net' is a pre-defined neural network model # Get the state dictionary of the model state_dict = get_state_dict(net) # Save the state dictionary to a file safe_save(state_dict, "model.safetensors") # Load the state dictionary back from the file loaded_state_dict = safe_load("model.safetensors") # Load the state dictionary into the model load_state_dict(net, loaded_state_dict) ``` Note: Many models in the tinygrad/extra/models folder provide a `load_from_pretrained` method, which often requires PyTorch to be installed for loading PyTorch weights. ``` -------------------------------- ### PlotJuggler Installation and Setup Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tools/plotjuggler/README.md Installs PlotJuggler and its openpilot plugins. Requires the openpilot environment to be set up beforehand. ```shell cd tools/plotjuggler && ./juggle.py --install ``` -------------------------------- ### One-time setup for tinybox_red Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v4.1/tinycorp/benchmarks/bert/implementations/tinybox_green/README.md Performs the one-time setup required for the tinybox_red environment. This script configures the system before running benchmarks. ```shell examples/mlperf/training_submission_v4.1/tinycorp/benchmarks/bert/implementations/tinybox_red/setup.sh ``` -------------------------------- ### Simulation Example Executable Target Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/third_party/acados/acados_template/c_templates_tera/CMakeLists.in.txt Defines and installs a simulation example executable if BUILD_SIM_EXAMPLE is enabled. It links model and simulation object files. ```CMake {% if solver_options.integrator_type != "DISCRETE" -%} # example_sim if(${BUILD_SIM_EXAMPLE}) set(EX_SIM_SRC main_sim_{{ model.name }}.c) set(EX_SIM_EXE main_sim_{{ model.name }}) add_executable(${EX_SIM_EXE} ${EX_SIM_SRC} $ $) install(TARGETS ${EX_SIM_EXE} DESTINATION ${CMAKE_INSTALL_PREFIX}) endif(${BUILD_SIM_EXAMPLE}) {%- endif %} ``` -------------------------------- ### Example: Full Camera Streaming Workflow Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tools/camerastream/README.md An example demonstrating the complete workflow: starting the stream decoder on the PC and then launching the display utility. This shows the typical usage pattern. ```bash cd ~/openpilot/tools/camerastream && ./compressed_vipc.py comma-ffffffff --cams 0 cd ~/openpilot/selfdrive/ui/ && ./watch3 ``` -------------------------------- ### Deploy Fork to Device Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/docs/how-to/turn-the-speed-blue.md Provides the URL format to install the custom openpilot fork onto a comma device. This involves uninstalling the existing version and then accessing a personalized installer URL. ```bash installer.comma.ai//master ``` -------------------------------- ### Serve openpilot docs locally (bash) Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/docs/README.md Starts a local web server to preview the openpilot documentation. The site will typically be accessible via http://localhost:8000. Run from the root directory of the openpilot project. ```bash mkdocs serve ``` -------------------------------- ### Stochastic Gradient Descent (SGD) Optimizer Initialization Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/docs/quickstart.md Demonstrates how to initialize the Stochastic Gradient Descent (SGD) optimizer in tinygrad. It shows passing the network's parameters and setting a learning rate, with a note on using `get_parameters` for a more concise approach. ```python from tinygrad.nn.optim import SGD opt = SGD([net.l1.weight, net.l2.weight], lr=3e-4) ``` -------------------------------- ### Install Additional Dependencies Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v5.1/tinycorp/benchmarks/retinanet/implementations/tinybox_green/README.md Installs essential Python packages required for the project, including data handling, machine learning, and utility libraries. ```shell pip install tqdm numpy pycocotools boto3 pandas torch torchvision ``` -------------------------------- ### Device Setup Commands Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tools/camerastream/README.md Commands to run on the openpilot device to start the necessary daemons for streaming video. These include bridge, encorderd, and camerad. ```bash cd /data/openpilot/cereal/messaging && ./bridge cd /data/openpilot/system/loggerd && ./encoderd cd /data/openpilot/system/camerad && ./camerad ``` ```bash ( cd /data/openpilot/cereal/messaging/ ./bridge & cd /data/openpilot/system/camerad/ ./camerad & cd /data/openpilot/system/loggerd/ ./encoderd & wait ) ; trap 'kill $(jobs -p)' SIGINT ``` -------------------------------- ### Tensor Creation with Data Types Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/docs/quickstart.md Shows how to specify the data type (dtype) for Tensors during creation, using predefined dtypes from the tinygrad library. ```python from tinygrad import Tensor, dtypes t3 = Tensor([1, 2, 3, 4, 5], dtype=dtypes.int32) ``` -------------------------------- ### Install Additional Dependencies Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v5.0/tinycorp/benchmarks/retinanet/implementations/tinybox_green/README.md Installs essential Python packages required for the project, including data handling, machine learning, and utility libraries. ```shell pip install tqdm numpy pycocotools boto3 pandas torch torchvision ``` -------------------------------- ### Tensor Creation from Data Structures Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/docs/quickstart.md Demonstrates how to create tinygrad Tensors from Python lists and NumPy ndarrays, serving as the fundamental data structure for operations. ```python from tinygrad import Tensor t1 = Tensor([1, 2, 3, 4, 5]) na = np.array([1, 2, 3, 4, 5]) t2 = Tensor(na) ``` -------------------------------- ### Install tinygrad from Source Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/docs/index.md Instructions for cloning the tinygrad repository and installing it locally using pip. This method is recommended for users who want the latest features or to contribute to the project. ```bash git clone https://github.com/tinygrad/tinygrad.git cd tinygrad python3 -m pip install -e . ``` -------------------------------- ### Install Tinygrad and MLPerf Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v5.0/tinycorp/benchmarks/retinanet/implementations/tinybox_green/README.md Installs the tinygrad library and mlperf-logging from a specific branch. This involves cloning the repository and performing a local Python package installation. ```shell git clone https://github.com/tinygrad/tinygrad.git python3 -m pip install -e ".[mlperf]" ``` -------------------------------- ### Basic Tensor Operations and Realization Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/docs/quickstart.md Demonstrates performing arithmetic operations on Tensors and applying activation functions. Operations are lazy and executed upon calling `.realize()` or `.numpy()`. ```python from tinygrad import Tensor t4 = Tensor([1, 2, 3, 4, 5]) t5 = (t4 + 1) * 2 t6 = (t5 * t4).relu().log_softmax() print(t6.numpy()) # [-56. -48. -36. -20. 0.] ``` -------------------------------- ### Download Wikipedia Raw Data (Shell) Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/examples/mlperf/training_submission_v5.1/tinycorp/benchmarks/bert/implementations/tinybox_red/README.md Downloads the raw Wikipedia dataset. Sets the base directory for datasets and enables verification of checksums. This script is part of the data preparation steps. ```shell BASEDIR="/raid/datasets/wiki" WIKI_TRAIN=1 VERIFY_CHECKSUM=1 python3 extra/datasets/wikipedia_download.py ``` -------------------------------- ### Clone openpilot Repository (Full) Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tools/README.md Clones the complete openpilot repository, including all history and data, using Git LFS. This method requires Git LFS to be installed and configured. ```bash git clone --recurse-submodules https://github.com/commaai/openpilot.git ``` -------------------------------- ### MNIST Dataset Fetching Source: https://github.com/ajouatom/openpilot/blob/carrot2-v8/tinygrad_repo/docs/quickstart.md Imports the MNIST dataset loader from the `extra.datasets` module within tinygrad. This function is used to retrieve the MNIST training and testing data for model evaluation. ```python from extra.datasets import fetch_mnist ```