TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
←

134. Max Batch Size from VRAM

Medium

Given the memory budget on a GPU, return the largest integer batch size that fits.

Signature: def max_batch_size(weight_bytes: int, activation_bytes_per_sample: int, gpu_vram_bytes: int, overhead_bytes: int) -> int

Return floor((vram - weights - overhead) / activation_per_sample). If the result is negative, return 0.

Math

B=⌊AV−W−O​⌋

Asked at

NumPy

import numpy as np

 

def max_batch_size(...):

    pass

🔒

Premium problem

Free accounts include problems #1–20. Upgrade to unlock the editor, hidden test cases, and reference solutions for every problem.

Upgrade to PremiumBack to problems

Already premium?