Skip to content

Local Installation

Inference is built to be run at the edge. It loads and executes model weights and does computation locally. It can run fully offline (once model weights are downloaded) but it's often useful to maintain a network connection for interfacing with outside systems (like PLCs on the local network, or remote systems for storing data and sending notifications).

Run via Docker

The preferred way to use Inference is via Docker (see Why Docker).

Install Docker (and NVIDIA Container Toolkit for GPU acceleration if you have a CUDA-enabled GPU). Then run:

pip install inference-cli
inference server start

The inference server start command attempts to automatically choose and configure the optimal container to optimize performance on your machine. See Using Your New Server for next steps.

Tip

Special installation notes and performance tips by device are also available. Browse the navigation on the left for detailed install guides.

Dev Mode

The --dev parameter to inference server start starts in development mode. This spins up a companion Jupyter notebook server with a quickstart guide on localhost:9002. Dive in there for a whirlwind tour of your new Inference Server's functionality!

inference server start --dev

Using Your New Server

Once you have a server running, you can access it via its API or using the Python SDK. You can also use it to build Workflows using the Roboflow Platform UI.

Install the SDK

pip install inference-sdk

Run a workflow

This code runs an example model comparison Workflow on an Inference Server running on your local machine:

from inference_sdk import InferenceHTTPClient

client = InferenceHTTPClient(
    api_url="http://localhost:9001", # use local inference server
    # api_key="<YOUR API KEY>" # optional to access your private data and models
)

result = client.run_workflow(
    workspace_name="roboflow-docs",
    workflow_id="model-comparison",
    images={
        "image": "https://media.roboflow.com/workflows/examples/bleachers.jpg"
    },
    parameters={
        "model1": "yolov8n-640",
        "model2": "yolov11n-640"
    }
)

print(result)

From a JavaScript app, hit your new server with an HTTP request.

const response = await fetch('http://localhost:9001/infer/workflows/roboflow-docs/model-comparison', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        // api_key: "<YOUR API KEY>" // optional to access your private data and models
        inputs: {
            "image": {
                "type": "url",
                "value": "https://media.roboflow.com/workflows/examples/bleachers.jpg"
            },
            "model1": "yolov8n-640",
            "model2": "yolov11n-640"
        }
    })
});

const result = await response.json();
console.log(result);

Warning

Be careful not to expose your API Key to external users (in other words: don't use this snippet in a public-facing front-end app).

Using the server's API you can access it from any other client application. From the command line using cURL:

curl -X POST "http://localhost:9001/infer/workflows/roboflow-docs/model-comparison" \
-H "Content-Type: application/json" \
-d '{
    "api_key": "<YOUR API KEY -- REMOVE THIS LINE IF NOT FILLING>",
    "inputs": {
        "image": {
            "type": "url",
            "value": "https://media.roboflow.com/workflows/examples/bleachers.jpg"
        },
        "model1": "yolov8n-640",
        "model2": "yolov11n-640"
    }
}'

Tip

ChatGPT is really good at converting snippets like this into other languages. If you need help, try pasting it in and asking it to translate it to your language of choice.