Closed LucaNap closed 1 year ago
I expect this is something to do with Theano not being able to find the relevant compilers and trying to fall back on pure-Python implementations for computations. Can you share more info about how you installed Python and starry and the versions of everything that you're using?
Hey @dfm , thanks for the reply! I am using miniconda3 (v4.13.0), and this is the simple code I have used for the setup:
conda create --name starry python==3.9.7 mkl-service -y
conda activate starry
pip install numpy==1.21.0 starry==1.2.0 tqdm corner jupyterlab ipykernel lightkurve
I have just installed Mingw64 through msys64 (latest version, on a 64bit Windows11 system), and CUDA drivers. Now after a couple of system restarts, the error seems to have changed to:
You can find the C code in this temporary file: C:\Users\L\AppData\Local\Temp\theano_compilation_error_n4wvqp32
library ine is not found.
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
Input In [3], in <cell line: 14>()
35 sys = starry.System(A, b)
36 # Our model for the flux
---> 37 flux_model = pm.Deterministic("flux_model", sys.flux(t))
39 # This is how we tell `pymc3` about our observations we are assuming they are ampally distributed about
40 # the true model. This line effectively defines our likelihood function.
41 pm.Normal("obs", flux_model, sd=folded_lc["flux_err"], observed=folded_lc["flux"])
File C:\Miniconda3\envs\starry\lib\site-packages\starry\kepler.py:1015, in System.flux(self, t, total, integrated)
1005 def flux(self, t, total=True, integrated=False):
1006 """Compute the system flux at times ``t``.
1007
1008 Args:
(...)
1013 from each body.
1014 """
-> 1015 X = self.design_matrix(t)
1017 # Weight the ylms by amplitude
1018 if self._reflected:
1019 # If we're doing reflected light, scale the amplitude of
1020 # each of the secondaries by the amplitude of the primary
1021 # (the illumination source).
File C:\Miniconda3\envs\starry\lib\site-packages\starry\kepler.py:914, in System.design_matrix(self, t)
895 def design_matrix(self, t):
896 """Compute the system flux design matrix at times ``t``.
897
898 .. note::
(...)
912 the design matrix in units of :py:attr:`time_unit`.
913 """
--> 914 return self.ops.X(
915 self._math.reshape(self._math.to_array_or_tensor(t), [-1])
916 * self._time_factor,
917 self._primary._r,
918 self._primary._m,
919 self._primary._prot,
920 self._primary._t0,
921 self._primary._theta0,
922 self._math.to_array_or_tensor(
923 1.0
924 ), # we treat `amp` seprately in `flux()`
925 getattr(
926 self._primary._map,
927 "_inc",
928 self._math.to_array_or_tensor(0.5 * np.pi),
929 ),
930 getattr(
931 self._primary._map, "_obl", self._math.to_array_or_tensor(0.0)
932 ),
933 getattr(
934 self._primary._map, "fproj", self._math.to_array_or_tensor(0.0)
935 ),
936 self._primary._map._u,
937 self._primary._map._f,
938 self._math.to_array_or_tensor(
939 [sec._r for sec in self._secondaries]
940 ),
941 self._math.to_array_or_tensor(
942 [sec._m for sec in self._secondaries]
943 ),
944 self._math.to_array_or_tensor(
945 [sec._prot for sec in self._secondaries]
946 ),
947 self._math.to_array_or_tensor(
948 [sec._t0 for sec in self._secondaries]
949 ),
950 self._math.to_array_or_tensor(
951 [sec._theta0 for sec in self._secondaries]
952 ),
953 self._get_periods(),
954 self._math.to_array_or_tensor(
955 [sec._ecc for sec in self._secondaries]
956 ),
957 self._math.to_array_or_tensor(
958 [sec._w for sec in self._secondaries]
959 ),
960 self._math.to_array_or_tensor(
961 [sec._Omega for sec in self._secondaries]
962 ),
963 self._math.to_array_or_tensor(
964 [sec._inc for sec in self._secondaries]
965 ),
966 self._math.to_array_or_tensor(
967 np.ones(
968 len(self._secondaries)
969 ) # we treat `amp` seprately in `flux()`
970 ),
971 self._math.to_array_or_tensor(
972 [
973 getattr(
974 sec._map,
975 "_inc",
976 self._math.to_array_or_tensor(0.5 * np.pi),
977 )
978 for sec in self._secondaries
979 ]
980 ),
981 self._math.to_array_or_tensor(
982 [
983 getattr(
984 sec._map, "_obl", self._math.to_array_or_tensor(0.0)
985 )
986 for sec in self._secondaries
987 ]
988 ),
989 self._math.to_array_or_tensor(
990 [sec._map._u for sec in self._secondaries]
991 ),
992 self._math.to_array_or_tensor(
993 [sec._map._f for sec in self._secondaries]
994 ),
995 self._math.to_array_or_tensor(
996 [
997 getattr(
998 sec._map, "_sigr", self._math.to_array_or_tensor(0.0)
999 )
1000 for sec in self._secondaries
1001 ]
1002 ),
1003 )
File C:\Miniconda3\envs\starry\lib\site-packages\starry\_core\utils.py:141, in autocompile.<locals>.wrapper(instance, *args)
135 @wraps(func) # inherit docstring
136 def wrapper(instance, *args):
138 if is_tensor(*args):
139
140 # Just return the function as is
--> 141 return func(instance, *args)
143 else:
144
145 # Determine the argument types
146 arg_types = tuple([_get_type(arg) for arg in args])
File C:\Miniconda3\envs\starry\lib\site-packages\starry\_core\core.py:2455, in OpsSystem.X(self, t, pri_r, pri_m, pri_prot, pri_t0, pri_theta0, pri_amp, pri_inc, pri_obl, pri_fproj, pri_u, pri_f, sec_r, sec_m, sec_prot, sec_t0, sec_theta0, sec_porb, sec_ecc, sec_w, sec_Omega, sec_iorb, sec_amp, sec_inc, sec_obl, sec_u, sec_f, sec_sigr)
2442 phase_pri = pri_amp * self.primary.map.ops.X(
2443 theta_pri,
2444 tt.zeros_like(t),
(...)
2452 pri_f,
2453 )
2454 else:
-> 2455 phase_pri = pri_amp * self.primary.map.ops.X(
2456 theta_pri,
2457 tt.zeros_like(t),
2458 tt.zeros_like(t),
2459 tt.zeros_like(t),
2460 math.to_tensor(0.0),
2461 pri_inc,
2462 pri_obl,
2463 pri_u,
2464 pri_f,
2465 )
2466 if self._reflected:
2467 phase_sec = [
2468 pri_amp
2469 * sec_amp[i]
(...)
2486 for i, sec in enumerate(self.secondaries)
2487 ]
File C:\Miniconda3\envs\starry\lib\site-packages\starry\_core\utils.py:141, in autocompile.<locals>.wrapper(instance, *args)
135 @wraps(func) # inherit docstring
136 def wrapper(instance, *args):
138 if is_tensor(*args):
139
140 # Just return the function as is
--> 141 return func(instance, *args)
143 else:
144
145 # Determine the argument types
146 arg_types = tuple([_get_type(arg) for arg in args])
File C:\Miniconda3\envs\starry\lib\site-packages\starry\_core\core.py:784, in OpsLD.X(self, theta, xo, yo, zo, ro, inc, obl, u, f)
775 @autocompile
776 def X(self, theta, xo, yo, zo, ro, inc, obl, u, f):
777 """
778 Convenience function for integration of limb-darkened maps
779 with the ``System`` class. The design matrix for limb-darkened
(...)
782
783 """
--> 784 flux = self.flux(xo, yo, zo, ro, u)
785 X = tt.reshape(flux, (-1, 1))
786 return X
File C:\Miniconda3\envs\starry\lib\site-packages\starry\_core\utils.py:141, in autocompile.<locals>.wrapper(instance, *args)
135 @wraps(func) # inherit docstring
136 def wrapper(instance, *args):
138 if is_tensor(*args):
139
140 # Just return the function as is
--> 141 return func(instance, *args)
143 else:
144
145 # Determine the argument types
146 arg_types = tuple([_get_type(arg) for arg in args])
File C:\Miniconda3\envs\starry\lib\site-packages\starry\_core\core.py:771, in OpsLD.flux(self, xo, yo, zo, ro, u)
768 los = zo[i_occ]
769 r = ro * tt.ones_like(los)
770 flux = tt.set_subtensor(
--> 771 flux[i_occ], self._limbdark(c_norm, b[i_occ], r, los)[0]
772 )
773 return flux
File ~\AppData\Roaming\Python\Python39\site-packages\theano\graph\op.py:253, in Op.__call__(self, *inputs, **kwargs)
250 node = self.make_node(*inputs, **kwargs)
252 if config.compute_test_value != "off":
--> 253 compute_test_value(node)
255 if self.default_output is not None:
256 rval = node.outputs[self.default_output]
File ~\AppData\Roaming\Python\Python39\site-packages\theano\graph\op.py:126, in compute_test_value(node)
123 compute_map[o] = [False]
125 # Create a thunk that performs the computation
--> 126 thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[])
127 thunk.inputs = [storage_map[v] for v in node.inputs]
128 thunk.outputs = [storage_map[v] for v in node.outputs]
File ~\AppData\Roaming\Python\Python39\site-packages\theano\graph\op.py:634, in COp.make_thunk(self, node, storage_map, compute_map, no_recycling, impl)
630 self.prepare_node(
631 node, storage_map=storage_map, compute_map=compute_map, impl="c"
632 )
633 try:
--> 634 return self.make_c_thunk(node, storage_map, compute_map, no_recycling)
635 except (NotImplementedError, MethodNotDefined):
636 # We requested the c code, so don't catch the error.
637 if impl == "c":
File ~\AppData\Roaming\Python\Python39\site-packages\theano\graph\op.py:600, in COp.make_c_thunk(self, node, storage_map, compute_map, no_recycling)
598 print(f"Disabling C code for {self} due to unsupported float16")
599 raise NotImplementedError("float16")
--> 600 outputs = cl.make_thunk(
601 input_storage=node_input_storage, output_storage=node_output_storage
602 )
603 thunk, node_input_filters, node_output_filters = outputs
605 def rval():
File ~\AppData\Roaming\Python\Python39\site-packages\theano\link\c\basic.py:1203, in CLinker.make_thunk(self, input_storage, output_storage, storage_map)
1175 """
1176 Compiles this linker's fgraph and returns a function to perform the
1177 computations, as well as lists of storage cells for both the inputs
(...)
1200 first_output = ostor[0].data
1201 """
1202 init_tasks, tasks = self.get_init_tasks()
-> 1203 cthunk, module, in_storage, out_storage, error_storage = self.__compile__(
1204 input_storage, output_storage, storage_map
1205 )
1207 res = _CThunk(cthunk, init_tasks, tasks, error_storage, module)
1208 res.nodes = self.node_order
File ~\AppData\Roaming\Python\Python39\site-packages\theano\link\c\basic.py:1138, in CLinker.__compile__(self, input_storage, output_storage, storage_map)
1136 input_storage = tuple(input_storage)
1137 output_storage = tuple(output_storage)
-> 1138 thunk, module = self.cthunk_factory(
1139 error_storage,
1140 input_storage,
1141 output_storage,
1142 storage_map,
1143 )
1144 return (
1145 thunk,
1146 module,
(...)
1155 error_storage,
1156 )
File ~\AppData\Roaming\Python\Python39\site-packages\theano\link\c\basic.py:1634, in CLinker.cthunk_factory(self, error_storage, in_storage, out_storage, storage_map)
1632 for node in self.node_order:
1633 node.op.prepare_node(node, storage_map, None, "c")
-> 1634 module = get_module_cache().module_from_key(key=key, lnk=self)
1636 vars = self.inputs + self.outputs + self.orphans
1637 # List of indices that should be ignored when passing the arguments
1638 # (basically, everything that the previous call to uniq eliminated)
File ~\AppData\Roaming\Python\Python39\site-packages\theano\link\c\cmodule.py:1191, in ModuleCache.module_from_key(self, key, lnk)
1189 try:
1190 location = dlimport_workdir(self.dirname)
-> 1191 module = lnk.compile_cmodule(location)
1192 name = module.__file__
1193 assert name.startswith(location)
File ~\AppData\Roaming\Python\Python39\site-packages\theano\link\c\basic.py:1543, in CLinker.compile_cmodule(self, location)
1541 try:
1542 _logger.debug(f"LOCATION {location}")
-> 1543 module = c_compiler.compile_str(
1544 module_name=mod.code_hash,
1545 src_code=src_code,
1546 location=location,
1547 include_dirs=self.header_dirs(),
1548 lib_dirs=self.lib_dirs(),
1549 libs=libs,
1550 preargs=preargs,
1551 )
1552 except Exception as e:
1553 e.args += (str(self.fgraph),)
File ~\AppData\Roaming\Python\Python39\site-packages\theano\link\c\cmodule.py:2546, in GCC_compiler.compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
2542 # We replace '\n' by '. ' in the error message because when Python
2543 # prints the exception, having '\n' in the text makes it more
2544 # difficult to read.
2545 compile_stderr = compile_stderr.replace("\n", ". ")
-> 2546 raise Exception(
2547 f"Compilation failed (return status={status}): {compile_stderr}"
2548 )
2549 elif config.cmodule__compilation_warning and compile_stderr:
2550 # Print errors just below the command line.
2551 print(compile_stderr)
Exception: ('Compilation failed (return status=1): In file included from C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\numpy\\core\\include/numpy/ndarraytypes.h:4,. from C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\numpy\\core\\include/numpy/ndarrayobject.h:12,. from C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\numpy\\core\\include/numpy/arrayobject.h:4,. from C:\\Users\\L\\AppData\\Local\\Theano\\compiledir_Windows-10-10.0.22000-SP0-Intel64_Family_6_Model_167_Stepping_1_GenuineIntel-3.9.7-64\\tmpicooiegn\\mod.cpp:5:. C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\numpy\\core\\include/numpy/npy_common.h:185:20: warning: \'int _fseeki64(FILE*, long long int, int)\' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]. 185 | extern int __cdecl _fseeki64(FILE *, long long, int);. | ^~~~~~~~~. C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\numpy\\core\\include/numpy/npy_common.h:186:26: warning: \'long long int _ftelli64(FILE*)\' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]. 186 | extern long long __cdecl _ftelli64(FILE *);. | ^~~~~~~~~. In file included from C:\\Users\\L\\AppData\\Local\\Theano\\compiledir_Windows-10-10.0.22000-SP0-Intel64_Family_6_Model_167_Stepping_1_GenuineIntel-3.9.7-64\\tmpicooiegn\\mod.cpp:9:. C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\starry\\_core\\ops\\lib\\include/limbdark.h: In instantiation of \'void starry::limbdark::GreensLimbDark<T>::downwardM() [with T = double]\':. C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\starry\\_core\\ops\\lib\\include/limbdark.h:654:5: required from \'void starry::limbdark::GreensLimbDark<T>::compute(const T&, const T&) [with bool GRADIENT = true; T = double]\'. C:\\Users\\L\\AppData\\Local\\Theano\\compiledir_Windows-10-10.0.22000-SP0-Intel64_Family_6_Model_167_Stepping_1_GenuineIntel-3.9.7-64\\tmpicooiegn\\mod.cpp:132:50: required from here. C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\starry\\_core\\ops\\lib\\include/limbdark.h:368:5: error: exception handling disabled, use \'-fexceptions\' to enable. 368 | throw std::runtime_error(. | ^~~~~~~~~~~~~~~~~~~~~~~~~. 369 | "Downward recursion in `M` not implemented for `k^2` >= 1.");. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~. In file included from C:\\Users\\L\\AppData\\Local\\Theano\\compiledir_Windows-10-10.0.22000-SP0-Intel64_Family_6_Model_167_Stepping_1_GenuineIntel-3.9.7-64\\tmpicooiegn\\mod.cpp:8:. C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\starry\\_core\\ops\\lib\\include/ellip.h: In function \'T starry::ellip::CEL(T, T, T, T, T) [with T = double]\':. C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\starry\\_core\\ops\\lib\\include/ellip.h:104:1: warning: control reaches end of non-void function [-Wreturn-type]. 104 | }. | ^. At global scope:. cc1plus.exe: note: unrecognized command-line option \'-Wno-c++11-narrowing\' may have been intended to silence earlier diagnostics. ', 'FunctionGraph(*1 -> LimbDarkOp(<TensorType(float64, vector)>, <TensorType(float64, vector)>, <TensorType(float64, vector)>, <TensorType(float64, vector)>), *1::1, *1::2, *1::3)')
I am also attaching the theano compilation error file.
Great - that's more like something we can handle! It looks like you'll want to add -fexceptions
as a compile flag. You can probably do something like:
import theano
theano.config.gcc__cxxflags += " -fexceptions"
Probably best to do that before importing starry.
I have tried to do that (since there was a similar suggestion in another thread), but the same, or similar, error appears:
You can find the C code in this temporary file: C:\Users\L\AppData\Local\Temp\theano_compilation_error_f57i0xjr
library ine is not found.
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
Input In [4], in <cell line: 12>()
33 sys = starry.System(A, b)
34 # Our model for the flux
---> 35 flux_model = pm.Deterministic("flux_model", sys.flux(t))
37 # This is how we tell `pymc3` about our observations we are assuming they are ampally distributed about
38 # the true model. This line effectively defines our likelihood function.
39 pm.Normal("obs", flux_model, sd=folded_lc["flux_err"], observed=folded_lc["flux"])
File C:\Miniconda3\envs\starry\lib\site-packages\starry\kepler.py:1015, in System.flux(self, t, total, integrated)
1005 def flux(self, t, total=True, integrated=False):
1006 """Compute the system flux at times ``t``.
1007
1008 Args:
(...)
1013 from each body.
1014 """
-> 1015 X = self.design_matrix(t)
1017 # Weight the ylms by amplitude
1018 if self._reflected:
1019 # If we're doing reflected light, scale the amplitude of
1020 # each of the secondaries by the amplitude of the primary
1021 # (the illumination source).
File C:\Miniconda3\envs\starry\lib\site-packages\starry\kepler.py:914, in System.design_matrix(self, t)
895 def design_matrix(self, t):
896 """Compute the system flux design matrix at times ``t``.
897
898 .. note::
(...)
912 the design matrix in units of :py:attr:`time_unit`.
913 """
--> 914 return self.ops.X(
915 self._math.reshape(self._math.to_array_or_tensor(t), [-1])
916 * self._time_factor,
917 self._primary._r,
918 self._primary._m,
919 self._primary._prot,
920 self._primary._t0,
921 self._primary._theta0,
922 self._math.to_array_or_tensor(
923 1.0
924 ), # we treat `amp` seprately in `flux()`
925 getattr(
926 self._primary._map,
927 "_inc",
928 self._math.to_array_or_tensor(0.5 * np.pi),
929 ),
930 getattr(
931 self._primary._map, "_obl", self._math.to_array_or_tensor(0.0)
932 ),
933 getattr(
934 self._primary._map, "fproj", self._math.to_array_or_tensor(0.0)
935 ),
936 self._primary._map._u,
937 self._primary._map._f,
938 self._math.to_array_or_tensor(
939 [sec._r for sec in self._secondaries]
940 ),
941 self._math.to_array_or_tensor(
942 [sec._m for sec in self._secondaries]
943 ),
944 self._math.to_array_or_tensor(
945 [sec._prot for sec in self._secondaries]
946 ),
947 self._math.to_array_or_tensor(
948 [sec._t0 for sec in self._secondaries]
949 ),
950 self._math.to_array_or_tensor(
951 [sec._theta0 for sec in self._secondaries]
952 ),
953 self._get_periods(),
954 self._math.to_array_or_tensor(
955 [sec._ecc for sec in self._secondaries]
956 ),
957 self._math.to_array_or_tensor(
958 [sec._w for sec in self._secondaries]
959 ),
960 self._math.to_array_or_tensor(
961 [sec._Omega for sec in self._secondaries]
962 ),
963 self._math.to_array_or_tensor(
964 [sec._inc for sec in self._secondaries]
965 ),
966 self._math.to_array_or_tensor(
967 np.ones(
968 len(self._secondaries)
969 ) # we treat `amp` seprately in `flux()`
970 ),
971 self._math.to_array_or_tensor(
972 [
973 getattr(
974 sec._map,
975 "_inc",
976 self._math.to_array_or_tensor(0.5 * np.pi),
977 )
978 for sec in self._secondaries
979 ]
980 ),
981 self._math.to_array_or_tensor(
982 [
983 getattr(
984 sec._map, "_obl", self._math.to_array_or_tensor(0.0)
985 )
986 for sec in self._secondaries
987 ]
988 ),
989 self._math.to_array_or_tensor(
990 [sec._map._u for sec in self._secondaries]
991 ),
992 self._math.to_array_or_tensor(
993 [sec._map._f for sec in self._secondaries]
994 ),
995 self._math.to_array_or_tensor(
996 [
997 getattr(
998 sec._map, "_sigr", self._math.to_array_or_tensor(0.0)
999 )
1000 for sec in self._secondaries
1001 ]
1002 ),
1003 )
File C:\Miniconda3\envs\starry\lib\site-packages\starry\_core\utils.py:141, in autocompile.<locals>.wrapper(instance, *args)
135 @wraps(func) # inherit docstring
136 def wrapper(instance, *args):
138 if is_tensor(*args):
139
140 # Just return the function as is
--> 141 return func(instance, *args)
143 else:
144
145 # Determine the argument types
146 arg_types = tuple([_get_type(arg) for arg in args])
File C:\Miniconda3\envs\starry\lib\site-packages\starry\_core\core.py:2455, in OpsSystem.X(self, t, pri_r, pri_m, pri_prot, pri_t0, pri_theta0, pri_amp, pri_inc, pri_obl, pri_fproj, pri_u, pri_f, sec_r, sec_m, sec_prot, sec_t0, sec_theta0, sec_porb, sec_ecc, sec_w, sec_Omega, sec_iorb, sec_amp, sec_inc, sec_obl, sec_u, sec_f, sec_sigr)
2442 phase_pri = pri_amp * self.primary.map.ops.X(
2443 theta_pri,
2444 tt.zeros_like(t),
(...)
2452 pri_f,
2453 )
2454 else:
-> 2455 phase_pri = pri_amp * self.primary.map.ops.X(
2456 theta_pri,
2457 tt.zeros_like(t),
2458 tt.zeros_like(t),
2459 tt.zeros_like(t),
2460 math.to_tensor(0.0),
2461 pri_inc,
2462 pri_obl,
2463 pri_u,
2464 pri_f,
2465 )
2466 if self._reflected:
2467 phase_sec = [
2468 pri_amp
2469 * sec_amp[i]
(...)
2486 for i, sec in enumerate(self.secondaries)
2487 ]
File C:\Miniconda3\envs\starry\lib\site-packages\starry\_core\utils.py:141, in autocompile.<locals>.wrapper(instance, *args)
135 @wraps(func) # inherit docstring
136 def wrapper(instance, *args):
138 if is_tensor(*args):
139
140 # Just return the function as is
--> 141 return func(instance, *args)
143 else:
144
145 # Determine the argument types
146 arg_types = tuple([_get_type(arg) for arg in args])
File C:\Miniconda3\envs\starry\lib\site-packages\starry\_core\core.py:784, in OpsLD.X(self, theta, xo, yo, zo, ro, inc, obl, u, f)
775 @autocompile
776 def X(self, theta, xo, yo, zo, ro, inc, obl, u, f):
777 """
778 Convenience function for integration of limb-darkened maps
779 with the ``System`` class. The design matrix for limb-darkened
(...)
782
783 """
--> 784 flux = self.flux(xo, yo, zo, ro, u)
785 X = tt.reshape(flux, (-1, 1))
786 return X
File C:\Miniconda3\envs\starry\lib\site-packages\starry\_core\utils.py:141, in autocompile.<locals>.wrapper(instance, *args)
135 @wraps(func) # inherit docstring
136 def wrapper(instance, *args):
138 if is_tensor(*args):
139
140 # Just return the function as is
--> 141 return func(instance, *args)
143 else:
144
145 # Determine the argument types
146 arg_types = tuple([_get_type(arg) for arg in args])
File C:\Miniconda3\envs\starry\lib\site-packages\starry\_core\core.py:771, in OpsLD.flux(self, xo, yo, zo, ro, u)
768 los = zo[i_occ]
769 r = ro * tt.ones_like(los)
770 flux = tt.set_subtensor(
--> 771 flux[i_occ], self._limbdark(c_norm, b[i_occ], r, los)[0]
772 )
773 return flux
File ~\AppData\Roaming\Python\Python39\site-packages\theano\graph\op.py:253, in Op.__call__(self, *inputs, **kwargs)
250 node = self.make_node(*inputs, **kwargs)
252 if config.compute_test_value != "off":
--> 253 compute_test_value(node)
255 if self.default_output is not None:
256 rval = node.outputs[self.default_output]
File ~\AppData\Roaming\Python\Python39\site-packages\theano\graph\op.py:126, in compute_test_value(node)
123 compute_map[o] = [False]
125 # Create a thunk that performs the computation
--> 126 thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[])
127 thunk.inputs = [storage_map[v] for v in node.inputs]
128 thunk.outputs = [storage_map[v] for v in node.outputs]
File ~\AppData\Roaming\Python\Python39\site-packages\theano\graph\op.py:634, in COp.make_thunk(self, node, storage_map, compute_map, no_recycling, impl)
630 self.prepare_node(
631 node, storage_map=storage_map, compute_map=compute_map, impl="c"
632 )
633 try:
--> 634 return self.make_c_thunk(node, storage_map, compute_map, no_recycling)
635 except (NotImplementedError, MethodNotDefined):
636 # We requested the c code, so don't catch the error.
637 if impl == "c":
File ~\AppData\Roaming\Python\Python39\site-packages\theano\graph\op.py:600, in COp.make_c_thunk(self, node, storage_map, compute_map, no_recycling)
598 print(f"Disabling C code for {self} due to unsupported float16")
599 raise NotImplementedError("float16")
--> 600 outputs = cl.make_thunk(
601 input_storage=node_input_storage, output_storage=node_output_storage
602 )
603 thunk, node_input_filters, node_output_filters = outputs
605 def rval():
File ~\AppData\Roaming\Python\Python39\site-packages\theano\link\c\basic.py:1203, in CLinker.make_thunk(self, input_storage, output_storage, storage_map)
1175 """
1176 Compiles this linker's fgraph and returns a function to perform the
1177 computations, as well as lists of storage cells for both the inputs
(...)
1200 first_output = ostor[0].data
1201 """
1202 init_tasks, tasks = self.get_init_tasks()
-> 1203 cthunk, module, in_storage, out_storage, error_storage = self.__compile__(
1204 input_storage, output_storage, storage_map
1205 )
1207 res = _CThunk(cthunk, init_tasks, tasks, error_storage, module)
1208 res.nodes = self.node_order
File ~\AppData\Roaming\Python\Python39\site-packages\theano\link\c\basic.py:1138, in CLinker.__compile__(self, input_storage, output_storage, storage_map)
1136 input_storage = tuple(input_storage)
1137 output_storage = tuple(output_storage)
-> 1138 thunk, module = self.cthunk_factory(
1139 error_storage,
1140 input_storage,
1141 output_storage,
1142 storage_map,
1143 )
1144 return (
1145 thunk,
1146 module,
(...)
1155 error_storage,
1156 )
File ~\AppData\Roaming\Python\Python39\site-packages\theano\link\c\basic.py:1634, in CLinker.cthunk_factory(self, error_storage, in_storage, out_storage, storage_map)
1632 for node in self.node_order:
1633 node.op.prepare_node(node, storage_map, None, "c")
-> 1634 module = get_module_cache().module_from_key(key=key, lnk=self)
1636 vars = self.inputs + self.outputs + self.orphans
1637 # List of indices that should be ignored when passing the arguments
1638 # (basically, everything that the previous call to uniq eliminated)
File ~\AppData\Roaming\Python\Python39\site-packages\theano\link\c\cmodule.py:1191, in ModuleCache.module_from_key(self, key, lnk)
1189 try:
1190 location = dlimport_workdir(self.dirname)
-> 1191 module = lnk.compile_cmodule(location)
1192 name = module.__file__
1193 assert name.startswith(location)
File ~\AppData\Roaming\Python\Python39\site-packages\theano\link\c\basic.py:1543, in CLinker.compile_cmodule(self, location)
1541 try:
1542 _logger.debug(f"LOCATION {location}")
-> 1543 module = c_compiler.compile_str(
1544 module_name=mod.code_hash,
1545 src_code=src_code,
1546 location=location,
1547 include_dirs=self.header_dirs(),
1548 lib_dirs=self.lib_dirs(),
1549 libs=libs,
1550 preargs=preargs,
1551 )
1552 except Exception as e:
1553 e.args += (str(self.fgraph),)
File ~\AppData\Roaming\Python\Python39\site-packages\theano\link\c\cmodule.py:2546, in GCC_compiler.compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
2542 # We replace '\n' by '. ' in the error message because when Python
2543 # prints the exception, having '\n' in the text makes it more
2544 # difficult to read.
2545 compile_stderr = compile_stderr.replace("\n", ". ")
-> 2546 raise Exception(
2547 f"Compilation failed (return status={status}): {compile_stderr}"
2548 )
2549 elif config.cmodule__compilation_warning and compile_stderr:
2550 # Print errors just below the command line.
2551 print(compile_stderr)
Exception: ('Compilation failed (return status=1): In file included from C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\numpy\\core\\include/numpy/ndarraytypes.h:4,. from C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\numpy\\core\\include/numpy/ndarrayobject.h:12,. from C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\numpy\\core\\include/numpy/arrayobject.h:4,. from C:\\Users\\L\\AppData\\Local\\Theano\\compiledir_Windows-10-10.0.22000-SP0-Intel64_Family_6_Model_167_Stepping_1_GenuineIntel-3.9.7-64\\tmpjh8_vuso\\mod.cpp:5:. C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\numpy\\core\\include/numpy/npy_common.h:185:20: warning: \'int _fseeki64(FILE*, long long int, int)\' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]. 185 | extern int __cdecl _fseeki64(FILE *, long long, int);. | ^~~~~~~~~. C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\numpy\\core\\include/numpy/npy_common.h:186:26: warning: \'long long int _ftelli64(FILE*)\' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]. 186 | extern long long __cdecl _ftelli64(FILE *);. | ^~~~~~~~~. In file included from C:\\Users\\L\\AppData\\Local\\Theano\\compiledir_Windows-10-10.0.22000-SP0-Intel64_Family_6_Model_167_Stepping_1_GenuineIntel-3.9.7-64\\tmpjh8_vuso\\mod.cpp:9:. C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\starry\\_core\\ops\\lib\\include/limbdark.h: In instantiation of \'void starry::limbdark::GreensLimbDark<T>::downwardM() [with T = double]\':. C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\starry\\_core\\ops\\lib\\include/limbdark.h:654:5: required from \'void starry::limbdark::GreensLimbDark<T>::compute(const T&, const T&) [with bool GRADIENT = true; T = double]\'. C:\\Users\\L\\AppData\\Local\\Theano\\compiledir_Windows-10-10.0.22000-SP0-Intel64_Family_6_Model_167_Stepping_1_GenuineIntel-3.9.7-64\\tmpjh8_vuso\\mod.cpp:132:50: required from here. C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\starry\\_core\\ops\\lib\\include/limbdark.h:368:5: error: exception handling disabled, use \'-fexceptions\' to enable. 368 | throw std::runtime_error(. | ^~~~~~~~~~~~~~~~~~~~~~~~~. 369 | "Downward recursion in `M` not implemented for `k^2` >= 1.");. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~. In file included from C:\\Users\\L\\AppData\\Local\\Theano\\compiledir_Windows-10-10.0.22000-SP0-Intel64_Family_6_Model_167_Stepping_1_GenuineIntel-3.9.7-64\\tmpjh8_vuso\\mod.cpp:8:. C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\starry\\_core\\ops\\lib\\include/ellip.h: In function \'T starry::ellip::CEL(T, T, T, T, T) [with T = double]\':. C:\\Miniconda3\\envs\\starry\\lib\\site-packages\\starry\\_core\\ops\\lib\\include/ellip.h:104:1: warning: control reaches end of non-void function [-Wreturn-type]. 104 | }. | ^. At global scope:. cc1plus.exe: note: unrecognized command-line option \'-Wno-c++11-narrowing\' may have been intended to silence earlier diagnostics. ', 'FunctionGraph(*1 -> LimbDarkOp(<TensorType(float64, vector)>, <TensorType(float64, vector)>, <TensorType(float64, vector)>, <TensorType(float64, vector)>), *1::1, *1::2, *1::3)')
Looks like the error message hasn't changed:
error: exception handling disabled, use \'-fexceptions\' to enable.
@dfm is right about the cause. I'll try to think of a workaround.
Yeah - if you look at the full error linked above you'll see that the -fno-exceptions
flag is being set somewhere.
It may be sensible to remove this exception from starry anyways since it would result in a segfault, I think!
Yeah. The exceptions date back to when we were using PyBind11, I think, which caught them and raised corresponding python exceptions. @dfm what's the proper way of raising an error in the c code of a theano op? Return some special flag and process it on the python side?
I have tried to clean the code by removing unnecessary lines and imports, and this is the exception I get now:
Exception: ("Compilation failed (return status=1): In file included from C:\Miniconda3\envs\starry\lib\site-packages\numpy\core\include/numpy/ndarraytypes.h:4,. from C:\Miniconda3\envs\starry\lib\site-packages\numpy\core\include/numpy/ndarrayobject.h:12,. from C:\Miniconda3\envs\starry\lib\site-packages\numpy\core\include/numpy/arrayobject.h:4,. from C:\Users\L\AppData\Local\Theano\compiledir_Windows-10-10.0.22000-SP0-Intel64_Family_6_Model_167_Stepping_1_GenuineIntel-3.9.7-64\tmpk_nwh1dx\mod.cpp:5:. C:\Miniconda3\envs\starry\lib\site-packages\numpy\core\include/numpy/npy_common.h:185:20: warning: 'int _fseeki64(FILE, long long int, int)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]. 185 | extern int __cdecl _fseeki64(FILE , long long, int);. | ^
~~. C:\Miniconda3\envs\starry\lib\site-packages\numpy\core\include/numpy/npy_common.h:186:26: warning: 'long long int _ftelli64(FILE)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]. 186 | extern long long __cdecl _ftelli64(FILE );. | ^~~. cc1plus.exe: note: unrecognized command-line option '-Wno-c++11-narrowing' may have been intended to silence earlier diagnostics. C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\L\AppData\Local\Temp\ccam8Hnx.o:C:/Users/L/AppData/Local/Theano/compiledir_Windows-10-10.0.22000-SP0-Intel64_Family_6_Model_167_Stepping_1_GenuineIntel-3.9.7-64/tmpk_nwh1dx/mod.cpp:225: undefined reference to__gxx_personality_sj0'\r. C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\\Users\\L\\AppData\\Local\\Temp\\ccam8Hnx.o: in function
__struct_compiled_op_mccc95d75578af596840a606c22be7031449765ef284e3db1bf1f87e8765d1b28_destructor':\r. C:/Users/L/AppData/Local/Theano/compiledir_Windows-10-10.0.22000-SP0-Intel64_Family_6_Model_167_Stepping_1_GenuineIntel-3.9.7-64/tmpk_nwh1dx/mod.cpp:225: undefined reference to_Unwind_SjLj_Register'\r. C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/L/AppData/Local/Theano/compiledir_Windows-10-10.0.22000-SP0-Intel64_Family_6_Model_167_Stepping_1_GenuineIntel-3.9.7-64/tmpk_nwh1dx/mod.cpp:227: undefined reference to
_Unwind_SjLj_Unregister'\r. collect2.exe: error: ld returned 1 exit status. ", 'FunctionGraph(Shape(v))')
If I just copy & paste the tutorial on the hot jupiter phase curve, I get this instead:
Exception: ('The following error happened while compiling the node', LimbDarkOp(TensorConstant{[ 0.114591...01909859]}, TensorConstant{[]}, TensorConstant{[]}, TensorConstant{[]}), '\n', 'Compilation failed (return status=1): In file included from C:\Miniconda3\envs\starry\lib\site-packages\numpy\core\include/numpy/ndarraytypes.h:4,. from C:\Miniconda3\envs\starry\lib\site-packages\numpy\core\include/numpy/ndarrayobject.h:12,. from C:\Miniconda3\envs\starry\lib\site-packages\numpy\core\include/numpy/arrayobject.h:4,. from C:\Users\L\AppData\Local\Theano\compiledir_Windows-10-10.0.22000-SP0-Intel64_Family_6_Model_167_Stepping_1_GenuineIntel-3.9.7-64\tmpmqdcls9n\mod.cpp:5:. C:\Miniconda3\envs\starry\lib\site-packages\numpy\core\include/numpy/npy_common.h:185:20: warning: \'int _fseeki64(FILE, long long int, int)\' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]. 185 | extern int __cdecl _fseeki64(FILE , long long, int);. | ^
~~. C:\Miniconda3\envs\starry\lib\site-packages\numpy\core\include/numpy/npy_common.h:186:26: warning: \'long long int _ftelli64(FILE)\' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]. 186 | extern long long __cdecl _ftelli64(FILE );. | ^~~. In file included from C:\Users\L\AppData\Local\Theano\compiledir_Windows-10-10.0.22000-SP0-Intel64_Family_6_Model_167_Stepping_1_GenuineIntel-3.9.7-64\tmpmqdcls9n\mod.cpp:9:. C:\Miniconda3\envs\starry\lib\site-packages\starry\_core\ops\lib\include/limbdark.h: In instantiation of \'void starry::limbdark::GreensLimbDark::downwardM() [with T = double]\':. C:\Miniconda3\envs\starry\lib\site-packages\starry\_core\ops\lib\include/limbdark.h:654:5: required from \'void starry::limbdark::GreensLimbDark ::compute(const T&, const T&) [with bool GRADIENT = true; T = double]\'. C:\Users\L\AppData\Local\Theano\compiledir_Windows-10-10.0.22000-SP0-Intel64_Family_6_Model_167_Stepping_1_GenuineIntel-3.9.7-64\tmpmqdcls9n\mod.cpp:130:50: required from here. C:\Miniconda3\envs\starry\lib\site-packages\starry\_core\ops\lib\include/limbdark.h:368:5: error: exception handling disabled, use \'-fexceptions\' to enable. 368 | throw std::runtime_error(. | ^ ~~~~~~. 369 | "Downward recursion inM
not implemented fork^2
>= 1.");. | ~~~~~~~~~~~~~~. In file included from C:\Users\L\AppData\Local\Theano\compiledir_Windows-10-10.0.22000-SP0-Intel64_Family_6_Model_167_Stepping_1_GenuineIntel-3.9.7-64\tmpmqdcls9n\mod.cpp:8:. C:\Miniconda3\envs\starry\lib\site-packages\starry\_core\ops\lib\include/ellip.h: In function \'T starry::ellip::CEL(T, T, T, T, T) [with T = double]\':. C:\Miniconda3\envs\starry\lib\site-packages\starry\_core\ops\lib\include/ellip.h:104:1: warning: control reaches end of non-void function [-Wreturn-type]. 104 | }. | ^. At global scope:. cc1plus.exe: note: unrecognized command-line option \'-Wno-c++11-narrowing\' may have been intended to silence earlier diagnostics. ', 'FunctionGraph(1 -> LimbDarkOp(TensorConstant{[ 0.114591...01909859]}, TensorConstant{[]}, TensorConstant{[]}, TensorConstant{[]}), 1::1, 1::2, 1::3)')
In this case I think we can just remove the exceptions since they shouldn't ever be hit given that we call it very carefully ;)
In the more general case, something like your suggestion @rodluger — handling the error in Python or in CPython here — but in this case it might be more trouble than it's worth to propagate the error all the way up manually.
OK, now compiling the theano C ops with exceptions disabled. @LucaNap can you try again with the version of starry on the main branch?
@rodluger , yes it works now! Thank you
Note that only the following order of setup worked (while others did raise errors, for example when I did not install the older version of starry first).
conda create --name starry python==3.9.7 mkl-service -y conda activate starry pip install numpy==1.21.0 starry tqdm corner jupyterlab ipykernel packaging lightkurve pip install git+https://github.com/rodluger/starry
Glad to hear. Unfortunately starry
is getting harder and harder for me to support as theano
falls apart with newer versions of numpy
, pymc
, gcc
, etc. So these issues are likely to pop up again. @dfm and I are talking about rewriting starry
in jax
and integrating it directly into exoplanet
-- I think that is the future of this code.
Hello,
I am trying to understand what the following error means and how can it be solved. For context, I am using anaconda on windows with the latest version of starry installed, and I am trying to fit the phase curve of an exoplanet.
Any help is appreciated!