Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nlm_gaussianfield() fails when called in parallel #99

Open
DavidDHofmann opened this issue Aug 17, 2022 · 0 comments
Open

nlm_gaussianfield() fails when called in parallel #99

DavidDHofmann opened this issue Aug 17, 2022 · 0 comments

Comments

@DavidDHofmann
Copy link

Hello

I'm trying to generate rasters using the nlm_gaussianfield() function. However, the generation fails whenever the function is called in a parallel session.

# Required packages
library(NLMR)
library(parallel)

# Works
mclapply(1:2, mc.cores = 1, function(x) {
  nlm_gaussianfield(ncol = 5, nrow = 5)
})

# Does not work
mclapply(1:2, mc.cores = 2, function(x) {
  nlm_gaussianfield(ncol = 5, nrow = 5)
})

This yields the following error message:

[[1]]
[1] "Error in RandomFieldsUtils::RFoptions(...) : \n  'RFoptions(...)' may be used only outside any parallel code\n"
attr(,"class")
[1] "try-error"
attr(,"condition")
<simpleError in RandomFieldsUtils::RFoptions(...): 'RFoptions(...)' may be used only outside any parallel code>

This appears to be an issue related to the RandomFields and RandomFieldsUtils packages, as the same code works when I install older package versions from the archive:

devtools::install_version("RandomFieldsUtils", version = "0.5", repos = "http://cran.us.r-project.org")
devtools::install_version("RandomFields", version = "3.3.1", repos = "http://cran.us.r-project.org", dependencies = F)

Here's my sessionInfo()

R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 20.3

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=de_DE.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=de_DE.UTF-8        LC_COLLATE=de_DE.UTF-8    
 [5] LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=de_DE.UTF-8   
 [7] LC_PAPER=de_DE.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] NLMR_1.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9              raster_3.5-21           uuid_1.1-0             
 [4] lattice_0.20-45         rlang_1.0.4             fastmap_1.1.0          
 [7] fansi_1.0.3             tools_4.2.1             RandomFields_3.3.14    
[10] grid_4.2.1              checkmate_2.1.0         utf8_1.2.2             
[13] terra_1.6-1             cli_3.3.0               RandomFieldsUtils_1.2.5
[16] htmltools_0.5.2         digest_0.6.29           lifecycle_1.0.1        
[19] crayon_1.5.1            IRdisplay_1.1           repr_1.1.4             
[22] codetools_0.2-18        base64enc_0.1-3         vctrs_0.4.1            
[25] IRkernel_1.3            glue_1.6.2              evaluate_0.15          
[28] sp_1.5-0                pbdZMQ_0.3-7            compiler_4.2.1         
[31] pillar_1.8.0            backports_1.4.1         jsonlite_1.8.0         
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant