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

setting ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS from within R #336

Open
leonardocerliani opened this issue Jan 5, 2021 · 0 comments
Open

Comments

@leonardocerliani
Copy link

setting ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS appears not to be possible from within R

dear guys,

I am using ANTsR within RStudio (system info at the bottom).

I saw a previous thread where stnava was advising to set the
ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS in .Renviron. So I did and it works.

I was wondering however why the same cannot be done from within R.
My .Renviron reads: ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=5.

Now inside R I do:

Sys.setenv("ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS" = 10)
Sys.getenv("ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS")
> 10

However when I run an ANTsR registration, I see that I am still using 5 threads.
It would be really useful to set the number of threads from within the R script/markdown, so that all the information to re-run the registration (e.g. by a colleague) would be the same.

Can you help me with this?
Thank you in advance,

leonardo

sessionInfo()

R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS

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

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

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

other attached packages:
[1] misc3d_0.9-0 pixmap_0.4-11 neurobase_1.29.0 ANTsR_0.5.7.5 reticulate_1.18
[6] glue_1.4.2 oro.nifti_0.11.0 ANTsRCore_0.7.4.9

loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 rstudioapi_0.11 knitr_1.30 magrittr_1.5
[5] splines_3.6.3 rappdirs_0.3.1 lattice_0.20-41 rlang_0.4.8
[9] stringr_1.4.0 tcltk_3.6.3 tools_3.6.3 grid_3.6.3
[13] xfun_0.19 R.oo_1.24.0 htmltools_0.5.0 matrixStats_0.57.0
[17] yaml_2.2.1 digest_0.6.27 abind_1.4-5 crayon_1.3.4
[21] RcppEigen_0.3.3.7.0 Matrix_1.2-18 R.utils_2.10.1 bitops_1.0-6
[25] evaluate_0.14 rmarkdown_2.5 stringi_1.5.3 RNifti_1.3.0
[29] compiler_3.6.3 ITKR_0.5.3.3.0 R.methodsS3_1.8.1 jsonlite_1.7.1

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