hvasbath / beat

Bayesian Earthquake Analysis Tool
GNU General Public License v3.0
132 stars 42 forks source link

beat sample Laquila error #58

Closed rzinke closed 3 days ago

rzinke commented 4 years ago

Hello,

I am trying to complete Example 3[https://hvasbath.github.io/beat/examples/Rectangular.html] from the tutorial. I have completed part of the tutorial, however, when I attempt to run beat sample Laquila I get an error message that I have trouble interpreting. The message is quite long, and in addition to pasting it below, I have attached it in a text file if that is easier to read.

I have also included my config_geometry.yaml file if that helps.

I am using a Mac running Mojave 10.14.6.

Please let me know where to start fixing this, and how I can help troubleshoot!

beat sample Laquila Error.txt

config_geometry.txt

rzinke commented 4 years ago

Here is the full message: (beat) MT-109587:BEATexamples rzinke$ beat sample Laquila config - INFO All hierarchicals ok! config - INFO All hyperparameters ok! config - INFO All priors ok! models - INFO ... Initialising Geometry Optimizer ...

models - INFO Analysing problem ... models - INFO ---------------------

geodetic - INFO Number of geodetic datasets: 2 geodetic - INFO Number of geodetic data points: 419 geodetic - WARNING Covariance estimation not implemented (yet)! Using imported covariances! geodetic - INFO Fit residual ramp selected! heart - INFO Consistent number of datasets and targets in any_P_0 wavemap! heart - INFO Number of seismic datasets for wavemap: any_P_0: 35 models - INFO ... Building model ...

models - INFO Optimization for 3 hyperparameters in total! geodetic - INFO Geodetic optimization on: depth, dip, east_shift, length, north_shift, rake, slip, strike, width

You can find the C code in this temporary file: /var/folders/5c/g4x7qt9s26gc2x5yj1dtynmh0000gp/T/theano_compilation_error_ybz83ftz Traceback (most recent call last): File "/Users/rzinke/opt/miniconda3/envs/beat/bin/beat", line 33, in sys.exit(load_entry_point('beat==1.0', 'console_scripts', 'beat')()) File "/Users/rzinke/opt/miniconda3/envs/beat/lib/python3.6/site-packages/beat-1.0-py3.6-macosx-10.9-x8664.egg/beat/apps/beat.py", line 1686, in main globals()['command' + command](args) File "/Users/rzinke/opt/miniconda3/envs/beat/lib/python3.6/site-packages/beat-1.0-py3.6-macosx-10.9-x86_64.egg/beat/apps/beat.py", line 768, in command_sample project_dir, options.mode, options.hypers) File "/Users/rzinke/opt/miniconda3/envs/beat/lib/python3.6/site-packages/beat-1.0-py3.6-macosx-10.9-x86_64.egg/beat/models/problems.py", line 844, in load_model problem.built_model() File "/Users/rzinke/opt/miniconda3/envs/beat/lib/python3.6/site-packages/beat-1.0-py3.6-macosx-10.9-x86_64.egg/beat/models/problems.py", line 228, in built_model input_rvs, fixed_rvs, self.hyperparams, pc) File "/Users/rzinke/opt/miniconda3/envs/beat/lib/python3.6/site-packages/beat-1.0-py3.6-macosx-10.9-x86_64.egg/beat/models/geodetic.py", line 427, in get_formula los_disp = (disp * self.slos_vectors).sum(axis=1) File "/Users/rzinke/opt/miniconda3/envs/beat/lib/python3.6/site-packages/theano/tensor/var.py", line 155, in mul return theano.tensor.mul(self, other) File "/Users/rzinke/opt/miniconda3/envs/beat/lib/python3.6/site-packages/theano/gof/op.py", line 670, in call no_recycling=[]) File "/Users/rzinke/opt/miniconda3/envs/beat/lib/python3.6/site-packages/theano/gof/op.py", line 955, in make_thunk no_recycling) File "/Users/rzinke/opt/miniconda3/envs/beat/lib/python3.6/site-packages/theano/gof/op.py", line 858, in make_c_thunk output_storage=node_output_storage) File "/Users/rzinke/opt/miniconda3/envs/beat/lib/python3.6/site-packages/theano/gof/cc.py", line 1217, in make_thunk keep_lock=keep_lock) File "/Users/rzinke/opt/miniconda3/envs/beat/lib/python3.6/site-packages/theano/gof/cc.py", line 1157, in compile keep_lock=keep_lock) File "/Users/rzinke/opt/miniconda3/envs/beat/lib/python3.6/site-packages/theano/gof/cc.py", line 1624, in cthunk_factory key=key, lnk=self, keep_lock=keep_lock) File "/Users/rzinke/opt/miniconda3/envs/beat/lib/python3.6/site-packages/theano/gof/cmodule.py", line 1189, in module_from_key module = lnk.compile_cmodule(location) File "/Users/rzinke/opt/miniconda3/envs/beat/lib/python3.6/site-packages/theano/gof/cc.py", line 1527, in compile_cmodule preargs=preargs) File "/Users/rzinke/opt/miniconda3/envs/beat/lib/python3.6/site-packages/theano/gof/cmodule.py", line 2399, in compile_str (status, compile_stderr.replace('\n', '. '))) Exception: ("Compilation failed (return status=1): /Users/rzinke/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.6.10-64/tmpz3oo8r2l/mod.cpp:572:27: error: non-constant-expression cannot be narrowed from type 'npy_intp' (aka 'long') to 'int' in initializer list [-Wc++11-narrowing]. int init_totals[2] = {V3_n0, V3_n1};. ^~~. /Users/rzinke/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.6.10-64/tmpz3oo8r2l/mod.cpp:572:27: note: insert an explicit cast to silence this issue. int init_totals[2] = {V3_n0, V3_n1};. ^. static_cast( ). /Users/rzinke/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.6.10-64/tmpz3oo8r2l/mod.cpp:572:34: error: non-constant-expression cannot be narrowed from type 'npy_intp' (aka 'long') to 'int' in initializer list [-Wc++11-narrowing]. int init_totals[2] = {V3_n0, V3_n1};. ^. /Users/rzinke/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.6.10-64/tmpz3oo8r2l/mod.cpp:572:34: note: insert an explicit cast to silence this issue. int init_totals[2] = {V3_n0, V3_n1};. ^. static_cast( ). /Users/rzinke/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.6.10-64/tmpz3oo8r2l/mod.cpp:584:9: error: non-constant-expression cannot be narrowed from type 'ssize_t' (aka 'long') to 'int' in initializer list [-Wc++11-narrowing]. V3_stride0, V3_stride1, . ^~. /Users/rzinke/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.6.10-64/tmpz3oo8r2l/mod.cpp:584:9: note: insert an explicit cast to silence this issue. V3_stride0, V3_stride1, . ^~. static_cast( ). /Users/rzinke/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.6.10-64/tmpz3oo8r2l/mod.cpp:584:21: error: non-constant-expression cannot be narrowed from type 'ssize_t' (aka 'long') to 'int' in initializer list [-Wc++11-narrowing]. V3_stride0, V3_stride1, . ^~. /Users/rzinke/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.6.10-64/tmpz3oo8r2l/mod.cpp:584:21: note: insert an explicit cast to silence this issue. V3_stride0, V3_stride1, . ^~. static_cast( ). /Users/rzinke/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.6.10-64/tmpz3oo8r2l/mod.cpp:585:1: error: non-constant-expression cannot be narrowed from type 'ssize_t' (aka 'long') to 'int' in initializer list [-Wc++11-narrowing]. V5_stride0, V5_stride1, . ^~. /Users/rzinke/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.6.10-64/tmpz3oo8r2l/mod.cpp:585:1: note: insert an explicit cast to silence this issue. V5_stride0, V5_stride1, . ^~. static_cast( ). /Users/rzinke/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.6.10-64/tmpz3oo8r2l/mod.cpp:585:13: error: non-constant-expression cannot be narrowed from type 'ssize_t' (aka 'long') to 'int' in initializer list [-Wc++11-narrowing]. V5_stride0, V5_stride1, . ^~. /Users/rzinke/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.6.10-64/tmpz3oo8r2l/mod.cpp:585:13: note: insert an explicit cast to silence this issue. V5_stride0, V5_stride1, . ^~. static_cast( ). /Users/rzinke/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.6.10-64/tmpz3oo8r2l/mod.cpp:586:1: error: non-constant-expression cannot be narrowed from type 'ssize_t' (aka 'long') to 'int' in initializer list [-Wc++11-narrowing]. V1_stride0, V1_stride1. ^~. /Users/rzinke/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.6.10-64/tmpz3oo8r2l/mod.cpp:586:1: note: insert an explicit cast to silence this issue. V1_stride0, V1_stride1. ^~. static_cast( ). /Users/rzinke/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.6.10-64/tmpz3oo8r2l/mod.cpp:586:13: error: non-constant-expression cannot be narrowed from type 'ssize_t' (aka 'long') to 'int' in initializer list [-Wc++11-narrowing]. V1_stride0, V1_stride1. ^~. /Users/rzinke/.theano/compiledir_Darwin-18.7.0-x86_64-i386-64bit-i386-3.6.10-64/tmpz3oo8r2l/mod.cpp:586:13: note: insert an explicit cast to silence this issue. V1_stride0, V1_stride1. ^~~~. static_cast( ). 8 errors generated.. ", '[Elemwise{mul,no_inplace}(<TensorType(float64, matrix)>, los_vecs)]')

