Skip to content

Commit bff42d1

Browse files
author
Vincent Moens
committed
amend
1 parent 392230a commit bff42d1

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

intermediate_source/pinmem_nonblock.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
- While ``cpu_tensor.to("cuda", non_blocking=True).mean()`` executes correctly, attempting
2424
``cuda_tensor.to("cpu", non_blocking=True).mean()`` will result in erroneous outputs.
2525
26+
Preamble
27+
~~~~~~~~
28+
29+
The performance reported in this tutorial are conditioned on the system used to build the tutorial.
30+
Although the conclusions should be applicable across different systems, the specific observations may vary slightly
31+
depending on the hardware available.
32+
2633
"""
2734

2835
import torch
@@ -32,6 +39,14 @@
3239

3340
######################################################################
3441
#
42+
# This tutorial requires tensordict to be installed. If you don't have tensordict in your environment yet, install it
43+
# by running the following command in a separate cell:
44+
#
45+
# .. code-block:: bash
46+
#
47+
# # Install tensordict with the following command
48+
# !pip3 install tensordict
49+
#
3550
# We start by outlining the theory surrounding these concepts, and then move to concrete test examples of the features.
3651
#
3752
# - :ref:`Background <pinned_memory_background>`
@@ -136,7 +151,6 @@
136151

137152
import contextlib
138153

139-
import torch
140154
from torch.cuda import Stream
141155

142156

@@ -589,10 +603,6 @@ def pin_copy_to_device_nonblocking(*tensors):
589603
# ``pin_memory()`` before proceeding with to ``to(device)``.
590604
# This approach can further accelerate data transfers, as demonstrated in the following example.
591605
#
592-
# .. code-block:: bash
593-
#
594-
# # Install tensordict with the following command
595-
# !pip3 install tensordict
596606
#
597607

598608
from tensordict import TensorDict

0 commit comments

Comments
 (0)