Principle:Bigscience workshop Petals Environment Setup
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Setup |
| Last Updated | 2026-02-09 14:00 GMT |
Overview
The process of installing the Petals package with its dependencies and configuring authentication for accessing gated models on HuggingFace.
Description
Environment Setup prepares the Python environment for using Petals, whether as a client for distributed inference/training or as a server contributing GPU resources. The installation includes:
Core dependencies:
- hivemind: Kademlia DHT and P2P networking
- transformers: HuggingFace model framework
- torch: PyTorch deep learning framework
- accelerate: Efficient model loading utilities
- safetensors: Fast weight serialization
- dijkstar: Shortest-path routing for server selection
Optional dependencies:
- datasets: HuggingFace datasets for training workflows
- wandb: Experiment tracking for training
- bitsandbytes: Quantization support (INT8/NF4)
- speedtest-cli: Network bandwidth estimation (server only)
Authentication: For gated models (e.g., Llama 2), HuggingFace authentication is required via huggingface-cli login or by passing a token to from_pretrained().
Usage
This is the mandatory first step for any Petals workflow. For client usage, pip install petals is sufficient. For server contribution, CUDA drivers and GPU access are additionally required.
Practical Guide
Client setup:
# Install Petals
# pip install petals
# For training workflows, also install:
# pip install petals datasets wandb
# For gated models (e.g., Llama):
# huggingface-cli login
# Enter your HuggingFace access token
Server setup:
# Option 1: Direct installation
# pip install petals
# Option 2: Docker (recommended for servers)
# docker run -p 31330:31330 --ipc host --gpus all \
# --volume petals-cache:/cache --rm \
# learningathome/petals:main \
# python -m petals.cli.run_server MODEL_NAME