hvasbath commented 4 years ago

I never had that issue before. Theano cannot compile the function is what the error is saying. Similar to your earlier issues with compiling the fomosto programs it is likely a problem with finding and or linking your compiler. In this case gcc ... Can you run gcc successfully in your commandline?

rzinke commented 4 years ago

Hi @hvasbath, yes it appears so:

(beat) MT-109587:BEATexamples rzinke$ gcc
clang: error: no input files

It also seems that Theano works properly:

(beat) MT-109587:beat rzinke$ THEANO_FLAGS=mode=FAST_RUN,device=cpu,floatX=float32 python3 test/gpu_test.py
[Elemwise{exp,no_inplace}(<TensorType(float32, vector)>)]
Looping 1000 times took 0.874465 seconds
Result is [1.2317803 1.6187934 1.5227807 ... 2.2077181 2.2996776 1.6232328]
Used the cpu
rzinke commented 4 years ago

There were also some directory paths in the config_geometry.yaml file that I was unsure of. For example, where should

geodetic_config: !beat.GeodeticConfig
  datadir: /home/vasyurhm/BEATS/RectangularStatic/insar
  names:
  - Laquila_dscxn
  - Laquila_ascxn

point? I cannot find any files named Laquila_dscxn/ascxn. Should those already exist?

