-
Hi there! I am working on a system to generate synthetic responses for jsPsych experiments (jsPsychMonkeys). I use targets to create one docker container per participant using map(). Each container opens a browser instance, each browser runs the task for the participant (this can be from a minute to more than an hour), and in the last step, the docker container is destroyed. See gif below. When I run a few participants everything works fine. But when I run a big number of participants, the containers eat my RAM. This happens because right now targets runs the nodes by layers. So, first all the docker containers, then all the remote drivers, etc. (see gif). So I need to have enough RAM to have as many docker containers as participants simultaneously. Is there is a way to finish each branch before starting a new one? In brief:
Thanks for the help! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
In your case, it would probably be easiest to change the memory management strategy, e.g. An alternative would be to manually set the priority of each target. It is difficult to do this in # _targets.R
library(rlang)
library(targets)
library(tarchetypes)
tar_eval(
values = list(
target1 = c("target1_a", "target1_b"),
target2 = c("target2_a", "target2_b"),
x = c("a", "b"),
priority = c(0.5, 1)
),
list(
tar_target(target1, f(x), priority = priority),
tar_target(target2, g(target1), priority = priority)
)
) |
Beta Was this translation helpful? Give feedback.
-
Thanks for the answer @wlandau Sorry for the long message. The TLDR version is: It seems the future workers move row-wise more often than column-wise, reaching my If it was possible to set an option for row-wise movement as the default for targets, it would allow for cases where a lot of independent parallel computations with high RAM cost are needed. Long version. I've been doing some testing on a different computer with more RAM (64GB vs 24), and I tried running the transient memory and normal targets in 4 different configurations (Type of protocol x Type of make): Type of protocol:
Type of make:
For the sake of simplicity I am not showing the
I was puzzled about the lower memory requirements of It seems
I have not tried setting the priorities for each individual target. As you can see, I use Just in case it may be useful, this is my _targets.R file:
|
Beta Was this translation helpful? Give feedback.
-
My initial version had a big function taking care of everything, and One critical bit with my use case is that the side effect (csv file with participant's responses) is the desired result. The memory demands seem to also be unavoidable given the "column-wise" default direction in targets, and the need for as much parallel workers as possible. A "row-wise" mode would be a blessing, making possible to launch much more parallel participants. If at any point you think it may be a good idea to develop this "row-wise" mode, I would be happy to help testing it. Thanks for all the help. |
Beta Was this translation helpful? Give feedback.
In your case, it would probably be easiest to change the memory management strategy, e.g.
tar_option_set(memory = "transient", garbage_collection = TRUE)
. If you did that, I suspect target execution order would matter less. (Please keep in mind thattargets
assumes each target produces a single serializable/exportable return value and any untracked side effects can be safely discarded.)An alternative would be to manually set the priority of each target. It is difficult to do this in
tar_map()
but may be easier withtar_eval()
.