netlogo in linux (and in R if possible)

140 views
Skip to first unread message

Rebecca Goldberg

unread,
Feb 7, 2024, 4:42:58 PMFeb 7
to netlogo-users
Hello,

I'm running netlogo in a linux server so that I can run models from R (also running on the same linux server), but I'm having a performance issue. Models are taking a lot longer than they should. If anyone could assist with getting the models to run in the expected run time using headless on linux, that would be great, but extra special would be getting them to run with an expected run time in R using the nlrx package (so much easier for model set up and output analysis). More details below.

Appreciate any help!

Rebecca


nlrx has been taking a very long time to run models for me, and I tried to see how long only one would take to isolate the issue. The basic wolf sheep predation model with all constants specified to only one option, using only one seed, and one repetition still takes about 5 minutes in R. Based on what I saw was written previously about similar issues, the headless version (using only linux) should run in a few seconds, and a model with nlrx should take a few seconds by itself + 4seconds. I ran the default headless wolf-sheep predation netlogo model in linux, but instead of 1 minute, that takes about 5 minutes to get output. I always get the output expected in both situations though, with no errors of any kind. I kept the temp files too, csv and xml, which also look fine. I've tried increasing the memory allocated as well. System info and code below. Appreciate any assistance and please let me know if I need to provide more info.


Headless Run in linux terminal
cd "/opt/NetLogo-6.4.0-64" ./netlogo-headless.sh \ --model "models/IABM Textbook/chapter 4/Wolf Sheep Simple 5.nlogo" \ --experiment "Wolf Sheep Simple model analysis" \ --table ~/wsp5-table-output.csv


R code

library(nlrx)
library(progressr)
library(furrr)
library(tictoc)
wd <- "/opt/"
wd_home <- "[pathway...]"
netlogopath <- file.path(paste0(wd,"NetLogo-6.4.0-64"))

Create nl object

netlogopath <- file.path(paste0(wd,"NetLogo-6.4.0-64"))
modelpath <- file.path(netlogopath, "models/Sample Models/Biology/Wolf Sheep Predation.nlogo")
outpath <- file.path(wd_home)
nl <- nl(nlversion = "6.4.0-64",
nlpath = netlogopath,
modelpath = modelpath,
jvmmem = 1024)

single run

nl@experiment <- experiment(expname="wolf-sheep",
outpath=outpath,
repetition=1,
tickmetrics="true",
idsetup="setup",
idgo="go",
runtime=50,
evalticks=seq(40,50),
metrics=c("count sheep", "count wolves"),
constants = list("model-version" = ""sheep-wolves-grass"",
"grass-regrowth-time" = 30,
"sheep-gain-from-food" = 4,
"wolf-gain-from-food" = 20,
"sheep-reproduce" = 4,
"wolf-reproduce" = 5,
"show-energy?" = "false",
"initial-number-sheep" = 100,
"initial-number-wolves" = 25))
nl@simdesign <- simdesign_simple(nl=nl,
nseeds=1)

eval_variables_constants(nl) #should print "all valid" message

Run all simulations (loop over all siminputrows and simseeds)

