Skip to main content

Installation

This guide covers the installation of BentoML and its dependencies on various platforms.

System Requirements

  • Python: 3.8, 3.9, 3.10, or 3.11
  • Operating System: Linux, macOS, or Windows
  • Memory: Minimum 2GB RAM (4GB+ recommended)
  • Docker: Optional, but recommended for containerized deployments

Basic Installation

Using pip

The simplest way to install BentoML is using pip:

pip install bentoml

Verify Installation

Check that BentoML is installed correctly:

bentoml --version

You should see output similar to:

bentoml, version 1.2.0

Framework-Specific Installation

BentoML provides framework-specific packages that include necessary dependencies.

PyTorch

pip install bentoml[torch]

Or install PyTorch separately with specific CUDA version:

# Install PyTorch with CUDA 11.8
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118
pip install bentoml

TensorFlow

pip install bentoml[tensorflow]

For GPU support:

pip install tensorflow-gpu
pip install bentoml

Scikit-learn

pip install bentoml[sklearn]

XGBoost

pip install bentoml[xgboost]

LightGBM

pip install bentoml[lightgbm]

Multiple Frameworks

Install support for multiple frameworks:

pip install bentoml[sklearn,xgboost,lightgbm]

Development Installation

For development work or contributing to BentoML:

# Clone the repository
git clone https://github.com/bentoml/BentoML.git
cd BentoML

# Install in editable mode with dev dependencies
pip install -e ".[dev]"

Docker Installation

Official Docker Image

BentoML provides official Docker images:

docker pull bentoml/bentoml:latest

Run BentoML in Docker

docker run -it --rm \
-v $(pwd):/workspace \
-w /workspace \
bentoml/bentoml:latest \
bentoml --help

Virtual Environment Setup

It's recommended to use a virtual environment:

Using venv

# Create virtual environment
python -m venv bentoml-env

# Activate (Linux/macOS)
source bentoml-env/bin/activate

# Activate (Windows)
bentoml-env\Scripts\activate

# Install BentoML
pip install bentoml

Using conda

# Create conda environment
conda create -n bentoml python=3.10

# Activate environment
conda activate bentoml

# Install BentoML
pip install bentoml

Platform-Specific Instructions

Linux

Ubuntu/Debian:

# Update package list
sudo apt-get update

# Install Python and pip
sudo apt-get install python3 python3-pip

# Install BentoML
pip3 install bentoml

CentOS/RHEL:

# Install Python and pip
sudo yum install python3 python3-pip

# Install BentoML
pip3 install bentoml

macOS

# Install Homebrew if not installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Python
brew install python@3.10

# Install BentoML
pip3 install bentoml

Windows

  1. Download and install Python from python.org
  2. Open Command Prompt or PowerShell
  3. Install BentoML:
pip install bentoml

Additional Dependencies

For REST API Development

pip install bentoml[grpc]  # gRPC support
pip install bentoml[io] # Advanced I/O types

For Monitoring

pip install bentoml[tracing]  # OpenTelemetry support
pip install bentoml[monitor] # Prometheus monitoring

For AWS Deployment

pip install bentoml[aws]

For All Features

pip install bentoml[all]

Troubleshooting

ImportError: No module named 'bentoml'

Make sure you've activated your virtual environment and installed BentoML:

pip install --upgrade bentoml

Permission Denied Errors

On Linux/macOS, use --user flag:

pip install --user bentoml

Or use a virtual environment (recommended).

Dependency Conflicts

Create a fresh virtual environment:

python -m venv fresh-env
source fresh-env/bin/activate # On Windows: fresh-env\Scripts\activate
pip install bentoml

Docker Issues

Ensure Docker is running:

docker ps

Pull the latest image:

docker pull bentoml/bentoml:latest

Verifying Installation

Create a simple test to verify everything works:

# test_bentoml.py
import bentoml
import sklearn
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier

# Train a simple model
iris = load_iris()
model = RandomForestClassifier()
model.fit(iris.data, iris.target)

# Save with BentoML
saved_model = bentoml.sklearn.save_model("test_model", model)
print(f"Model saved: {saved_model.tag}")

# Load the model
loaded_model = bentoml.sklearn.get("test_model:latest")
print("Model loaded successfully!")

Run the test:

python test_bentoml.py

Next Steps

Now that BentoML is installed, you can: