Xla: Should the num_workers in the colab examples be higher than 4?

Created on 13 Oct 2019  ยท  1Comment  ยท  Source: pytorch/xla

โ“ Questions and Help

In the colab examples, I noticed the num_workers is set to 4. I am wondering if it should be set to at least 8, which is the number of cores a TPU has. So a dataloader for each core. The num_workers is a parameter for the dataloader

train_loader = torch.utils.data.DataLoader(
    train_dataset,
    batch_size=batch_size,
    shuffle=True,
    num_workers=num_workers)

I am wondering if this is based on colab CPUs having 4 cores in the CPU and GPU instances; however the TPU colab instance's CPU has 40 cores instead of 4.

Most helpful comment

Tuning the number of workers depends on the amount of work the input pipeline is doing, and the available CPU cores.
Some CPU cores are also needed to convert tensors to device format, and some for running model's Python code, so we can imagine the maximum number of workers to be about NUM_CPU_CORES - NUM_TPU_CORES.
There is also no reason to set num_workers to a number higher than necessary.
So given the 40 CPU cores, you can try to bump it up progressively and see up to which point model's throughput increases.

>All comments

Tuning the number of workers depends on the amount of work the input pipeline is doing, and the available CPU cores.
Some CPU cores are also needed to convert tensors to device format, and some for running model's Python code, so we can imagine the maximum number of workers to be about NUM_CPU_CORES - NUM_TPU_CORES.
There is also no reason to set num_workers to a number higher than necessary.
So given the 40 CPU cores, you can try to bump it up progressively and see up to which point model's throughput increases.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

myleott picture myleott  ยท  7Comments

david-alexander-white picture david-alexander-white  ยท  6Comments

butchland picture butchland  ยท  7Comments

dalmia picture dalmia  ยท  6Comments

ibeltagy picture ibeltagy  ยท  5Comments