Closed saumil-sh closed 1 year ago
Hi @saumil-sh -
Can you share a bit more about how you downloaded bridgestan and what commands you ran before receiving this error? We had an issue in the R example (https://github.com/roualdes/bridgestan/issues/121) which was fixed recently, but if you downloaded one of the .tar.gz from the GitHub releases page I do not believe it would have been updated yet.
I had a look at #121 before posting this and I belive it is a different issue.
I followed the documentation and used git clone --recurse-submodules https://github.com/roualdes/bridgestan.git
.
Here is the relevant lines of the output of my git log
commit 6dd7d3a8a80b9027145fb20d230aa86e5fcf99df (HEAD -> main, origin/main, origin/HEAD)
Author: Brian Ward <bward@flatironinstitute.org>
Date: Tue Jun 13 13:55:15 2023 -0400
Python: Warn if user has 5+ copies downloaded in .bridgestan (#128)
I am on Mac M1 running Ventura 13.4 and tested the installation according to the documentation running make test_models/multi/multi_model.so
from the root
directory of the repo.
Next, I created a mamba
/conda
environment using mamba create -n stan -c conda-forge
and installed r-base
and radian
. Then I followed the relevant documentation to install the R
bridgestan
package. Here is the relevant version information:
$ mamba --version
mamba 1.4.2
conda 23.3.1
$ mamba list | grep r-base
r-base 4.3.0 h4b3f977_1 conda-forge
$ mamba list | grep radian
radian 0.6.6 pyhd8ed1ab_0 conda-forge
$ radian
R version 4.3.0 (2023-04-21) -- "Already Tomorrow"
Platform: aarch64-apple-darwin20.0.0 (64-bit)
r$> install.packages(getwd(), repos=NULL, type="source")
.
.
.
* DONE (bridgestan)
r$> installed.packages()
Package LibPath Version Priority
base "base" "/Users/shah/mambaforge/envs/stan/lib/R/library" "4.3.0" "base"
bridgestan "bridgestan" "/Users/shah/mambaforge/envs/stan/lib/R/library" "2.0.0" NA
compiler "compiler" "/Users/shah/mambaforge/envs/stan/lib/R/library" "4.3.0" "base"
datasets "datasets" "/Users/shah/mambaforge/envs/stan/lib/R/library" "4.3.0" "base"
graphics "graphics" "/Users/shah/mambaforge/envs/stan/lib/R/library" "4.3.0" "base"
grDevices "grDevices" "/Users/shah/mambaforge/envs/stan/lib/R/library" "4.3.0" "base"
grid "grid" "/Users/shah/mambaforge/envs/stan/lib/R/library" "4.3.0" "base"
methods "methods" "/Users/shah/mambaforge/envs/stan/lib/R/library" "4.3.0" "base"
parallel "parallel" "/Users/shah/mambaforge/envs/stan/lib/R/library" "4.3.0" "base"
R6 "R6" "/Users/shah/mambaforge/envs/stan/lib/R/library" "2.5.1" NA
splines "splines" "/Users/shah/mambaforge/envs/stan/lib/R/library" "4.3.0" "base"
stats "stats" "/Users/shah/mambaforge/envs/stan/lib/R/library" "4.3.0" "base"
stats4 "stats4" "/Users/shah/mambaforge/envs/stan/lib/R/library" "4.3.0" "base"
tcltk "tcltk" "/Users/shah/mambaforge/envs/stan/lib/R/library" "4.3.0" "base"
tools "tools" "/Users/shah/mambaforge/envs/stan/lib/R/library" "4.3.0" "base"
utils "utils" "/Users/shah/mambaforge/envs/stan/lib/R/library" "4.3.0" "base"
I am aware of 2 ways of running an R
script, one using Rscript example.R
and another source("example.R")
from radian
both threw the same error mentioned in the first post in this thread.
Please let me know if I missed any information.
Did you build the bernoulli_model
library before running the example? If you were able to build the multi_model.so
file your installation is most likely working, but you may need to build the specific model the example is using first
I forgot to mention this. I did run make test_models/bernoulli/bernoulli_model.so
and if I run it again it says:
$make test_models/bernoulli/bernoulli_model.so
make: 'test_models/bernoulli/bernoulli_model.so' is up to date.
Should I "remake" it using the make -B
flag?
That all seems correct, then.
Could you try running the following command:
nm test_models/bernoulli/bernoulli_model.so | grep " bs_"
This should print out the names of the functions available in bernoulli_model
. It should be the case that bs_model_construct_R
is on this list, but it is good to check
I ran the following in the root
directory of the repository:
$nm test_models/bernoulli/bernoulli_model.so | grep _bs_
00000000000161ec T _bs_free_error_msg
00000000000161e4 T _bs_free_error_msg_R
0000000000016a7c T _bs_log_density
0000000000016a20 T _bs_log_density_R
0000000000016c5c T _bs_log_density_gradient
0000000000016c00 T _bs_log_density_gradient_R
0000000000016e38 T _bs_log_density_hessian
0000000000016de0 T _bs_log_density_hessian_R
000000000005c1b0 D _bs_major_version
000000000005c8c0 S _bs_minor_version
0000000000015f60 T _bs_model_construct
0000000000015f18 T _bs_model_construct_R
000000000001623c T _bs_model_destruct
0000000000016218 T _bs_model_destruct_R
0000000000016280 T _bs_model_info
0000000000016270 T _bs_model_info_R
0000000000016268 T _bs_name
0000000000016258 T _bs_name_R
0000000000016410 T _bs_param_constrain
00000000000163b0 T _bs_param_constrain_R
00000000000162cc T _bs_param_names
0000000000016288 T _bs_param_names_R
0000000000016360 T _bs_param_num
000000000001631c T _bs_param_num_R
0000000000016314 T _bs_param_unc_names
0000000000016304 T _bs_param_unc_names_R
00000000000163a8 T _bs_param_unc_num
0000000000016398 T _bs_param_unc_num_R
00000000000166d0 T _bs_param_unconstrain
000000000001668c T _bs_param_unconstrain_R
000000000001689c T _bs_param_unconstrain_json
0000000000016854 T _bs_param_unconstrain_json_R
000000000005c8c4 S _bs_patch_version
0000000000017000 T _bs_rng_construct
0000000000016fbc T _bs_rng_construct_R
000000000001720c T _bs_rng_destruct
00000000000171fc T _bs_rng_destruct_R
0000000000017218 T _bs_set_print_callback
00000000000161f0 T _bs_version_R
Can you share your C++ compiler version and how you installed it (xcode, brew, mamba, etc)? The output of nm
suggests it is mangling the C function names with a leading underscore. I've known of some macos compilers to do this, but it hasn't previously come up for us in this project.
You may be able to delete the model library and then use CXXFLAGS=-fno-leading-underscore make test_models/bernoulli/bernoulli_model.so
to fix this (to be verified either with nm
or with the example script), but it would be great to understand why this is occuring/why we haven't encountered it with other Macs we've used
It may also be worthwhile to test either the Python or Julia example if you are able to - it's possible the issue is that the build of R you installed is not properly handling the leading underscores which can appear in macos libraries
I will share my C++ compiler and relevant setup and I try your suggestions when I get to it tomorrow.
Python and Julia examples ran as expected. python:
$python example.py
This model's name is bernoulli_model.
It has 1 parameters.
log_density and gradient of Bernoulli model: (-27.455880681398384, array([-7.67408425]))
julia:
$julia -e 'using Pkg; Pkg.activate(".."); include("example.jl")'
Activating project at `/Volumes/shah/projects/reviews/bridgestan/bridgestan`
This model's name is bernoulli_model.
It has 1 parameters.
log_density and gradient of Bernoulli model: (-6.456684984700505, [-2.575183751495763])
Hey,
Here is relevant information about my setup:
When I try xcode-select --install
It directs me to I updated xcode using System Settings > Software Update
, and that is how I updated it just before cloning the repo.
$xcode-select --version
xcode-select version 2397.
clang
and make
were installed as the dependency in the mamba
environment I created.
$clang --version
clang version 16.0.5
Target: arm64-apple-darwin22.5.0
Thread model: posix
InstalledDir: /Users/shah/mambaforge/envs/stan/bin
$clang++ --version
clang version 16.0.5
Target: arm64-apple-darwin22.5.0
Thread model: posix
InstalledDir: /Users/shah/mambaforge/envs/stan/bin
$make --version
GNU Make 4.3
Built for arm64-apple-darwin20.0.0
The xcode
command line tools provide other compilers.
$g++ --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
I will rebuild with no leading underscore flag and let you know how it goes.
I ran make clean
and then built the multi
model again. There are 43 warnings generated, I am putting them here in case it may be useful.
```sh
$make test_models/multi/multi_model.so
curl -L https://github.com/stan-dev/stanc3/releases/download/v2.32.1/mac-stanc -o ./bin/stanc --retry 5 --retry-delay 10
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 10.8M 100 10.8M 0 0 9.8M 0 0:00:01 0:00:01 --:--:-- 28.7M
chmod +x ./bin/stanc
--- Compiling Stan bridge C++ code ---
arm64-apple-darwin20.0.0-clang++ -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem /Users/shah/mambaforge/envs/stan/include -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes -I ./stan/lib/stan_math/lib/tbb_2020.3/include -O3 -I ./stan/src -I ./stan/lib/rapidjson_1.1.0/ -I ./stan/lib/stan_math/ -I ./stan/lib/stan_math/lib/eigen_3.4.0 -I ./stan/lib/stan_math/lib/boost_1.78.0 -I ./stan/lib/stan_math/lib/sundials_6.1.1/include -I ./stan/lib/stan_math/lib/sundials_6.1.1/src/sundials -fPIC -D_FORTIFY_SOURCE=2 -isystem /Users/shah/mambaforge/envs/stan/include -DBOOST_DISABLE_ASSERTS -c -o src/bridgestan.o -Wl,-L,"/Volumes/shah/projects/reviews/bridgestan/bridgestan/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/Volumes/shah/projects/reviews/bridgestan/bridgestan/stan/lib/stan_math/lib/tbb" src/bridgestan.cpp
clang-16: warning: -Wl,-L,/Volumes/shah/projects/reviews/bridgestan/bridgestan/stan/lib/stan_math/lib/tbb: 'linker' input unused [-Wunused-command-line-argument]
clang-16: warning: -Wl,-rpath,/Volumes/shah/projects/reviews/bridgestan/bridgestan/stan/lib/stan_math/lib/tbb: 'linker' input unused [-Wunused-command-line-argument]
In file included from src/bridgestan.cpp:1:
In file included from src/bridgestan.h:5:
In file included from src/model_rng.hpp:4:
In file included from ./stan/src/stan/model/model_base.hpp:5:
In file included from ./stan/lib/stan_math/stan/math/rev/core.hpp:10:
In file included from ./stan/lib/stan_math/stan/math/rev/core/chainable_object.hpp:6:
In file included from ./stan/lib/stan_math/stan/math/rev/core/typedefs.hpp:7:
In file included from ./stan/lib/stan_math/stan/math/rev/core/Eigen_NumTraits.hpp:5:
In file included from ./stan/lib/stan_math/stan/math/prim/core.hpp:4:
In file included from ./stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:6:
In file included from ./stan/lib/stan_math/lib/boost_1.78.0/boost/lexical_cast.hpp:31:
In file included from ./stan/lib/stan_math/lib/boost_1.78.0/boost/lexical_cast/bad_lexical_cast.hpp:28:
In file included from ./stan/lib/stan_math/lib/boost_1.78.0/boost/throw_exception.hpp:24:
./stan/lib/stan_math/lib/boost_1.78.0/boost/assert/source_location.hpp:75:14: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
std::sprintf( buffer, ":%ld", static_cast
Hello, I am reviewing this package for submission at JOSS. When I tried to run the
example.R
file from thebridgestan/R
folder, I get the following error:My guess is that it originates here https://github.com/roualdes/bridgestan/blob/7267e83ad6a8f41ff2e65d49dfcc130c0137cf9e/R/example.R#L7, is something missing in this call https://github.com/roualdes/bridgestan/blob/7267e83ad6a8f41ff2e65d49dfcc130c0137cf9e/R/R/bridgestan.R#L42?