pytorch / pytorch/vision

r2plus1d - strange relationship with inference batch size and inference speed

Open
#5,016 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
17.9k
Forks
7.3k
Avg merge
1d 15h
Merged PRs (30d)
13

Description

I'm seeing a weird relationship between inference batch size and inference speed that I can't explain. I have an r2plus1d resnet18 model that I trained. Input size is 8x32x32x3. I've been running some tests with fake data (random arrays) to measure inference speed as a function of batch size. For some reason, when the batch size increases from 6 to 7, the throughput suddenly drops significantly. It then slowly increases with the batch size until going from batch size of 24 to 25, at which point the throughput nearly doubles. I'm running this on a machine with one RTX 2080 with no other major processes running at the same time. I can run the experiment multiple times and I see the same phenomenon. I'm using Torch 1.9.1+cu102 and Torchvision 0.10.1+cu102. If anyone has any insight that might explain what I'm seeing, I'd appreciate it.

r2plus1d-timing-8frames.png

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository file, test, or entry point is named. Start by reproducing the reported r2plus1d ResNet-18 benchmark with fake data across batch sizes 6–25 on the stated Torch and Torchvision versions, then compare timings and profiling results. Done means identifying a reproducible explanation for the throughput changes or documenting the cause.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
computer-vision, machine-learning, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.