Lock page memory and non_blocking: Astrotransmission also requires conditions
The lock page memory is the memory of a CPU side that is not moved by a normal page break mechanism, which facilitates the transmission of some host to the device.
Learning objectives and first steps2 objectives 2 first fixes
Try to do it after reading
- Distinguishing CPU lock page memory from GPU memory
- Explain the necessary conditions for overlapping transmissions
Suggested first
- Target function to oversee learning
- Basic training and validation cycle
Two options do not automatically overlap
The lock page memory is the memory of a CPU side that is not moved by a normal page break mechanism, which facilitates the transmission of some host to the device. non_blocking indicates that the requested operation can be performed in a step-by-step manner, but that it can actually overlap with calculations and rely on hardware, currents, data sources and synchronization. It is not a promise to “copy immediately”.
Assuming that a batch contains 1 million float32, the pure data is about 4 MB. Opening pin_memory will not turn it into GPU volume or change data type; It also needs to be delivered visibly to the target equipment. If a lock page is temporarily reprinted manually in each batch, the lock page operation itself may offset the gain, and the full path should be measured instead of only the second half.
When the transfer is not complete, the data that is the source of the astral copy cannot be modified at will. In particular, the use of lock-page buffers and immediate reuse may allow the equipment to read the changed content. An asynchronous copy of the device to the host is also ensured before the results are used in CPU, and cannot be read immediately because the function returns.
Let's make sure where the bottlenecks are
If the model calculates 95 per cent of the time, the transmission is only a small fraction, and the benefits of complex transmission currents may be limited. Conversely, short models and large inputs are more likely to be subject to transmission restrictions. The calculation of CPU preparation, copying and equipment is separated by a reliable time scale before a decision is taken to increase the double buffer or stand-alone flow.
Lock page memory is a limited system resource. Too many workers, too large pre-cancellation queues and multiple parallel operations may take up a large amount of mainframe memory and affect other processes. The configuration should be estimated by the actual length size, batch, advance depth and the number of workers, and not by the size of a single batch.
The correctness test can fill a different fixed number for each batch, check that the device calculates the return value to match the current number, and then introduce buffer recovery. This exposes a step-by-step life-cycle error; A more general infestation does not lead to accidental contamination of samples.
This section is directed to the PyTorch2 mainframe and CUDA transmission, and other equipment backends are checked separately. 4 MB is an element byte estimate.
Does pin_memory = True mean that DataLoader returns the GPU volume directly?
No, it's not. It usually involves the storage of a CPU lock page, which still needs to be transmitted according to the equipment protocol.
What's the risk of covering the source buffer as soon as the astrologer returns?
The equipment may not be read yet and the result will be influenced by changes in source data. The life cycle of transmission completion and buffer recovery must be respected.
Sources and reconciliations
Definitions, methods and interfaces are available.
Figures and calculations are reorganized according to this chapter. Mathematical measurements, framework operations and real business effects are described separately in the body of the text.