From ed5b511b2d473e117320c75c0fd7fe2abfbfc9da Mon Sep 17 00:00:00 2001 From: vmoens Date: Fri, 24 Nov 2023 12:13:23 +0000 Subject: [PATCH] amend --- tutorials/sphinx-tutorials/rb_tutorial.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tutorials/sphinx-tutorials/rb_tutorial.py b/tutorials/sphinx-tutorials/rb_tutorial.py index 5237b344e56..23f2f866d71 100644 --- a/tutorials/sphinx-tutorials/rb_tutorial.py +++ b/tutorials/sphinx-tutorials/rb_tutorial.py @@ -46,6 +46,7 @@ # replay buffer is a straightforward process, as shown in the following # example: # +import tempfile from torchrl.data import ReplayBuffer @@ -175,8 +176,9 @@ ###################################################################### # We can also customize the storage location on disk: # +tempdir = tempfile.TemporaryDirectory() buffer_lazymemmap = ReplayBuffer( - storage=LazyMemmapStorage(size, scratch_dir="/tmp/memmap/") + storage=LazyMemmapStorage(size, scratch_dir=tempdir) ) buffer_lazymemmap.extend(data) print(f"The buffer has {len(buffer_lazymemmap)} elements") @@ -207,8 +209,9 @@ from torchrl.data import TensorDictReplayBuffer +tempdir = tempfile.TemporaryDirectory() buffer_lazymemmap = TensorDictReplayBuffer( - storage=LazyMemmapStorage(size, scratch_dir="/tmp/memmap/"), batch_size=12 + storage=LazyMemmapStorage(size, scratch_dir=tempdir), batch_size=12 ) buffer_lazymemmap.extend(data) print(f"The buffer has {len(buffer_lazymemmap)} elements") @@ -248,8 +251,9 @@ class MyData: batch_size=[1000], ) +tempdir = tempfile.TemporaryDirectory() buffer_lazymemmap = TensorDictReplayBuffer( - storage=LazyMemmapStorage(size, scratch_dir="/tmp/memmap/"), batch_size=12 + storage=LazyMemmapStorage(size, scratch_dir=tempdir), batch_size=12 ) buffer_lazymemmap.extend(data) print(f"The buffer has {len(buffer_lazymemmap)} elements")