Skip to content

Running out of memory when using future_lapply within another software #670

Answered by HenrikBengtsson
blenback asked this question in Q&A
Discussion options

You must be logged in to vote

Looking at your code snippet, each future_lapply() iteration uses only one row of Model_lookup, e.g. Model_lookup[i, "Trans_name"]. This means you can avoid exporting the full Model_lookup object. I recommend using future_by() instead, which has the capability of iterating over rows, e.g.

results <- future.apply::future_by(Model_lookup, INDICES = seq_len(nrow(Model_lookup)), future.packages = packs, FUN = function(row) {
  #vector trans_name
  Trans_name <- row[1, "Trans_name"]
  Trans_ID <- row[1, "Trans_ID"]
  ...
})

Because future.apply chunks up the iterations, this construct will export only the chunk of rows that are needed, instead of the full Model_lookup object. This scales much …

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@blenback
Comment options

@scottkosty
Comment options

@scottkosty
Comment options

Comment options

You must be logged in to vote
1 reply
@blenback
Comment options

Answer selected by blenback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants