Skip to content

Help Understanding Permission Denied Warning #793

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

Closed
brucejwittmann opened this issue May 20, 2025 · 10 comments
Closed

Help Understanding Permission Denied Warning #793

brucejwittmann opened this issue May 20, 2025 · 10 comments

Comments

@brucejwittmann
Copy link

I'm trying to deploy a model on a cluster and running into some odd warnings. Specifically, cmdstanpy returns the below:

17:08:10 - cmdstanpy - WARNING - g++ -std=c++17 -pthread -D_REENTRANT -Wno-sign-compare -Wno-ignored-attributes -Wno-class-memaccess     -DSTAN_THREADS -I /opt/conda/include/    -O3 -I src -I stan/src -I stan/lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.4.0 -I stan/lib/stan_math/lib/boost_1.84.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS   -DTBB_INTERFACE_NEW  -DTBB_INTERFACE_NEW     -c -MT src/cmdstan/main_threads.o -MM -E -MG -MP -MF src/cmdstan/main_threads.d src/cmdstan/main.cpp
<built-in>: fatal error: opening dependency file src/cmdstan/main_threads.d: Permission denied
compilation terminated.

I'm trying to understand why compilation terminated is just considered a warning. Even more confusing, the model seems to compile just fine--the code does not crash, but keeps going with sampling, which it certainly wouldn't do if compilation had failed.

So, my questions are, what is this compilation terminated warning talking about (I assume not my model?)? Should I be worried about it? How do I fix whatever is triggering it?

I've copied the relevant stdout up to when sampling actually begins. I'm running with O1 optimizations and STAN_THREADS=true; otherwise, no major deviations from the default sample arguments.

17:07:47 - cmdstanpy - INFO - compiling stan file /scratch/amlt_code/outputs/pdz/trans-1/pdz_trans-1_gamma_exponential.stan to exe file /scratch/amlt_code/outputs/pdz/trans-1/pdz_trans-1_gamma_exponential
17:08:10 - cmdstanpy - INFO - compiled model executable: /scratch/amlt_code/outputs/pdz/trans-1/pdz_trans-1_gamma_exponential
17:08:10 - cmdstanpy - WARNING - Stan compiler has produced 3 warnings:
17:08:10 - cmdstanpy - WARNING - g++ -std=c++17 -pthread -D_REENTRANT -Wno-sign-compare -Wno-ignored-attributes -Wno-class-memaccess     -DSTAN_THREADS -I /opt/conda/include/    -O3 -I src -I stan/src -I stan/lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.4.0 -I stan/lib/stan_math/lib/boost_1.84.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS   -DTBB_INTERFACE_NEW  -DTBB_INTERFACE_NEW     -c -MT src/cmdstan/main_threads.o -MM -E -MG -MP -MF src/cmdstan/main_threads.d src/cmdstan/main.cpp
<built-in>: fatal error: opening dependency file src/cmdstan/main_threads.d: Permission denied
compilation terminated.

--- Translating Stan model to C++ code ---
bin/stanc --filename-in-msg=pdz_trans-1_gamma_exponential.stan --warn-pedantic --O1 --include-paths=/opt/DMSStan/dms_stan/model/stan --o=/scratch/amlt_code/outputs/pdz/trans-1/pdz_trans-1_gamma_exponential.hpp /scratch/amlt_code/outputs/pdz/trans-1/pdz_trans-1_gamma_exponential.stan
Warning: The parameter theta_t0 has no priors. This means either no prior is
    provided, or the prior(s) depend on data variables. In the later case,
    this may be a false positive.
Warning: The parameter r has no priors. This means either no prior is
    provided, or the prior(s) depend on data variables. In the later case,
    this may be a false positive.
Warning: The parameter inv_r_mean has no priors. This means either no prior
    is provided, or the prior(s) depend on data variables. In the later case,
    this may be a false positive.

--- Compiling C++ code ---
g++ -std=c++17 -pthread -D_REENTRANT -Wno-sign-compare -Wno-ignored-attributes -Wno-class-memaccess     -DSTAN_THREADS -I /opt/conda/include/    -O3 -I src -I stan/src -I stan/lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.4.0 -I stan/lib/stan_math/lib/boost_1.84.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS   -DTBB_INTERFACE_NEW  -DTBB_INTERFACE_NEW     -c  -x c++ -o /scratch/amlt_code/outputs/pdz/trans-1/pdz_trans-1_gamma_exponential.o /scratch/amlt_code/outputs/pdz/trans-1/pdz_trans-1_gamma_exponential.hpp
In file included from stan/lib/stan_math/lib/boost_1.84.0/boost/numeric/ublas/traits.hpp:21,
                 from stan/lib/stan_math/lib/boost_1.84.0/boost/numeric/ublas/storage.hpp:27,
                 from stan/lib/stan_math/lib/boost_1.84.0/boost/numeric/ublas/vector.hpp:21,
                 from stan/lib/stan_math/lib/boost_1.84.0/boost/numeric/odeint/util/ublas_wrapper.hpp:23,
                 from stan/lib/stan_math/lib/boost_1.84.0/boost/numeric/odeint.hpp:25,
                 from stan/lib/stan_math/stan/math/prim/functor/ode_rk45.hpp:9,
                 from stan/lib/stan_math/stan/math/prim/functor/integrate_ode_rk45.hpp:6,
                 from stan/lib/stan_math/stan/math/prim/functor.hpp:16,
                 from stan/lib/stan_math/stan/math/rev/fun.hpp:189,
                 from stan/lib/stan_math/stan/math/rev.hpp:14,
                 from stan/lib/stan_math/stan/math.hpp:19,
                 from stan/src/stan/model/model_header.hpp:6,
                 from /scratch/amlt_code/outputs/pdz/trans-1/pdz_trans-1_gamma_exponential.hpp:2:
stan/lib/stan_math/lib/boost_1.84.0/boost/numeric/ublas/detail/iterator.hpp:111:21: warning: ‘template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator’ is deprecated [-Wdeprecated-declarations]
  111 |         public std::iterator<IC, T> {
      |                     ^~~~~~~~
In file included from /usr/include/c++/13/bits/stl_iterator_base_funcs.h:66,
                 from /usr/include/c++/13/string:47,
                 from /usr/include/c++/13/bits/locale_classes.h:40,
                 from /usr/include/c++/13/bits/ios_base.h:41,
                 from /usr/include/c++/13/ios:44,
                 from /usr/include/c++/13/istream:40,
                 from /usr/include/c++/13/sstream:40,
                 from stan/src/stan/io/var_context.hpp:4,
                 from stan/src/stan/model/model_base.hpp:7,
                 from stan/src/stan/model/model_header.hpp:4:
/usr/include/c++/13/bits/stl_iterator_base_types.h:127:34: note: declared here
  127 |     struct _GLIBCXX17_DEPRECATED iterator
      |                                  ^~~~~~~~
stan/lib/stan_math/lib/boost_1.84.0/boost/numeric/ublas/detail/iterator.hpp:149:21: warning: ‘template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator’ is deprecated [-Wdeprecated-declarations]
  149 |         public std::iterator<IC, T> {
      |                     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator_base_types.h:127:34: note: declared here
  127 |     struct _GLIBCXX17_DEPRECATED iterator
      |                                  ^~~~~~~~
stan/lib/stan_math/lib/boost_1.84.0/boost/numeric/ublas/detail/iterator.hpp:204:21: warning: ‘template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator’ is deprecated [-Wdeprecated-declarations]
  204 |         public std::iterator<IC, T> {
      |                     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator_base_types.h:127:34: note: declared here
  127 |     struct _GLIBCXX17_DEPRECATED iterator
      |                                  ^~~~~~~~

--- Linking model ---
g++ -std=c++17 -pthread -D_REENTRANT -Wno-sign-compare -Wno-ignored-attributes -Wno-class-memaccess     -DSTAN_THREADS -I /opt/conda/include/    -O3 -I src -I stan/src -I stan/lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.4.0 -I stan/lib/stan_math/lib/boost_1.84.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials    -DBOOST_DISABLE_ASSERTS   -DTBB_INTERFACE_NEW  -DTBB_INTERFACE_NEW          -Wl,-L,"/opt/conda/lib/" -Wl,--disable-new-dtags -Wl,-rpath,"/opt/conda/lib/"      /scratch/amlt_code/outputs/pdz/trans-1/pdz_trans-1_gamma_exponential.o src/cmdstan/main_threads.o       -ltbb   stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_cvodes.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_idas.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_kinsol.a   -o /scratch/amlt_code/outputs/pdz/trans-1/pdz_trans-1_gamma_exponential
rm /scratch/amlt_code/outputs/pdz/trans-1/pdz_trans-1_gamma_exponential.o /scratch/amlt_code/outputs/pdz/trans-1/pdz_trans-1_gamma_exponential.hpp

17:08:16 - cmdstanpy - INFO - CmdStan start processing
method = sample (Default)
sample
num_samples = 1000 (Default)
num_warmup = 3000
save_warmup = false (Default)
thin = 1 (Default)
adapt
engaged = true (Default)
gamma = 0.05 (Default)
delta = 0.8 (Default)
kappa = 0.75 (Default)
t0 = 10 (Default)
init_buffer = 75 (Default)
term_buffer = 50 (Default)
window = 25 (Default)
save_metric = false (Default)
algorithm = hmc (Default)
hmc
engine = nuts (Default)
nuts
max_depth = 10 (Default)
metric = diag_e (Default)
metric_file =  (Default)
stepsize = 1 (Default)
stepsize_jitter = 0 (Default)
num_chains = 4
id = 1 (Default)
data
file = /tmp/tmpefzhaouk/hm019zjt.json
init = /tmp/tmpefzhaouk/d7ngr8n7.json
random
seed = 1025
output
file = /scratch/amlt_code/outputs/pdz/trans-1/pdz_trans-1_gamma_exponential-20250520170816.csv
diagnostic_file =  (Default)
refresh = 10
sig_figs = -1 (Default)
profile_file = profile.csv (Default)
save_cmdstan_config = false (Default)
num_threads = 4 (Default)
@bob-carpenter
Copy link
Member

I'm trying to understand why compilation terminated is just considered a warning.

It's not a warning, it's fatal. That's a bug in our output message.

You can see that it's fatal from this report:

fatal error: opening dependency file src/cmdstan/main_threads.d: Permission denied

It's referencing the compilation of threading. You might be able to run just fine without threading. Did your eventual process work?

The root cause appears to be a permission problem on the cluster when trying to compile with threading. Can you check that your process has permission to read that file and that it exists? Clusters are often much more locked down. They can also have very slow I/O.

@brucejwittmann
Copy link
Author

brucejwittmann commented May 20, 2025

Thanks for the quick response, @bob-carpenter! Yes, I saw the fatal error part but was confused because everything seems to run normally afterward: The process is working (currently at warmup step 160) and the job seems to be running from a single thread (only one log file).

I'm assuming that that path is relative to my cmdstan installation? I'm running in a Docker container using a conda base environment to handle dependencies. From the base conda env, running the below

root@acb7167b93f4:/opt/conda# find . -wholename "*src/cmdstan/main_threads.d"

doesn't yield any results. Should it? I can find ./bin/cmdstan/src/cmdstan/main_threads.o, however.

@bob-carpenter
Copy link
Member

The path should be relative to wherever the command is running from. You don't need multi-threading to run Stan, which is why it's probably still working (and maybe that's why it was only listed as a WARNING? whatever the intent, that message was confusing). The .o is the object code file, whereas the .d file is a dependency file that maintains compiler state.

I'm not sure about how the conda is going to be structured. @WardBrian is our conda expert and will probably know if this is a real error or red herring.

@WardBrian
Copy link
Member

WardBrian commented May 20, 2025

This sounds like the kind of error that happens when cmdstan is being used from a read-only directory. We unfortunately do not support out-of-tree builds with our current build system. Are you installing cmdstan as part of the docker image build? That tends to leave things in unwritable folders by default at runtime.

I am surprised at the fact that the model still builds -- when I try to mark such a file as not-writable, I get the same <built-in>: fatal error: opening dependency file src/cmdstan/main.d: Permission denied style error, but then make halts and does not compile the model.
I suspect this is an issue with our build system's rather hacky way of doing the different builds for STAN_THREADS=true or not, where it isn't actually reading main_WHATEVER.d, but only the default main.d.

@brucejwittmann
Copy link
Author

I saw a few similar threads regarding read-only directories. It does seem to have some parallels.

cmdstan is being installed as part of the Docker build, yes. Looking at the permissions for the directory in question, it looks like only the owner has write access. Others just have read and executable permissions.

Image

I can play around with the permissions in my Docker image to see if that helps resolve anything. I don't get the same error when running the container locally, however, so my guess would be it's something to do with permissions on the cluster.
 
I can run with STAN_THREADS=false and see if that changes anything. Though, I suppose if everything's running its probably fine to just ignore the warning?

@WardBrian
Copy link
Member

I was able to recreate locally and I can confirm a few things:

  1. It's definitely a permissions issue
  2. There is a bug in the way we are detecting dependencies for objects like main_threads.o

But!

  1. You (@brucejwittmann) are safe to ignore this if you want. These dependency files are primarily there so that things get re-built if something changes, but since you're running in a locked down container and (presumably) don't plan on editing the Stan source code yourself, nothing should ever change enough to need a re-build.

Depending on how we fix this, it might mean a future version would really refuse to build (like I think you disabling STAN_THREADS might), not just print "fatal error" and then continue, so it might be worth figuring out permissions on your end, but you can also cross that bridge when you get to it if you prefer.

@brucejwittmann
Copy link
Author

All sounds good. Thank you both for your help!

A quick fix I suppose could also be just installing cmdstanpy/cmdstan as part of my job rather than in the container. It would add a little bit of overhead but should ensure writability.

I think I'll cross that bridge when I come to it though. If things are looking good for now, I'll just keep going as is.

BTW, is there a recommended version of c++ and/or cmdstan that I could use that would not trigger all those deprecation warnings on compilation?

@WardBrian
Copy link
Member

Unfortunately those are in our dependency Boost and aren't avoidable at the moment. As a user, you are free to set -w or -Wdeprecated-declarations to silence them

I have been trying off-and-on-again to update Boost to make them go away -- my latest attempt is here

@brucejwittmann
Copy link
Author

Just an update: Adding the below line to my Dockerfile removed the 'fatal error' message.

RUN chmod -R 777 /opt/conda/bin/cmdstan

So, confirming that it was indeed permissions on my end. My guess is that our cluster will not run as the root user by default in our images, meaning it does not have automatic write permissions in my environment. Adding the above grants those permissions to all users.

@WardBrian
Copy link
Member

Glad it is resolved!

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

3 participants