### Manage Prime Intellect Environments Source: https://docs.primeintellect.ai/tutorials-environments/getting-started A set of bash commands for interacting with environments on Prime Intellect. This includes listing, getting information, installing, and initializing new environments. ```bash # List available environments prime env list # Get information about an environment prime env info owner/environment-name # Install an environment prime env install owner/environment-name # Create a new environment prime env init my-new-environment ``` -------------------------------- ### Environment Installation Examples with Prime CLI Source: https://docs.primeintellect.ai/tutorials-environments/install Demonstrates how to install environments using the Prime CLI, including installing the latest version and a specific version of an environment. This allows for flexible environment management. ```bash # Install latest version prime env install will/wordle # Install specific version prime env install will/wordle@0.1.3 ``` -------------------------------- ### Authenticate Prime CLI Source: https://docs.primeintellect.ai/tutorials-environments/getting-started Logs into the Prime Intellect CLI using your account credentials. This is a necessary step before interacting with the Prime Intellect Hub. ```bash prime login ``` -------------------------------- ### Start vLLM Server for High Throughput Source: https://docs.primeintellect.ai/tutorials-environments/evaluating Configures and starts a vLLM OpenAI-compatible API server for high-throughput model serving. This example specifies the model, sequence length, concurrency, and quantization (FP8) for optimal performance. ```bash # Example vLLM startup for high-throughput evaluation python -m vllm.entrypoints.openai.api_server \ --model Qwen/Qwen3-4B-Instruct-2507 \ --max-model-len 32768 \ --max-num-seqs 256 \ --tensor-parallel-size 2 \ --quantization fp8 ``` -------------------------------- ### Basic Environment Installation with Prime CLI Source: https://docs.primeintellect.ai/tutorials-environments/install Installs an environment from the Prime Intellect Environment Hub using the `prime env install` command. This is the primary method for adding new environments to your system. It requires the owner and environment name as arguments. ```bash prime env install / ``` -------------------------------- ### Install tmux and Start a tmux Session (Bash) Source: https://docs.primeintellect.ai/tutorials-multi-node-cluster/llama-405B-in-bf16 Installs the tmux terminal multiplexer and starts a new tmux session. This is recommended for long-running downloads to prevent interruption if the SSH connection drops. ```bash sudo apt install tmux -y; tmux ``` -------------------------------- ### Alternative Environment Installation Methods (pip, uv) Source: https://docs.primeintellect.ai/tutorials-environments/install Provides alternative methods for installing environments using direct wheel URLs with `pip` and `uv`, and how to add an environment to an existing project using `uv add`. These methods are useful when the Prime CLI is not preferred or for integration into existing workflows. ```bash # Direct pip installation from wheel URL pip install https://hub.primeintellect.ai/will/wordle/@latest/wordle-0.1.4-py2.py3-none-any.whl # UV pip installation uv pip install https://hub.primeintellect.ai/will/wordle/@latest/wordle-0.1.4-py2.py3-none-any.whl # Add to existing project with UV uv add wordle@https://hub.primeintellect.ai/will/wordle/@latest/wordle-0.1.4-py2.py3-none-any.whl ``` -------------------------------- ### Install Gradio for Chat Server Source: https://docs.primeintellect.ai/tutorials-multi-node-cluster/llama-405B-in-bf16 This command installs the Gradio library, which is required to run the chat server for interactive model testing. ```bash pip install gradio ``` -------------------------------- ### Prime CLI: Basic Environment Evaluation Source: https://docs.primeintellect.ai/tutorials-environments/evaluating Demonstrates the core commands for installing and running a basic evaluation of an environment using the Prime CLI. It includes listing available environments, installing a specific environment, and executing an evaluation against a specified model. ```bash # List available environments prime env list --owner primeintellect # Install an environment prime env install primeintellect/gsm8k@latest # Run a basic evaluation prime env eval gsm8k -m meta-llama/llama-3.1-70b-instruct -n 10 -r 1 ``` -------------------------------- ### Using Installed Environments in Python Source: https://docs.primeintellect.ai/tutorials-environments/install Shows how to load and use an installed environment within a Python script using the `verifiers` library. It demonstrates importing `load_environment` and then using the loaded environment for evaluation. ```python from verifiers import load_environment # Load the environment env = load_environment("will/wordle") # Use the environment for evaluation or training results = env.evaluate(examples=100, rollouts_per_example=1) ``` -------------------------------- ### Check NVIDIA Container Toolkit Installation Source: https://docs.primeintellect.ai/tutorials-contribute/contribute-compute-self-hosted Verifies if the NVIDIA Container Toolkit is installed on the system. This is a prerequisite for running GPU-accelerated workloads. ```bash nvidia-ctk --version ``` -------------------------------- ### Install Docker (Bash) Source: https://docs.primeintellect.ai/tutorials-multi-node-cluster/llama-405B-in-bf16 Installs Docker on the system using a convenience script and adds the current user to the 'docker' group. This is required to ensure a homogenous environment for the Ray cluster nodes, which will be used to deploy the vLLM server. ```bash curl https://get.docker.com | sh sudo usermod -aG docker "$USER" ``` -------------------------------- ### Start Ray Head Node with Docker Source: https://docs.primeintellect.ai/tutorials-multi-node-cluster/llama-405B-in-bf16 This command starts the Ray head node on the master instance using a Docker container. It configures privileged access, host networking, and GPU allocation, mounting the model directory and setting up necessary environment variables. ```bash docker run -d --rm \ --name vllm-server \ --privileged \ --network host \ --ipc host \ --entrypoint /bin/bash \ --gpus all \ -e GLOO_SOCKET_IFNAME=${GLOO_SOCKET_IFNAME} \ ${NETWORK_ENVS} \ -v "${MODEL_PATH}:/Meta-Llama-3.1-405B-Instruct" \ primeintellect/vllm-cuda12-1 -c "ray start --block --head --port 6379" ``` -------------------------------- ### Install Git and Git-LFS (Bash) Source: https://docs.primeintellect.ai/tutorials-multi-node-cluster/llama-405B-in-bf16 Installs Git and Git Large File Storage (LFS) which is required for cloning repositories containing large binary files like model weights. It also initializes Git LFS for use. ```bash sudo apt install git git-lfs -y git lfs install ``` -------------------------------- ### Provision GPU Instance Source: https://docs.primeintellect.ai/api-reference/introduction Quickly set up and deploy a GPU instance with easy-to-follow steps. ```APIDOC ## POST /api-reference/provision-gpu ### Description This endpoint allows you to provision and deploy a new GPU instance. ### Method POST ### Endpoint /api-reference/provision-gpu ### Parameters #### Request Body - **provider** (string) - Required - The GPU provider to use. - **gpu_model** (string) - Required - The desired GPU model. - **storage_gb** (integer) - Required - The amount of storage in GB. - **region** (string) - Optional - The region for the instance. ### Request Example ```json { "example": { "provider": "aws", "gpu_model": "nvidia-a100", "storage_gb": 100, "region": "us-east-1" } } ``` ### Response #### Success Response (200) - **instance_id** (string) - The ID of the provisioned instance. - **status** (string) - The status of the instance (e.g., "pending", "running"). #### Response Example ```json { "example": { "instance_id": "gpu-instance-12345", "status": "pending" } } ``` ``` -------------------------------- ### Install SSH Server at Runtime (Prime Intellect AI) Source: https://docs.primeintellect.ai/tutorials-on-demand-cloud/deploy-custom-docker-image This script installs and configures the OpenSSH server during container startup, intended for use when modifying the Docker image is not feasible. It handles updates, SSH configuration, key setup, and port settings. This runtime installation can significantly increase provisioning time. ```bash # Install SSH server apt-get update apt-get install -y openssh-server # Configure SSH mkdir -p /var/run/sshd sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config sed -i 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' /etc/pam.d/sshd # Set up SSH key if [ ! -z "$PUBLIC_KEY" ]; then mkdir -p /root/.ssh echo "$PUBLIC_KEY" > /root/.ssh/authorized_keys chmod 700 /root/.ssh chmod 600 /root/.ssh/authorized_keys fi # Set SSH port if [ ! -z "$SSH_PORT" ]; then sed -i "s/#Port 22/Port $SSH_PORT/" /etc/ssh/sshd_config fi # Generate host keys if missing (required for some base images) if [ -z "$(ls /etc/ssh/ssh_host_* 2>/dev/null || true)" ]; then ssh-keygen -A fi # Start SSH service /usr/sbin/sshd -D ``` -------------------------------- ### Start Ray Worker Node with Docker Source: https://docs.primeintellect.ai/tutorials-multi-node-cluster/llama-405B-in-bf16 This command initiates a Ray worker node within a Docker container, connecting it to the existing Ray head node. Similar to the head node setup, it ensures proper network and GPU configuration, along with model volume mounting. ```bash docker run -d --rm \ --name vllm-server \ --privileged \ --network host \ --ipc host \ --entrypoint /bin/bash \ --gpus all \ -e GLOO_SOCKET_IFNAME=${GLOO_SOCKET_IFNAME} \ ${NETWORK_ENVS} \ -v "${MODEL_PATH}:/Meta-Llama-3.1-405B-Instruct" \ primeintellect/vllm-cuda12-1 -c "ray start --block --address=${HEAD_NODE_ADDRESS}:6379" ``` -------------------------------- ### List and Get Sandbox Status and Details Source: https://docs.primeintellect.ai/sandboxes/cli Provides commands to list sandboxes, showing their status in a table format, or retrieve detailed JSON information for a specific sandbox. It also includes a command to run a quick verification script within a sandbox. ```bash # Overview at a glance prime sandbox list --status RUNNING --output table # Rich details for one sandbox prime sandbox get sbx_123 --output json # Quick command to verify the runtime prime sandbox run sbx_123 --working-dir /workspace "python -c 'print(42)'" # Capture logs for later debugging prime sandbox logs sbx_123 > logs.txt ``` -------------------------------- ### Launch a Single Sandbox Instance with Async Python Source: https://docs.primeintellect.ai/sandboxes/sdk This snippet demonstrates how to create a single sandbox environment using the AsyncSandboxClient. It includes steps for creating the sandbox, waiting for it to be ready, executing a command, and then deleting the sandbox. Dependencies include the asyncio library and classes from prime_cli.api.sandbox. ```python import asyncio from prime_cli.api.sandbox import AsyncSandboxClient, CreateSandboxRequest async def launch_demo() -> None: async with AsyncSandboxClient() as sandboxes: request = CreateSandboxRequest( name="sdk-demo", docker_image="python:3.11-slim", labels=["experiment", "ml-pipeline", "team-research"], timeout_minutes=120, ) sandbox = await sandboxes.create(request) await sandboxes.wait_for_creation(sandbox.id) result = await sandboxes.execute_command(sandbox.id, "python -c 'print(42)'") print(result.stdout.strip()) await sandboxes.delete(sandbox.id) asyncio.run(launch_demo()) ``` -------------------------------- ### Organize Sandboxes Using Labels Source: https://docs.primeintellect.ai/sandboxes/cli Demonstrates how to create sandboxes with multiple labels, list sandboxes filtered by specific labels, and delete sandboxes based on their labels. Labels facilitate grouping, ownership tracking, and bulk management. ```bash # Create sandboxes with labels prime sandbox create python:3.11-slim \ --label experiment \ --label ml-pipeline \ --label team-research # List sandboxes with specific labels (must have ALL labels) prime sandbox list --label experiment --label ml-pipeline # Delete all sandboxes with specific labels prime sandbox delete --label experiment --yes ``` -------------------------------- ### Provide Instructions with System Messages in Python Source: https://docs.primeintellect.ai/api-reference/inference-chat-completions Utilizes system messages to guide the AI's behavior and persona. By including a 'system' role message, you can set context or instructions for the AI before the user's prompt. This example shows how to set the AI as a helpful math tutor. ```python response = client.chat.completions.create( model="meta-llama/llama-3.1-70b-instruct", messages=[ {"role": "system", "content": "You are a helpful math tutor."}, {"role": "user", "content": "Explain calculus"} ] ) ``` -------------------------------- ### Prime CLI: Eval Command Syntax and Parameters Source: https://docs.primeintellect.ai/tutorials-environments/evaluating Illustrates the general syntax for the `prime env eval` command and details its core parameters, including environment name, model selection, number of examples, and rollouts per example. It also lists advanced options for concurrency, token limits, temperature, sampling arguments, and environment-specific arguments. ```bash prime env eval ENVIRONMENT [OPTIONS] # Core Parameters: # environment: Name of the installed verifier environment (e.g., 'wordle', 'gsm8k', 'math_python') # --model, -m: Model to use for evaluation. Defaults to `meta-llama/llama-3.1-70b-instruct` # --num-examples, -n: Number of examples to evaluate. Default: 5 # --rollouts-per-example, -r: Number of rollouts per example for statistical significance. Default: 3 # Advanced Options: # --max-concurrent, -c: Maximum concurrent requests to the inference API. Default: 32 # --max-tokens, -t: Maximum tokens to generate per request # --temperature, -T: Sampling temperature (0.0-2.0). Higher values = more randomness # --sampling-args, -S: JSON string with additional sampling arguments # --env-args, -a: Environment-specific arguments as JSON # Output and Storage Options: # --verbose, -v: Enable verbose output for detailed logging # --save-results, -s: Save evaluation results to disk # --save-every, -f: Save dataset every N rollouts. Default: -1 (no checkpointing) # --save-to-hf-hub, -H: Save results to Hugging Face Hub # --hf-hub-dataset-name, -D: Specify Hugging Face Hub dataset name ``` -------------------------------- ### Install CLI with pip Source: https://docs.primeintellect.ai/cli-reference/introduction Installs the Prime Intellect CLI using pip, the standard Python package installer. This is an alternative installation method if uv is not preferred. ```bash pip install prime ``` -------------------------------- ### Install CLI with uv Source: https://docs.primeintellect.ai/cli-reference/introduction Installs the Prime Intellect CLI using uv, a fast Python package installer and virtual environment manager. This method ensures the CLI is installed in a managed environment. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh uv tool install prime ``` -------------------------------- ### Execute Commands and Retrieve Logs from a Sandbox with Async Python Source: https://docs.primeintellect.ai/sandboxes/sdk This snippet demonstrates executing a command within a specified sandbox and retrieving its logs. It uses AsyncSandboxClient to run a Python command to get the version and then fetches the sandbox logs. The command results include stdout, stderr, and exit code, allowing for pipeline short-circuiting. ```python async def smoke_test(sandbox_id: str) -> None: async with AsyncSandboxClient() as sandboxes: results = await sandboxes.execute_command( sandbox_id, "python -c 'import platform; print(platform.python_version())'", ) print("stdout:", results.stdout.strip()) logs = await sandboxes.get_logs(sandbox_id) print("logs snippet:", logs[:120]) ``` -------------------------------- ### Verify Environment Variables for Ray Cluster (Bash) Source: https://docs.primeintellect.ai/tutorials-multi-node-cluster/llama-405B-in-bf16 Prints the values of essential environment variables required for setting up the Ray cluster. These variables define network configurations and the location of the downloaded model. ```bash echo $HEAD_NODE_ADDRESS # e.g. 10.0.0.123 echo $GLOO_SOCKET_IFNAME # e.g. enp8s0 echo $MODEL_PATH # e.g. /data/Meta-Llama-3.1-405B-Instruct echo $NETWORK_ENVS # Infiniband env var if node has infiniband interconnect, otherwise not set ``` -------------------------------- ### Use Cost-Effective Models for Large Evaluations Source: https://docs.primeintellect.ai/tutorials-environments/evaluating Demonstrates how to switch to more economical models like Llama-3.1-8B-Instruct for large-scale evaluations when encountering 'Insufficient balance' errors or aiming to reduce costs. ```bash # Use cost-effective models for large evaluations prime env eval gsm8k -m meta-llama/llama-3.1-8b-instruct -n 1000 ``` -------------------------------- ### Example GPU Availability Response Source: https://docs.primeintellect.ai/api-reference/check-gpu-availability This JSON object represents a typical response from the PrimeIntellect AI availability API when querying for GPU information. It details specific GPU configurations, including provider, data center, pricing (on-demand, community), available disk space, vCPU, memory, stock status, and compatible operating system images. ```json { "H100_80GB": [ { "cloudId": "NVIDIA H100 PCIe", "gpuType": "H100_80GB", "socket": "PCIe", "provider": "runpod", "dataCenter": "US-KS-2", "country": "US", "gpuCount": 1, "gpuMemory": 80, "disk": { "minCount": 80, "defaultCount": 80, "maxCount": 1000, "pricePerUnit": 0.00014, "step": 1, "defaultIncludedInPrice": false }, "vcpu": { "defaultCount": 16 }, "memory": { "defaultCount": 251 }, "stockStatus": "Low", "security": "secure_cloud", "prices": { "onDemand": 2.69, "communityPrice": null, "isVariable": null, "currency": "USD" }, "images": [ "ubuntu_22_cuda_12", "cuda_12_1_pytorch_2_2", "cuda_11_8_pytorch_2_1", "stable_diffusion", "flux", "axolotl", "bittensor", "vllm_llama_8b", "vllm_llama_70b", "vllm_llama_405b" ], "isSpot": null, "prepaidTime": null } ] } ``` -------------------------------- ### API Pod Configuration Error Response Examples (YAML) Source: https://docs.primeintellect.ai/api-reference/pods/get-pod Example YAML payloads for error responses from the API Pod Configuration endpoint. Includes examples for authorization failures and invalid request data, detailing the structure of error messages. ```yaml errors: - param: details: ``` -------------------------------- ### Create Pod with Custom Template (Bash) Source: https://docs.primeintellect.ai/api-reference/provision-gpu This Bash script demonstrates how to create a new pod (instance) using a custom template. It requires your API key for authentication and specifies the custom template ID and other pod configurations. Ensure the `gpuType` and `dataCenterId` are compatible with your chosen custom template. ```bash curl --request POST \ --url https://api.primeintellect.ai/api/v1/pods/ \ --header 'Authorization: Bearer your_api_key' \ --header 'Content-Type: application/json' \ --data '{ "pod": { "name": "My first pod", "cloudId": "n3-H100x1", "gpuType": "H100_80GB", "socket": "PCIe", "gpuCount": 1, "image": "custom_template", "customTemplateId": "cm2szl4a20001tl3pyq7ua6o7" "dataCenterId": "CANADA-1", "country": "CA", "security": "secure_cloud" }, "provider": { "type": "hyperstack" } }' ``` -------------------------------- ### Initialize New Environment with Prime CLI Source: https://docs.primeintellect.ai/tutorials-environments/create Creates a new environment template using the Prime CLI. This command generates a basic structure including README, pyproject.toml, and a Python entrypoint function (`load_environment`), simplifying the initial setup for new environments. ```bash prime env init ``` -------------------------------- ### Check tmux Installation Source: https://docs.primeintellect.ai/tutorials-contribute/contribute-compute-self-hosted Verifies if tmux, a terminal multiplexer, is installed. tmux is recommended for cloud-based compute to maintain persistent sessions. ```bash tmux -V ``` -------------------------------- ### Create a New Instance Interactively Source: https://docs.primeintellect.ai/cli-reference/provision-gpu Creates a new instance interactively by prompting the user for configuration details. Options include specifying GPU type, count, name, disk size, vCPUs, memory, image, team ID, and environment variables. ```bash prime pods create ```