Skip to content

Commit

Permalink
Batch size + worker experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre.delaunay committed Jun 3, 2024
1 parent d8c09b7 commit 87bc6af
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 11 deletions.
29 changes: 18 additions & 11 deletions benchmarks/torchvision/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def get_dali_pipeline():
random_shuffle=True,
name="Reader",
)

# decode data on the GPU
images = fn.decoders.image_random_crop(
images,
Expand All @@ -124,31 +125,37 @@ def get_dali_pipeline():
reader_name='Reader'
)

def iter():
for _ in range(args.epochs):
for data in train_data:
class Adapter:
def __init__(self, iter):
self.iter = iter

def __len__(self):
return len(self.iter)

def __iter__(self):
for data in self.iter:
x, y = data[0]['data'], data[0]['label']
yield x, torch.squeeze(y, dim=1).type(torch.LongTensor)

yield from iter()
return Adapter(train_data)


def dataloader(args, model):
if args.loader == "dali":
return dali(args, args.data)
if not args.data:
data_directory = os.environ.get("MILABENCH_DIR_DATA", None)
if data_directory:
args.data = os.path.join(data_directory, "FakeImageNet")

if args.fixed_batch:
args.synthetic_data = True

if args.synthetic_data:
args.data = None
else:
if not args.data:
data_directory = os.environ.get("MILABENCH_DIR_DATA", None)
if data_directory:
args.data = os.path.join(data_directory, "FakeImageNet")

if args.data:
if args.loader == "dali":
return dali(args, os.path.join(args.data, "train"))

train = datasets.ImageFolder(os.path.join(args.data, "train"), data_transforms)
return torch.utils.data.DataLoader(
train,
Expand Down
11 changes: 11 additions & 0 deletions config/matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,14 @@ resnet-batch:
--batch-size: '{batch-size}'
--num-workers: '{worker}'
--loader: '{loader}'

resnet-batch-noio:
matrix:
batch-size: [32, 64, 128, 256, 512, 1024]

job:
name: 'resnet50-noio-bs{batch-size}'
inherits: _resnet50
argv:
--batch-size: '{batch-size}'
--synthetic-data: true
5 changes: 5 additions & 0 deletions scripts/article/run_cuda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ install_prepare() {
pip install -e $MILABENCH_WORDIR/voir
pip install -e $MILABENCH_WORDIR/torchcompat
pip install torch torchvision torchaudio

# DALI stuff
pip install --extra-index-url https://pypi.nvidia.com --upgrade nvidia-dali-cuda120
pip install nvidia-pyindex
pip install nvidia-nvjpeg-cu12
)

#
Expand Down
14 changes: 14 additions & 0 deletions scripts/batch/run_cuda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@



export MILABENCH_GPU_ARCH=cuda
export MILABENCH_WORDIR="$(pwd)/$MILABENCH_GPU_ARCH"
export MILABENCH_CONFIG="$MILABENCH_WORDIR/milabench/config/matrix.yaml"

CUDA_VISIBLE_DEVICES=0 bash $MILABENCH_WORDIR/milabench/scripts/article/run_cuda.sh --config $MILABENCH_CONFIG --select resnet

CUDA_VISIBLE_DEVICES=0,1 bash $MILABENCH_WORDIR/milabench/scripts/article/run_cuda.sh --config $MILABENCH_CONFIG --select resnet

CUDA_VISIBLE_DEVICES=0,1,2,3 bash $MILABENCH_WORDIR/milabench/scripts/article/run_cuda.sh --config $MILABENCH_CONFIG --select resnet

CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 bash $MILABENCH_WORDIR/milabench/scripts/article/run_cuda.sh --config $MILABENCH_CONFIG --select resnet

0 comments on commit 87bc6af

Please sign in to comment.