A team is building a text classification pipeline. After tokenising a large corpus on the CPU, they notice the GPU sits idle during the tokenisation and normalisation steps, then spikes briefly during the forward pass before sitting idle again. Which redesign most effectively eliminates the host-to-device transfer bottleneck and keeps the GPU busy throughout preprocessing?
- AIncrease the number of CPU worker threads feeding the DataLoader so that batches arrive faster, saturating the GPU with more frequent data transfers at a higher bandwidth per second.
- BPin the input tensors in CPU memory using pinned allocation so that direct memory access transfers are faster, then copy the pinned tensors to the GPU once per epoch at the start of training.
- CMove the tokenisation and feature-scaling steps onto the GPU using a GPU-native library such as cuDF or RAPIDS, keeping the tensors resident on the GPU throughout the pipeline until training is complete. Correct
- DPre-tokenise the entire dataset on the CPU, serialise the resulting integer tensors to disk as memory-mapped files, then load each batch lazily from disk directly into GPU memory at training time.
Why A is wrong: Adding CPU workers reduces the time data sits in a queue, but every batch still crosses the PCIe bus from host to device memory. The root cause - host-to-device transfer overhead - is not addressed; the GPU can still stall between transfers, and more frequent small transfers may worsen PCIe congestion rather than improve it.
Why B is wrong: Pinned memory does accelerate individual host-to-device copies and enables asynchronous transfer, which is a genuine optimisation. However, it does not eliminate transfers; the data still moves across the PCIe bus. Preprocessing on the CPU and then copying once per epoch still leaves the GPU idle during tokenisation, so the fundamental pipeline stall persists.
Why C is correct: Performing tokenisation and scaling directly on the GPU with a library like cuDF means the data never leaves device memory between preprocessing and training. This eliminates the host-to-device transfers that stall the pipeline, and the GPU remains active across all stages rather than waiting for the CPU to finish and then copy data across the PCIe bus.
Why D is wrong: Memory-mapped files can reduce RAM pressure and allow partial loading, which is attractive for very large datasets. However, loading from disk to GPU still requires a host-staging step; data travels through the CPU memory hierarchy before reaching the GPU. Disk I/O latency is far higher than DRAM-to-GPU transfers, so this approach introduces a new bottleneck rather than removing the existing one.