tic()
results <- run_nl_one(nl = nl,seed = 123, siminputrow = 1,cleanup.csv = FALSE,cleanup.xml = FALSE )
toc()`


Sys.info

R version 4.3.2 (2023-10-31)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux 8.9 (Ootpa)

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblaso-r0.3.15.so; LAPACK version 3.9.0

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

time zone: America/New_York
tzcode source: system (glibc)

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] tictoc_1.2 furrr_0.3.1 future_1.33.1 progressr_0.14.0 nlrx_0.4.4

Charles Jui

unread,
Feb 7, 2024, 4:59:43 PMFeb 7
to netlogo-users

Hi

I suspect you are running the models while in "headless" over just ONE thread/core (which is the default) of the processor whereas interactively it runs on 4-8 threads/core?
I am going to guess that you have a machine with 8 cores or 4 cores/8 thread?
You can use the "--threads <number>" option to specify number of threads running in parallel 

Hope this helps
Cheers!
Charlie Jui
University of Utah

Rebecca Goldberg

unread,
Feb 8, 2024, 1:40:28 PMFeb 8
to netlogo-users
I'm sorry I should've mentioned my parallelization attempts. Yes, the code I shared was using only 1 thread. I'm actually running this on a 256 core server, and have tried increasing the number of threads to 4 with the headless version as well as the number of cores to 4 using the future package as specified in the nlrx documentation. Changing to 4 threads for headless doesn't make it any faster, but I'm not sure if that's because, as expected, each model really only takes a couple of seconds and something else in the process is taking up the bulk of the time. When I increase the cores for the nlrx version, meaning using only 1 set of constants for everything, parallelization also had no effect, but it shouldn't if I understand correctly how it it's assigning jobs to the cores (each permutation of variables gets one core). If I use more than one variable permutation, then I can see the parallelization have an impact, but nothing outputs below the 5 minutes of running a single model. If my understanding is incorrect though, please let me know. I'm not as concerned with how long extensive models and permutations take since I have so much processing power. I just want to make sure that at the most basic level, netlogo and/or nlrx are behaving as expected, but these run times seem way too long.

Revised headless code:
  cd "/opt/NetLogo-6.4.0-64"
  ./netlogo-headless.sh  \
  --threads 4 \

  --model "models/IABM Textbook/chapter 4/Wolf Sheep Simple 5.nlogo"  \
  --experiment "Wolf Sheep Simple model analysis" \
  --table directory....wsp5-table-output.csv

Thanks all,
Rebecca

Rebecca Goldberg

unread,
Jun 10, 2024, 3:25:14 PMJun 10
to netlogo-users
Hi again,

I am still experiencing issues running netlogo in a reasonable amount of time with the most basic example model on linux. My team has tried running this on multiple production servers and it still takes 5 minutes. When I run it on my personal computer, it only takes 20 seconds, but my personal computer can't be used for this project. We've been experiencing this issue for months, and despite plenty of troubleshooting, we're unable to find any issues or errors. If anyone knows if there's a config change we need to make or a reason why it would be dragging its feet in different environments, please let me know. 

Thank you,
Rebecca

Dale Frakes

unread,
Jun 10, 2024, 3:55:16 PMJun 10
to netlog...@googlegroups.com
Hi Rebecca,

I don't really have an answer...  it could also depend on the java being used on the Linux machines.  I'm not sure how to specify that NetLogo use its own, however.

I also use Linux and in the past I've compared the native Linux version of a model (the 3D Surface in the Model Library) with the same model running on the same machine but using Wine and the Windows version of NetLogo (which comes with its own Java installation) and the model running in the Windows version runs quite a bit faster.

It might be worth seeing if they can install the Windows version of Netlogo on your cluster using Wine and see if it runs any faster.

Dale
--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/ef3f22ad-ef41-487c-8c06-3092063f0ed3n%40googlegroups.com.

-- 
Dale Frakes
Adjunct Instructor, PhD Student
PSU Systems Science
dfr...@pdx.edu - http://web.pdx.edu/~dfrakes/

Aaron Andre Brandes

unread,
Jun 11, 2024, 9:26:28 AMJun 11
to Rebecca Goldberg, netlogo-users, bu...@ccl.northwestern.edu

Hi Rebecca,

We are sorry you are experiencing this problem.

I’m busy with a project this week, and will look further into it next week.

Can you clarify the following:

What kind of personal computer do you have?

When you say “linux server” does that mean you have to submit a job to a high performance computing cluster (HPC), or are you logging onto a linux server and running the code directly?

If you are using an HPC we will need more information. We have graduate students here running large NetLogo projects successfully on the Northwestern HPC, so we know it can be done.

 

From what you are saying this problem is separate from the nlrx problem.

 

I have run the basic nlrx demo problem on my MacBook Pro and I think it takes 20 minutes to run a version that winds up running 1000 single run experiments, each requiring a separate use of NetLogo via its Controlling API. I don’t think it takes advantage of parallelism on the Mac. In NetLogo 6.4.0 one can specify “non-combinatorial” experiments, so if nlrx were updated to make use of this capability it would only need to call NetLogo once.

 

Please include bu...@ccl.northwestern.edu bu...@ccl.northwestern.edu in future email to be sure this issue gets the appropriate attention.

  • Aaron

 

 

 

-- 

Aaron Brandes, Software Developer

Center for Connected Learning and Computer-Based Modeling

 

 

--

You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to


To view this discussion on the web visit

Wade Schuette

unread,
Jun 11, 2024, 9:49:04 AMJun 11
to Aaron Andre Brandes, Rebecca Goldberg, bu...@ccl.northwestern.edu, netlogo-users
I am trying to figure out what the right question is to ask. I guess there is no magic profiling tool so how can an easy test halve the search space?

my first thought is whether the time is being spent on lines of code or between lines of code  ( swapping, processes fighting each other for slicesof time etc.)

one experiment would be to short circuit the deepest nested statements  that are run the most times and seeif that helps a lot or a little.

if it helps a lot,  dig there.  best way to improve speed is to revise the algorthmand eliminate the loop entirely. doesnt answer why different.

if it barely helps the problem isnt in linesof code. 


.wade



R. Wade Schuette
2401 Parker St. APT 3
Columbia MO 65202


Rebecca Goldberg

unread,
Jun 11, 2024, 10:09:16 AMJun 11
to netlogo-users
Hi all,

thank you so much for troubleshooting with me. We have tried pointing to multiple java versions, including the one that comes with netlogo. And given the processing speed our super servers can provide, the windows version isn’t feasible for us. We just can’t figure out why headless takes 20 seconds on some platforms but 5 minutes on others. We log into a linux server and test by running the example wolf-sheep simulation headless. 

The server we're trying to run it on is AMD EPYC 7763 processor (256 cores) with 4.5TB of RAM. We've tried with other prod servers with slightly less memory (2TB and 880 gigs), which still takes 5 minutes. All of these larger servers run redhat linux 8.9. When we test on much smaller dev servers running redhat 9.3 with one to eight cpu and 15 Gigs of ram, that takes only 20 seconds. Personal computer was intel laptop with arch linux, also takes 20 seconds. To make sure linux 8.9 wasn't the issue, we also tried creating a virtual machine with 1cpu and 2gp of memory with redhat 8.9, simulation only took 30 seconds.

Maybe this is the reason nlrx could be taking so long? We started running netlogo headless on linux instead of just running nlrx to make sure netlogo was running properly (which obviously it isn't). Fixing the headless version is the priority though.

Rebecca
Reply all
Reply to author
Forward
0 new messages