diff --git a/benchmarks/torchvision/main.py b/benchmarks/torchvision/main.py index e5f463b9c..c44241867 100644 --- a/benchmarks/torchvision/main.py +++ b/benchmarks/torchvision/main.py @@ -69,7 +69,7 @@ class SyntheticData: def __init__(self, model, device, batch_size, n, fixed_batch): self.n = n model = model.to(device) - + self.inp = torch.randn((batch_size, 3, 224, 224), device=device) self.out = torch.rand_like(model(self.inp)) self.fixed_batch = fixed_batch @@ -184,7 +184,8 @@ def dataloader(args, model): ) def model_optimizer(args, model, device): - model.train() + if hasattr(model, "train"): + model.train() if "channel_last" in args.optim: model = model.to(memory_format=torch.channels_last) @@ -336,7 +337,8 @@ def iobench(args): def train_epoch(args, model, criterion, optimizer, loader, device, dtype, scaler=None): - model.train() + if hasattr(model, "train"): + model.train() set_to_none = "set_grad_none" in args.optim diff --git a/config/resnet50.yaml b/config/resnet50.yaml index dcdd26149..b2a004a70 100644 --- a/config/resnet50.yaml +++ b/config/resnet50.yaml @@ -53,33 +53,49 @@ resnet-matrix-noio: --fixed-batch: true -resnet18-matrix: +# resnet18-matrix: +# matrix: +# worker: [8] +# batch-size: [256, 512, 1024] +# loader: ['pytorch', 'dali'] + +# job: +# name: 'resnet18-w{worker}-bs{batch-size}-{loader}' +# inherits: _resnet50 +# argv: +# --model: resnet18 +# --batch-size: '{batch-size}' +# --num-workers: '{worker}' +# --loader: '{loader}' + +resnet-optim: matrix: worker: [8] - batch-size: [256, 512, 1024] - loader: ['pytorch', 'dali'] + batch-size: [256] + loader: ['dali'] + optim: ["trace", "inductor", "script", "channel_last", "set_grad_none"] job: - name: 'resnet18-w{worker}-bs{batch-size}-{loader}' + name: 'resnet50-w{worker}-bs{batch-size}-{loader}-{optim}' inherits: _resnet50 argv: - --model: resnet18 --batch-size: '{batch-size}' --num-workers: '{worker}' --loader: '{loader}' + --optim: '{optim}' -resnet-optim: + +image-loading: matrix: - worker: [8] - batch-size: [256] - loader: ['dali'] - optim: ["trace", "inductor", "script", "channel_last", "set_grad_none"] + worker: [2, 4, 8, 16, 24, 32, 64] + batch-size: [32, 64, 128, 256, 512, 1024] + loader: ['pytorch', 'dali'] job: - name: 'resnet50-w{worker}-bs{batch-size}-{loader}-{optim}' + name: 'imageloading-w{worker}-bs{batch-size}-{loader}' inherits: _resnet50 argv: --batch-size: '{batch-size}' --num-workers: '{worker}' --loader: '{loader}' - --optim: '{optim}' + --iobench: true