metrumresearchgroup / Torsten

library of C++ functions that support applications of Stan in Pharmacometrics
BSD 3-Clause "New" or "Revised" License
52 stars 11 forks source link

Compilation requires write access to the installation folder #34

Closed yendls closed 3 years ago

yendls commented 3 years ago

Hi Yi,

I have tried running "pk2cpt" example-model in a centos-8, gcc-8.3.1 and R-4.0.4 environment. When I run as a root user the execution goes through successfully as root has write access to all the locations. However, when running as a non-root user.. I am seeing the below errors, also below is the source code for pk2cpt example model..:

R version 4.0.4 (2021-02-15) -- "Lost Library Book" Copyright (C) 2021 The R Foundation for Statistical Computing Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R.

library("cmdstanr") This is cmdstanr version 0.4.0

  • Online documentation and vignettes at mc-stan.org/cmdstanr
  • Use set_cmdstan_path() to set the path to CmdStan
  • Use install_cmdstan() to install CmdStan set_cmdstan_path("/pkpd/Torsten/cmdstan") CmdStan path set to: /pkpd/Torsten/cmdstan file.dir <- file.path("/pkpd/Torsten", "example-models", "pk2cpt") file <- file.path(file.dir, "pk2cpt.stan") model <- cmdstan_model(file) : fatal error: opening dependency file stan/src/stan/model/model_header.d: Permission denied compilation terminated. : fatal error: opening dependency file src/cmdstan/main.d: Permission denied compilation terminated. mkdir: cannot create directory ‘bin/’: Permission denied make: *** [make/stanc:74: bin/stanc] Error 1 Error: An error occured during compilation! See the message above for more information. Execution halted

Source: library("cmdstanr") set_cmdstan_path("/pkpd/Torsten/cmdstan") file.dir <- file.path("./") file <- file.path(file.dir, "pk2cpt.stan") model <- cmdstan_model(file) fit <- model$sample(data = file.path(file.dir, "pk2cpt.data.R"), init = file.path(file.dir, "pk2cpt.init.R"), seed = 123, chains = 4, parallel_chains = 2, refresh = 500) bayesplot::mcmc_dens_overlay(fit$draws("CL"))

yizhang-yiz commented 3 years ago

fatal error: opening dependency file stan/src/stan/model/model_header.d: Permission denied

This line says you don't have write permission at path /pkpd/Torsten/cmdstan/. You can try to put Torsten somewhere you can write to, say, ~/pkpd/Torsten.

yendls commented 3 years ago

Can I know why does the compilation requires write access to the installation folder? and also do we have to compile all the models as part of the installation of Torsten? Please advise.

yizhang-yiz commented 3 years ago

It's related to how makefile works. You don't need to compile any model when building cmdstan. Torsten doesn't require installation per se, instead it asks for installed cmdstan. The error you see is when cmdstan requires write permission. For that reason I suggest put cmdstan in user's home directory.

yendls commented 3 years ago

I have tried out your suggestion where I placed cmdstan in the user writeable area user-readonly and "/home/resdonly". I am seeing the following:

library("cmdstanr") This is cmdstanr version 0.4.0

  • Online documentation and vignettes at mc-stan.org/cmdstanr
  • Use set_cmdstan_path() to set the path to CmdStan
  • Use install_cmdstan() to install CmdStan set_cmdstan_path("cmdstan") CmdStan path set to: /home/readonly/cmdstan file.dir <- file.path("/pkpd/Torsten", "example-models", "pk2cpt") file <- file.path(file.dir, "pk2cpt.stan") model <- cmdstan_model(file) Compiling Stan program... ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_nvecserial.a ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_cvodes.a ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_idas.a ar: creating stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_kinsol.a % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 619 100 619 0 0 1018 0 --:--:-- --:--:-- --:--:-- 1016 100 16.6M 100 16.6M 0 0 1314k 0 0:00:12 0:00:12 --:--:-- 2275k /home/readonly/cmdstan/stan/lib/stan_math/lib/tbb_2019_U8/build/Makefile.tbb:28: CONFIG: cfg=release arch=intel64 compiler=gcc target=linux runtime=cc8.3.1_libc2.28_kernel4.19.76 Warning message: In file.create(to[okay]) : cannot create file '/pkpd/Torsten/example-models/pk2cpt/pk2cpt', reason 'Permission denied'

The code is still trying to write the "/pkpd/Torsten/example-models/" location which is under the installation directory "/pkpd/Torsten"

yizhang-yiz commented 3 years ago

That's because the "pk2cpt" model is not moved. If you copy that model to your home directory it should work fine, same as now there's no longer

fatal error: opening dependency file stan/src/stan/model/model_header.d: Permission denied

error because the change you've made.