ENMeval 2.0.0

588 views
Skip to first unread message

Rahul G

unread,
May 11, 2021, 3:10:52 AM5/11/21
to max...@googlegroups.com
Dear People,

I am trying to work using the latest 'ENMeval 2.0.0' R package.

Having Mac, 2.3 GHz Dual-Core Intel Core i5, with 8 GB memory, the ENMevaluate process is taking forever, (I have created only 5000 background points). 
My system is getting hanged and Rstudio is getting crashed each time.

Any sort of trick could help?

e.mx <- ENMevaluate(occs = occ, envs = env, bg = bg, 
                    algorithm = 'maxnet', 
                    partitions = 'randomkfold', partition.settings = list(kfolds = 5), 
                    categoricals = "lulc",
                    tune.args = list(fc = c("L","LQ","LQH","H"), rm = 1:5))


Note: I am using seven fine scale (30m) environmental rasters, including one categorical raster which is 'land use land cover' file.

Thanks & regards,
Rahul

gafna jeff

unread,
May 11, 2021, 3:24:49 AM5/11/21
to max...@googlegroups.com
Hello Rahul,

Can you include this in your code and try        parallel = T


Jeff

--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maxent+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/maxent/CAKCC-_F6jDU0Rz%3DiaQA%3D0VCqrFzhBjm-KuaW9oZLXnf1M2Uwug%40mail.gmail.com.

Rahul G

unread,
May 11, 2021, 4:46:01 AM5/11/21
to max...@googlegroups.com
Thanks Jeff for responding, yes I have tried the argument 'parallel = TRUE', sadly that too didn't help.

Now today again I've tried running again, got the below error.

* Running initial checks... *

* Assigning variable lulc to categorical ...
* Clamping predictor variable rasters...
* Model evaluations with random 5-fold cross validation...

* Running ENMeval v2.0.0 with maxnet from maxnet package v0.1.2 *

  |========                                                                          |  10%Error: vector memory exhausted (limit reached?)
Error during wrapup: vector memory exhausted (limit reached?)
Error: no more error handlers available (recursive errors?); invoking 'abort' restart
>

Thanks,
Rahul

魏久锋

unread,
May 11, 2021, 8:07:02 AM5/11/21
to max...@googlegroups.com
Hi, Rahul,
You must be improve your memory in your computer.
or try change other computer with larger memory.



Rahul G <rahul...@gmail.com> 于2021年5月11日周二 下午4:46写道:

Rahul G

unread,
May 11, 2021, 2:59:41 PM5/11/21
to max...@googlegroups.com
Hi,
I dont think I can upgrade the memory of my computer and change the computer now due to shortage in time to submit my master thesis. Thanks.

On 11-May-2021, at 17:37, 魏久锋 <weiji...@gmail.com> wrote:



gafna jeff

unread,
May 12, 2021, 4:07:29 AM5/12/21
to max...@googlegroups.com
Dear Rahul,
You can increase the memory of your computer by running this code. It normally works for windows. Am not sure if that is the case for Macbook.

# workstation
options(java.parameters = "-Xmx30g")  
#my computer
options(java.parameters = "-Xmx30g")  



Jeff




Jamie M. Kass

unread,
May 17, 2021, 8:07:53 AM5/17/21
to Maxent
Rahul,

Sorry to hear you're having issues with memory using ENMeval 2.0.0. I really don't think this has anything to due with ENMeval or this particular version -- it is likely a limitation of your computer. Unfortunately, the Java memory settings suggested by Jeff will not work for maxnet, but another option is to switch to maxent.jar and do just this -- it's more powerful because it runs in Java instead of R (which is slower).

Another easy option is to break the modeling in parts, where if you had 50 models to tune, you could do 10 at a time, etc. After each run, you can save the resulting ENMevaluation object as an .rds, restart R, and do it again if you need to.

Hope this helps.

Jamie

Rahul G

unread,
May 17, 2021, 12:59:18 PM5/17/21
to max...@googlegroups.com
Thanks Jamie for the response, I will try the workaround as you suggested.

Regards,
Rahul

Antonio Sampedro

unread,
Dec 1, 2024, 4:51:41 AM12/1/24
to Maxent
Dear Jamie and friends. I came up. with something that might be a useful idea to store the model results through a loop and remove the virtual memory through each iteration of the loop (Code at the bottom).

I have one question. I can store a big number of models this way, but I can not access interesting functions as eval.models() or eval.results() or evalplot.stats(). Is there any walkaround to make it possible to include all those individual models in one "ENMeval" object?

Thank you in advance



as an example

tune_rm_values <- c(0.5, 1, 3, 5, 10)
feature_combinations <- c("LQ", "LQH", "HC", "HQC", "TC", "LQHP")
combinations <- expand.grid(fc = feature_combinations, rm = tune_rm_values, stringsAsFactors = FALSE)
model_list <- list()


for (i in seq_len(total_combinations)) {  # USE seq_len to avoid indexed problems
  # Update progress bar
  setTxtProgressBar(pb, i)
 
  # set combinations of fc y rm
  current_fc <- combinations$fc[i]
  current_rm <- combinations$rm[i]
 
  # Print the progress and the current execution (para depuración)
  cat("Combination", i, "of", total_combinations, "- fc:", current_fc, ", rm:", current_rm, "\n")
 
  # Define the settings for each loop
  tune_args <- list(fc = current_fc, rm = current_rm)
 
  # Execute ENMevaluate
  model <- tryCatch({
    ENMevaluate(
      occs = occs[,c("longitude", "latitude")],
      envs = clim.fit,
      bg = bgs[,c("longitude", "latitude")],
      algorithm = "maxent.jar",
      partitions = 'block',
      categoricals = "lancov",
      progbar = F,
      parallel = TRUE,
      parallelType = "doParallel",
      numCores = 8,
      tune.args = tune_args
    )
  }, error = function(e) {
    message(paste("Error on the combination fc =", current_fc, ", rm =", current_rm, ":", e$message))
    return(NULL)  # Return NULL in case of failure
  })
 
  # Store the result in a List object
  gw_list[[paste0("fc_", current_fc, "_rm_", current_rm)]] <- model
 
  # Eliminate the temporal object and free the memory
  rm(model)
  gc()
}

Jamie M. Kass

unread,
May 1, 2025, 8:20:26 PMMay 1
to Maxent
Sorry for the late reply. You use make an empty list before the loop, then put each ENMevaluation object inside the list with each iteration. Then you can access each one at the end from the list and pull out all the things you want.

-Jamie

Reply all
Reply to author
Forward
0 new messages