braunfuss commented 4 years ago

They are stored in the pickle file in the data geodetic_data.pkl. See https://hvasbath.github.io/beat/getting_started/import_data.html#insar. If you for some reason want the kite container data we uploaded them here: https://github.com/braunfuss/laquila_kite_container

To me this does not some like a beat issue but a installation issue on your side.

hvasbath commented 4 years ago

So gcc seems to be working fine and theano also compiles the simple example. What theano version are you using?

In [1]: import theano

In [2]: theano.version.full_version
Out[2]: '1.0.4'
hvasbath commented 4 years ago

Can you also please try to clear your theano cache with theano-cache purge

rzinke commented 4 years ago

My theano version is 1.0.4 After running theano-cahce purge in the shell, then rerunning beat sample Laquila, I still get the same error message.

hvasbath commented 4 years ago

hm I dont know- you will need to do some digging yourself in the theano forum and issues on github. I think its a compiler issue and goes in line with all these other compiler issues you reported ... You are the first one to report these ... its really strange

rzinke commented 4 years ago

Okay, thanks for your assistance looking into this @hvasbath. I'll let you know what I find out.

hvasbath commented 4 years ago

Here is an issue another person had, but already during import. Nevertheless you might be able to find some hints. https://github.com/Theano/Theano/issues/6645

