Question about Dataloader and GPU memory usage

for batch_i, (_, imgs, targets) in enumerate(dataloader):

        batches_done = len(dataloader) * epoch + batch_i

        imgs = Variable(imgs.to(device))
        targets = Variable(targets.to(device), requires_grad=False)

Question 1:
If using num working = 4, batch_size=8 for the dataloader, does it mean that at the same time I will have 32 data assigned to the GPU memory?

Question 2:
What is pin_memory in dataloader?

  1. Batch size indicates the size of data that comes out of dataloader at a time. i.e., in your case, you will have count=8 data assigned to the GPU. num_workers defines the number of threads spawned to read the data.

  2. Take a look at this: When to set pin_memory to true?