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

beat sample Laquila error #58

Open
rzinke opened this issue Sep 6, 2020 · 21 comments
Open

beat sample Laquila error #58

rzinke opened this issue Sep 6, 2020 · 21 comments

Comments

@rzinke
Copy link

rzinke commented Sep 6, 2020

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
Copy link
Author

rzinke commented Sep 6, 2020

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-x86_64.egg/beat/apps/beat.py", line 1686, in main
globals()'command_' + command
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
Copy link
Owner

hvasbath commented Sep 7, 2020

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
Copy link
Author

rzinke commented Sep 8, 2020

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
Copy link
Author

rzinke commented Sep 8, 2020

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
Copy link
Collaborator

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
Copy link
Owner

hvasbath commented Sep 9, 2020

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
Copy link
Owner

hvasbath commented Sep 9, 2020

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

@rzinke
Copy link
Author

rzinke commented Sep 9, 2020

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
Copy link
Owner

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
Copy link
Author

rzinke commented Sep 10, 2020

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

@hvasbath
Copy link
Owner

hvasbath commented Sep 10, 2020

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

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

@rzinke
Copy link
Author

rzinke commented Sep 10, 2020

Thanks, Hannes. I'll take a look!

@hvasbath hvasbath closed this as completed Feb 1, 2021
@samwimpenny
Copy link

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 hvasbath reopened this Feb 19, 2022
@hvasbath
Copy link
Owner

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
Copy link

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
Copy link
Owner

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

@hvasbath
Copy link
Owner

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
Copy link

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
Copy link
Owner

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
Copy link
Owner

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

  • I create an environment using python3.8
  • I have installed everything always using CXX=g++ CC=gcc LD=g++ (in my case gcc-12): pip and python
  • I have installed numpy==1.22.4 and wheel
  • I have installed pyrocko (through pyrocko install script)
  • I have installed Theano
  • I have installed beat, using pip
  • I have created in my home the .theanorc with the following commands:

[global]

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

@hvasbath
Copy link
Owner

hvasbath commented May 2, 2024

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

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

4 participants