Also there is this theano google group you could search for similar issues: https://groups.google.com/u/1/g/theano-users

rzinke commented 4 years ago

Thanks, Hannes. I'll take a look!

samwimpenny commented 2 years ago

Hi @rzinke - I was just wondering whether you found the solution to this issue, as I get the exact same compilation error when trying to run Example 3 of BEAT on Mac OS 12.0.1 Monterey? I installed BEAT through the Anaconda package manager following the website instructions, and everything else seems to work ok

Looks like it is something to do with Theano and not BEAT directly, but I cannot work out what it might be.

hvasbath commented 2 years ago

Hi @samwimpenny ,

does your gcc compiler work? Did you try some of the suggestions that are linked in the theano issue? Apparently, the theano version hosted on anaconda is mixing up the system linkers to different C compilers on macOS.

Proposed solutions: Try installing theano through pip (please make sure to uninstall the conda installed theano and to have the environment activated) then:

pip install theano 

For others creating symbolic links to the correct library helped:

https://stackoverflow.com/questions/58278260/cant-compile-a-c-program-on-a-mac-after-upgrading-to-catalina-10-15/58349403#58349403

samwimpenny commented 2 years ago

My gcc compiler seems to work fine:

(beat) MacBook-Pro-2:SLIPMODELS samwimpenny$ gcc clang: error: no input files

I first tried installing theano through pip. To remove theano from the conda environment I first just tried conda remove theano, but that wanted to remove a whole load of other dependencies, so I used conda remove theano --force.

I then ran pip install theano==1.0.4, which threw up a dependency warning:

... Successfully built theano ERROR: beat 1.1.1 has requirement matplotlib<=3.1.1, but you'll have matplotlib 3.3.4 which is incompatible. Installing collected packages: theano Successfully installed theano-1.0.4

Then trying to run beat sample Laquila just gives the same error as before.

I also tried the solutions from https://stackoverflow.com/questions/58278260/cant-compile-a-c-program-on-a-mac-after-upgrading-to-catalina-10-15/58349403#58349403 after removing and reinstalling beat from scratch through Anaconda. Sym-linking the C header library to /usr/include and explicitly setting the $CPATH to the directory with the C headers didn't seem to work either for me - I just get the same error @rzinke got again.

Not sure what else to do, but I'll keep looking.

hvasbath commented 2 years ago

I have a colleague who successfully installed it on anaconda with MAC I will ask him ...

hvasbath commented 2 years ago

Hi @samwimpenny unfortunately I didnt hear back from my colleague yet. Next week I will have a zoom call with him- I hope to ask him then. Do you have any update on that issue?

samwimpenny commented 2 years ago

No problem. I haven't made any progress yet, as I've been away for a couple of weeks. I'll be sure to let you know if I can get a workaround going.

hvasbath commented 1 year ago

We have been looking into that in more detail. Apparently, it has to do with newer MACs and clang as the default C compiler. We did not succeed getting it running. Likely theano is getting to old. The solution is to update BEAT to use pymc4. However, thats a major endeavour, but is needed for also other features that are planned. So eventually its going to happen at some point in time ... stay tuned.

hvasbath commented 1 year ago

One user @JJaraG managed to install it on M1 using:

[global]

cxx=/opt/homebrew/bin/g++

hvasbath commented 5 months ago

BEAT version 2 should be now easy and straightforward to be installed and executed. Theano dependency was dropped.