### Install Model Server from Source Source: https://developer.furiosa.ai/docs/latest/en/software/python-sdk Install the model server extra package from the source code. This involves navigating to the appropriate subdirectory within the cloned furiosa-sdk repository and installing the 'furiosa-server' package. ```bash cd furiosa-sdk/python pip install furiosa-server ``` -------------------------------- ### Install FuriosaAI Server from Source Code Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/python-sdk.rst Installs the model server functionality from the FuriosaAI SDK source code. This involves navigating to the Python subdirectory and installing the 'furiosa-server' package. ```sh cd furiosa-sdk/python pip install furiosa-server ``` -------------------------------- ### Install C SDK using APT - Shell Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/c-sdk.rst Installs the FuriosaAI C SDK package 'furiosa-libnux-dev' using the APT package manager. This command first updates the package list and then installs the specified package. Ensure the FuriosaAI APT repository is set up prior to execution. ```sh apt-get update && apt-get install -y furiosa-libnux-dev ``` -------------------------------- ### Install FuriosaAI Python SDK from Source Code Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/python-sdk.rst Installs the FuriosaAI Python SDK by cloning the repository and installing packages in a specific order. This method is useful for development or when the latest unreleased versions are needed. ```sh git clone https://github.com/furiosa-ai/furiosa-sdk cd furiosa-sdk/python pip install furiosa-runtime pip install furiosa-tools pip install furiosa-sdk ``` -------------------------------- ### Install Model Server Package Source: https://developer.furiosa.ai/docs/latest/en/software/python-sdk Install the model server package, which provides functionality to accelerate DNN models using the NPU and serve them via GRPC or Restful API. ```bash pip install 'furiosa-sdk[server]' ``` -------------------------------- ### Install Furiosa Python SDK with Extra Packages Source: https://developer.furiosa.ai/docs/latest/en/software/python-sdk Install the Furiosa Python SDK with specific extra packages for additional functionality. For example, to install packages for model serving ('server') and model-SDK compatibility checking ('litmus'). ```bash pip install 'furiosa-sdk[server, litmus]' ``` -------------------------------- ### Install furiosa-bench using apt Source: https://developer.furiosa.ai/docs/latest/en/_sources/releases/0.10.0.rst Installs the `furiosa-bench` tool using the apt package manager. This is a straightforward command for setting up benchmarking utilities. ```bash $ apt install furiosa-bench ``` -------------------------------- ### Install C SDK using Downloaded DEB Package - Shell Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/c-sdk.rst Installs the FuriosaAI C SDK from a downloaded .deb package. Replace 'x.y.z' with the actual version number. This method requires manual download from the FuriosaAI download center. Ensure all prerequisites are met before installation. ```sh apt-get install -y ./furiosa-libnux-dev-x.y.z-?.deb ``` -------------------------------- ### Update Pip, Setuptools, and Wheel Source: https://developer.furiosa.ai/docs/latest/en/software/python-sdk Before installing the furiosa-sdk, it is recommended to update Python's package installer (pip) and related tools to their latest versions to avoid potential installation errors. ```bash pip install --upgrade pip setuptools wheel ``` -------------------------------- ### Upgrade Pip and Install SDK Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/python-sdk.rst Commands to upgrade the Python package installer (pip) and install the FuriosaAI SDK. It's crucial to upgrade pip first to avoid potential installation errors. ```sh pip install --upgrade pip setuptools wheel ``` -------------------------------- ### Install FuriosaAI Python SDK with Extra Packages (PIP) Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/python-sdk.rst Installs the FuriosaAI Python SDK with specified extra packages for extended functionality. For example, installing 'server' for model serving and 'litmus' for model compatibility checks. ```sh pip install 'furiosa-sdk[server, litmus]' ``` -------------------------------- ### Install furiosa-compiler Source: https://developer.furiosa.ai/docs/latest/en/software/compiler Installs the `furiosa-compiler` command-line tool using the APT package manager. This is the primary method for obtaining the compiler. ```bash $ apt install furiosa-compiler ``` -------------------------------- ### Compile C Application with C SDK - Shell Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/c-sdk.rst Compiles a C application ('example.c') using the GCC compiler and links it with the FuriosaAI C SDK library ('-lnux'). The C header files and static libraries are expected to be in the default system paths. This command assumes the C SDK has been correctly installed. ```sh gcc example.c -lnux ``` -------------------------------- ### Install Specific Package Version (Shell) Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/installation.rst This command installs a specific version of a package. First, you list available versions using 'apt list -a ', then you specify the desired version in the 'apt-get install' command. The '-y' flag automatically confirms the installation. ```sh sudo apt list -a furiosa-libnux ``` ```sh sudo apt-get install -y furiosa-libnux=0.9.1-? ``` -------------------------------- ### Install FuriosaAI Server Package (PIP) Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/python-sdk.rst Installs the FuriosaAI Server package, enabling the acceleration of DNN models with the NPU and serving them via GRPC or Restful API. This is installed as an extra package for the SDK. ```sh pip install 'furiosa-sdk[server]' ``` -------------------------------- ### Real Example: Model Input Type Optimization (Python) Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/performance.rst Demonstrates a practical application of the ModelEditor API, specifically using the convert_input_type method to optimize model input types. This example showcases how to integrate the optimization into a workflow. ```python import onnx from furiosa_quantizer.onnx.importer.model_editor import ModelEditor, TensorType def optimize_model_input_type(model_path: str, output_path: str): model = onnx.load_model(model_path) # Assuming optimize_model is defined elsewhere and returns an optimized model # model = optimize_model(model) editor = ModelEditor(model) input_tensor_names = editor.get_pure_input_names() if input_tensor_names: # Convert the first input tensor to UINT8 editor.convert_input_type(input_tensor_names[0], TensorType.UINT8) print(f"Converted input tensor '{input_tensor_names[0]}' to UINT8.") else: print("No input tensors found to convert.") # Save the modified model editor.save(output_path) print(f"Optimized model saved to {output_path}") # Example usage: # optimize_model_input_type("path/to/your/model.onnx", "path/to/optimized_model.onnx") ``` -------------------------------- ### Install Quantizer Package for Model Quantization Source: https://developer.furiosa.ai/docs/latest/en/software/python-sdk Install the quantizer package, which offers a set of APIs for converting models into a quantized format. This is essential for optimizing models for the Furiosa NPU. ```bash pip install 'furiosa-sdk[quantizer]' ``` -------------------------------- ### Install FuriosaAI SDK with Legacy Runtime/API (PIP) Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/python-sdk.rst Installs the FuriosaAI SDK with the legacy runtime and API, which was adopted before version 0.10.0. This is useful for compatibility with older projects or specific requirements. ```sh pip install 'furiosa-sdk[legacy]' ``` -------------------------------- ### Install furiosa-toolkit using APT Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/cli.rst Installs the `furiosa-toolkit` package using the APT package manager. This is a prerequisite for using other `furiosactl` commands. Ensure the kernel driver is installed beforehand. ```sh sudo apt-get install -y furiosa-toolkit ``` -------------------------------- ### Install FuriosaAI Litmus Package (PIP) Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/python-sdk.rst Installs the FuriosaAI Litmus tool, which verifies model compatibility with the Furiosa SDK. It simulates processes like model quantization and compilation to ensure smooth execution. ```sh pip install 'furiosa-sdk[litmus]' ``` -------------------------------- ### Install Furiosa SDK with Legacy Runtime/API Source: https://developer.furiosa.ai/docs/latest/en/software/python-sdk Install the Furiosa Python SDK with the legacy runtime and API. This option is available for compatibility with older versions or specific project requirements. ```bash pip install 'furiosa-sdk[legacy]' ``` -------------------------------- ### Install APT Packages for HTTPS Access Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/installation.rst Installs essential packages required to access HTTPS-based APT repositories. These include tools for updating package lists, installing packages, managing GPG keys, and transferring files. ```sh sudo apt update sudo apt install -y ca-certificates apt-transport-https gnupg wget ``` -------------------------------- ### Model Summary Example Source: https://developer.furiosa.ai/docs/latest/en/_sources/api/python/furiosa.runtime.rst This example demonstrates how to print a human-readable summary of a model using the `print_summary` method. The output typically includes details about the input and output tensors, such as their shapes, data types, formats, sizes, and lengths. ```python print(model.summary()) # Expected output format: # Inputs: # {0: TensorDesc(shape=(1, 1, 28, 28), dtype=FLOAT32, format=NCHW, size=3136, len=784)} # Outputs: # {0: TensorDesc(shape=(1, 10), dtype=FLOAT32, format=??, size=40, len=10)} ``` -------------------------------- ### Install FuriosaAI Packages using APT Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/installation.rst Installs the NPU kernel driver and runtime library using the APT package manager. This command updates the package list and then installs the specified FuriosaAI packages. ```sh sudo apt-get update && sudo apt-get install -y furiosa-driver-warboy furiosa-libnux ``` -------------------------------- ### Install furiosa-toolkit using apt Source: https://developer.furiosa.ai/docs/latest/en/_sources/releases/0.10.0.rst Installs the `furiosa-toolkit` package using the apt package manager. This command ensures that the toolkit and its associated tools are available on the system. ```bash apt install furiosa-toolkit ``` -------------------------------- ### Install Furiosa SDK with Serving Support Source: https://developer.furiosa.ai/docs/latest/en/_sources/releases/0.6.0.rst Command to install the Furiosa SDK with support for the Furiosa Serving library, which is based on FastAPI for advanced model serving. This installation includes all components needed for serving functionalities. ```sh $ pip install 'furiosa-sdk[serving]' ``` -------------------------------- ### Install FuriosaAI Packages from .deb Files Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/installation.rst Installs FuriosaAI packages by directly referencing downloaded .deb files. This method requires specifying the exact filenames, including version numbers, for the driver, firmware, runtime, and onnxruntime. ```sh sudo apt-get install -y ./furiosa-driver-warboy-x.y.z-?.deb sudo apt-get install -y ./furiosa-libhal-warboy-x.y.z-?.deb sudo apt-get install -y ./libonnxruntime-x.y.z-?.deb sudo apt-get install -y ./furiosa-libnux-x.y.z-?.deb ``` -------------------------------- ### Real Example: Model Output Type Optimization (Python) Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/performance.rst Provides a concrete implementation for using the convert_output_type method of ModelEditor. This example demonstrates how to modify model outputs to INT8 or UINT8 to potentially improve inference performance. ```python import onnx from furiosa_quantizer.onnx.importer.model_editor import ModelEditor, TensorType def optimize_model_output_type(model_path: str, output_path: str): model = onnx.load_model(model_path) # Assuming optimize_model is defined elsewhere and returns an optimized model # model = optimize_model(model) editor = ModelEditor(model) output_tensor_names = editor.get_pure_output_names() if output_tensor_names: # Convert the first output tensor to UINT8 editor.convert_output_type(output_tensor_names[0], TensorType.UINT8) print(f"Converted output tensor '{output_tensor_names[0]}' to UINT8.") else: print("No output tensors found to convert.") # Save the modified model editor.save(output_path) print(f"Optimized model saved to {output_path}") # Example usage: # optimize_model_output_type("path/to/your/model.onnx", "path/to/optimized_model.onnx") ``` -------------------------------- ### Install Furiosa Model Server from Source Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/serving.rst Installs the Furiosa Model Server by cloning the source code repository and running the pip install command. This method is useful for developers who need to modify or contribute to the server's codebase. ```sh $ git clone https://github.com/furiosa-ai/furiosa-sdk.git $ cd furiosa-sdk/python/furiosa-server $ pip install . ``` -------------------------------- ### Install Specific furiosa-libnux Version with apt-get Source: https://developer.furiosa.ai/docs/latest/en/software/installation This command installs a specific version of `furiosa-libnux`. The `-y` flag automatically confirms the installation. Users must replace `0.9.1-?` with the exact version string obtained from `apt list`. ```bash sudo apt-get install -y furiosa-libnux=0.9.1-? ``` -------------------------------- ### Async/Await Syntax for Serving Applications (Python) Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/performance.rst Shows how to implement a serving application using the async/await API provided by `NPUModel` from `furiosa-server`. This approach simplifies handling multiple concurrent requests asynchronously, improving serving performance. ```python from furiosa.server.model import NPUModel # Assuming 'model_path' is the path to your model model = NPUModel(model_path) async def handle_request(request): # Process request and prepare input data input_data = ... # Run inference asynchronously outputs = await model.run(input_data) # Process outputs and return response return ... # Example of how to use it within an async web framework (e.g., FastAPI) # @app.post('/predict') # async def predict(request: Request): # data = await request.json() # return await handle_request(data) ... ``` -------------------------------- ### Install Python Packages on Linux Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/python-sdk.rst Commands to install Python 3, pip, and ensure 'python' command points to Python 3 on a Linux system. This is an alternative to using Conda for environment setup. ```bash sudo apt install -y python3 python3-pip python-is-python3 ``` -------------------------------- ### Install Miniconda Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/python-sdk.rst Steps to download and install the Miniconda installer for Python environment management. This is the recommended method for setting up isolated Python environments. ```bash wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh sh ./Miniconda3-latest-Linux-x86_64.sh source ~/.bashrc conda --version ``` -------------------------------- ### Check Python Version Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/python-sdk.rst Command to check the currently installed Python version on your system. This is a prerequisite for installing the FuriosaAI Python SDK. ```bash python --version Python 3.8.10 ``` -------------------------------- ### Install Furiosa SDK Server from Source Source: https://developer.furiosa.ai/docs/latest/en/software/serving Installs the Furiosa SDK server by cloning the source code and building it locally. This method is useful for development or when specific build configurations are needed. ```bash git clone https://github.com/furiosa-ai/furiosa-sdk.git cd furiosa-sdk/python/furiosa-server pip install . ``` -------------------------------- ### Full ResNet50 Optimization Example (Python) Source: https://developer.furiosa.ai/docs/latest/en/software/performance Demonstrates a complete workflow for optimizing a ResNet50 model. It includes exporting a PyTorch model to ONNX, optimizing the ONNX model, calibrating it, and then using `ModelEditor` to convert the input type. ```python #!/usr/bin/env python import time import numpy as np import onnx import torch import torchvision from torchvision import transforms import tqdm from furiosa.optimizer import optimize_model from furiosa.quantizer import get_pure_input_names, quantize, Calibrator, CalibrationMethod, ModelEditor, TensorType from furiosa.runtime import session from furiosa.runtime.profiler import profile torch_model = torchvision.models.resnet50(weights='DEFAULT') torch_model = torch_model.eval() dummy_input = (torch.randn(1, 3, 224, 224),) torch.onnx.export( torch_model, # PyTorch model to export dummy_input, # model input "resnet50.onnx", # where to save the exported ONNX model opset_version=13, # the ONNX OpSet version to export the model to do_constant_folding=True, # whether to execute constant folding for optimization input_names=["input"], # the ONNX model's input names output_names=["output"], # the ONNX model's output names ) onnx_model = onnx.load_model("resnet50.onnx") onnx_model = optimize_model(onnx_model) calibrator = Calibrator(onnx_model, CalibrationMethod.MIN_MAX_ASYM) calibrator.collect_data([[torch.randn(1, 3, 224, 224).numpy()]]) ranges = calibrator.compute_range() editor = ModelEditor(onnx_model) input_tensor_name = get_pure_input_names(onnx_model)[0] # Note: The actual conversion call editor.convert_input_type(input_tensor_name, TensorType.UINT8) is missing in the provided snippet but would follow here. ``` -------------------------------- ### List Available furiosa-libnux Versions with apt Source: https://developer.furiosa.ai/docs/latest/en/software/installation This command lists all available versions of the `furiosa-libnux` package. It helps users identify the exact version string required for installation. No specific inputs are needed beyond the package name. ```bash sudo apt list -a furiosa-libnux ``` -------------------------------- ### Install FuriosaAI Models Package (PIP) Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/python-sdk.rst Installs the FuriosaAI Models package, which provides optimized DNN model architectures and pre-trained model images executable on the NPU. This is installed as an extra package for the SDK. ```sh pip install 'furiosa-sdk[models]' ``` -------------------------------- ### Configure Device Plugin via Command Line Arguments Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/kubernetes_support.rst Demonstrates how to configure the k8s-device-plugin using command-line arguments. This example sets the interval for device searching to 10 seconds. These arguments can be specified within a Pod or DaemonSet definition. ```sh $ k8s-device-plugin --interval 10 ``` ```yaml apiVersion: v1 kind: Pod metadata: name: furiosa-device-plugin namespace: kube-system spec: containers: - name: device-plugin image: ghcr.io/furiosa-ai/k8s-device-plugin:latest command: ["/usr/bin/k8s-device-plugin"] args: ["--interval", "10"] ``` -------------------------------- ### Install FuriosaAI Python SDK with PIP Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/python-sdk.rst Installs the core FuriosaAI Python SDK package using pip. This package includes the compiler CLI and inference API. Additional functionalities can be installed as Python extra packages. ```sh pip install furiosa-sdk ``` -------------------------------- ### Install and Run Furiosa Server (Shell) Source: https://developer.furiosa.ai/docs/latest/en/_sources/releases/0.5.0.rst Provides the command to install Furiosa Server, a serving framework supporting GRPC and REST API, and instructions on how to run it to serve models on the NPU. This feature simplifies model deployment and inference serving. ```sh pip install furiosa-sdk[server] # Command to run the server (specific command not provided in text, but implied) ``` -------------------------------- ### Install FuriosaAI Quantizer Package (PIP) Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/python-sdk.rst Installs the FuriosaAI Quantizer package, which offers APIs for converting models into a quantized format. This package is essential for optimizing models for the NPU. ```sh pip install 'furiosa-sdk[quantizer]' ``` -------------------------------- ### Install FuriosaAI Models Package Source: https://developer.furiosa.ai/docs/latest/en/software/python-sdk Install the FuriosaAI Models Python module, which provides optimized DNN model architectures and pre-trained model images that can be executed directly on the NPU. ```bash pip install 'furiosa-sdk[models]' ``` -------------------------------- ### Install Litmus Package for Model Compatibility Source: https://developer.furiosa.ai/docs/latest/en/software/python-sdk Install the Litmus package, a tool designed to verify the compatibility of a specified model with the Furiosa SDK. It simulates processes like model quantization and compilation. ```bash pip install 'furiosa-sdk[litmus]' ``` -------------------------------- ### Run Latency Benchmark with furiosa-bench Source: https://developer.furiosa.ai/docs/latest/en/_sources/releases/0.10.0.rst This command shows an example of using `furiosa-bench` for a latency-oriented benchmark. It includes the model path, workload type, number of iterations, and the specific devices to be used for measurement. ```bash $ furiosa-bench ./model.onnx --workload latency -n 10000 --devices "warboy(2)*1" ``` -------------------------------- ### Configure APT Authentication for FuriosaAI Source: https://developer.furiosa.ai/docs/latest/en/_sources/software/installation.rst Sets up authentication for the FuriosaAI APT server using an API key. It creates a configuration file with machine, login (key ID), and password (API key) details and sets restrictive read permissions. ```sh sudo tee -a /etc/apt/auth.conf.d/furiosa.conf > /dev/null < npu-pod.yaml < int: ```