Welcome to torchbench!

You have reached the docs for the torchbench library. This library contains a collection of deep learning benchmarks you can use to benchmark your models, optimized for the PyTorch framework. It can be used in conjunction with the sotabench.com website to record results for models, so the community can compare model performance on different tasks, as well as a continuous integration style service for your repository to benchmark your models on each commit.

torchbench is a framework-optimized library, meaning it is designed to take advantage of PyTorch based features and standardisation. If this is too constraining, you can use alternative libraries that are framework-independent, e.g. sotabencheval.

Getting Started : Benchmarking on ImageNet

Step One : Create a sotabench.py file in the root of your repository

This contains a call to your model, metadata about your model, and options for evaluation such as dataset processing logic and data loader logic such as the batch size. Below is an example for the torchvision repository:

from torchbench.image_classification import ImageNet
from torchvision.models.resnet import resnext101_32x8d
import torchvision.transforms as transforms
import PIL

# Define the transforms need to convert ImageNet data to expected model input
normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], 
    std=[0.229, 0.224, 0.225])
input_transform = transforms.Compose([
    transforms.Resize(256, PIL.Image.BICUBIC),

# Run the benchmark

Step Two : Run locally to verify that it works

python sotabench.py

You can also run the logic in a Jupyter Notebook if that is your preferred workflow.

To verify your benchmark will run and all parameters are correct you can use the included CLI checking tool:

$ sb check

Step Three : Login and connect your repository to sotabench

Create an account on sotabench, then head to your user page. Click the Connect a GitHub repository button:

Then follow the steps to connect the repositories that you wish to benchmark:

After you connect your repository, the sotabench servers will re-evaluate your model on every commit, to ensure the model is working and results are up-to-date - including if you add additional models to the benchmark file.


The library requires Python 3.6+. You can install via pip:

pip install torchbench


If you get stuck you can head to our Discourse forum where you ask questions on how to use the project. You can also find ideas for contributions, and work with others on exciting projects.