aesara-devs / aesara

Aesara is a Python library for defining, optimizing, and efficiently evaluating mathematical expressions involving multi-dimensional arrays.
https://aesara.readthedocs.io
Other
1.18k stars 155 forks source link

Failure to link with MLK_RT under Windows #1228

Closed maresb closed 1 year ago

maresb commented 1 year ago

Description of your problem or feature request

There is a report on Discourse about an issue from a Windows user regarding a linking problem. @lucianopaz believes the issue is related to #947:

@opherdonchin , if it’s anything like the issue that I mentioned, you won’t be able to fix it using ldflags. Those will get a -l prepend and won’t link properly. The PR where I had fixed the old issue did some things to link to the full path of the dynamic link library, but it had to do so in aesara itself. I think that you’ll have to open an issue in aesara to get this fixed. I can help out with this after Monday

Versions and main components

opherdonchin commented 1 year ago

@maresb asked me to post the aesara config here in hopes that it will provide insight. Let me know if any other information will be helpful.

Click for output of: ``` python -c "import aesara; print(aesara.config)" ``` floatX ({'float16', 'float32', 'float64'}) Doc: Default floating-point precision for python casts. Note: float16 support is experimental, use at your own risk. Value: float64 warn_float64 ({'pdb', 'raise', 'ignore', 'warn'}) Doc: Do an action when a tensor variable with float64 dtype is created. Value: ignore pickle_test_value (>) Doc: Dump test values while pickling model. If True, test values will be dumped with model. Value: True cast_policy ({'numpy+floatX', 'custom'}) Doc: Rules for implicit type casting Value: custom deterministic ({'default', 'more'}) Doc: If `more`, sometimes we will select some implementation that are more deterministic, but slower. Also see the dnn.conv.algo* flags to cover more cases. Value: default device (cpu) Doc: Default device for computations. only cpu is supported for now Value: cpu force_device (>) Doc: Raise an error if we can't use the specified device Value: False conv__assert_shape (>) Doc: If True, AbstractConv* ops will verify that user-provided shapes match the runtime shapes (debugging option, may slow down compilation) Value: False print_global_stats (>) Doc: Print some global statistics (time spent) at the end Value: False assert_no_cpu_op ({'pdb', 'raise', 'ignore', 'warn'}) Doc: Raise an error/warning if there is a CPU op in the computational graph. Value: ignore unpickle_function (>) Doc: Replace unpickled Aesara functions with None. This is useful to unpickle old graphs that pickled them when it shouldn't Value: True Doc: Default compilation mode Value: Mode cxx () Doc: The C++ compiler to use. Currently only g++ is supported, but supporting additional compilers should not be too difficult. If it is empty, no C++ code is compiled. Value: "C:\miniconda3\envs\pymc_env_stricter\Library\mingw-w64\bin\g++.exe" linker ({'cvm_nogc', 'vm', 'py', 'vm_nogc', 'c', 'c|py', 'c|py_nogc', 'cvm'}) Doc: Default linker used if the aesara flags mode is Mode Value: cvm allow_gc (>) Doc: Do we default to delete intermediate results during Aesara function calls? Doing so lowers the memory requirement, but asks that we reallocate memory at the next function call. This is implemented for the default linker, but may not work for all linkers. Value: True optimizer ({'fast_compile', 'merge', 'fast_run', 'o2', 'o3', 'o4', 'None', 'unsafe', 'o1'}) Doc: Default optimizer. If not None, will use this optimizer with the Mode Value: o4 optimizer_verbose (>) Doc: If True, we print all optimization being applied Value: False on_opt_error ({'pdb', 'raise', 'ignore', 'warn'}) Doc: What to do when an optimization crashes: warn and skip it, raise the exception, or fall into the pdb debugger. Value: warn nocleanup (>) Doc: Suppress the deletion of code files that did not compile cleanly Value: False on_unused_input ({'raise', 'ignore', 'warn'}) Doc: What to do if a variable in the 'inputs' list of aesara.function() is not used in the graph. Value: raise gcc__cxxflags () Doc: Extra compiler flags for gcc Value: cmodule__warn_no_version (>) Doc: If True, will print a warning when compiling one or more Op with C code that can't be cached because there is no c_code_cache_version() function associated to at least one of those Ops. Value: False cmodule__remove_gxx_opt (>) Doc: If True, will remove the -O* parameter passed to g++.This is useful to debug in gdb modules compiled by Aesara.The parameter -g is passed by default to g++ Value: False cmodule__compilation_warning (>) Doc: If True, will print compilation warnings. Value: False cmodule__preload_cache (>) Doc: If set to True, will preload the C module cache at import time Value: False cmodule__age_thresh_use () Doc: In seconds. The time after which Aesara won't reuse a compile c module. Value: 2073600 cmodule__debug (>) Doc: If True, define a DEBUG macro (if not exists) for any compiled C code. Value: False compile__wait () Doc: Time to wait before retrying to acquire the compile lock. Value: 5 compile__timeout () Doc: In seconds, time that a process will wait before deciding to override an existing lock. An override only happens when the existing lock is held by the same owner *and* has not been 'refreshed' by this owner for more than this period. Refreshes are done every half timeout period for running processes. Value: 120 ctc__root () Doc: Directory which contains the root of Baidu CTC library. It is assumed that the compiled library is either inside the build, lib or lib64 subdirectory, and the header inside the include directory. Value: tensor__cmp_sloppy () Doc: Relax aesara.tensor.math._allclose (0) not at all, (1) a bit, (2) more Value: 0 tensor__local_elemwise_fusion (>) Doc: Enable or not in fast_run mode(fast_run optimization) the elemwise fusion optimization Value: True lib__amblibm (>) Doc: Use amd's amdlibm numerical library Value: False tensor__insert_inplace_optimizer_validate_nb () Doc: -1: auto, if graph have less then 500 nodes 1, else 10 Value: -1 traceback__limit () Doc: The number of stack to trace. -1 mean all. Value: 8 traceback__compile_limit () Doc: The number of stack to trace to keep during compilation. -1 mean all. If greater then 0, will also make us save Aesara internal stack trace. Value: 0 experimental__local_alloc_elemwise (>) Doc: DEPRECATED: If True, enable the experimental optimization local_alloc_elemwise. Generates error if not True. Use optimizer_excluding=local_alloc_elemwise to disable. Value: True experimental__local_alloc_elemwise_assert (>) Doc: When the local_alloc_elemwise is applied, add an assert to highlight shape errors. Value: True warn__ignore_bug_before ({'0.8.1', '0.8', '0.6', '1.0.4', '0.9', 'None', '1.0.5', '1.0.3', '0.10', '0.3', '0.4', '1.0.2', 'all', '0.7', '1.0', '1.0.1', '0.4.1', '0.8.2', '0.5'}) Doc: If 'None', we warn about all Aesara bugs found by default. If 'all', we don't warn about Aesara bugs found by default. If a version, we print only the warnings relative to Aesara bugs found after that version. Warning for specific bugs can be configured with specific [warn] flags. Value: 0.9 exception_verbosity ({'low', 'high'}) Doc: If 'low', the text of exceptions will generally refer to apply nodes with short names such as Elemwise{add_no_inplace}. If 'high', some exceptions will also refer to apply nodes with long descriptions like: A. Elemwise{add_no_inplace} B. log_likelihood_v_given_h C. log_likelihood_h Value: low print_test_value (>) Doc: If 'True', the __eval__ of an Aesara variable will return its test_value when this is available. This has the practical conseguence that, e.g., in debugging `my_var` will print the same as `my_var.tag.test_value` when a test value is defined. Value: False compute_test_value ({'off', 'raise', 'pdb', 'ignore', 'warn'}) Doc: If 'True', Aesara will run each op at graph build time, using Constants, SharedVariables and the tag 'test_value' as inputs to the function. This helps the user track down problems in the graph before it gets optimized. Value: off compute_test_value_opt ({'off', 'raise', 'pdb', 'ignore', 'warn'}) Doc: For debugging Aesara optimization only. Same as compute_test_value, but is used during Aesara optimization Value: off check_input (>) Doc: Specify if types should check their input in their C code. It can be used to speed up compilation, reduce overhead (particularly for scalars) and reduce the number of generated C files. Value: True NanGuardMode__nan_is_error (>) Doc: Default value for nan_is_error Value: True NanGuardMode__inf_is_error (>) Doc: Default value for inf_is_error Value: True NanGuardMode__big_is_error (>) Doc: Default value for big_is_error Value: True NanGuardMode__action ({'pdb', 'raise', 'warn'}) Doc: What NanGuardMode does when it finds a problem Value: raise DebugMode__patience () Doc: Optimize graph this many times to detect inconsistency Value: 10 DebugMode__check_c (>) Doc: Run C implementations where possible Value: True DebugMode__check_py (>) Doc: Run Python implementations where possible Value: True DebugMode__check_finite (>) Doc: True -> complain about NaN/Inf results Value: True DebugMode__check_strides () Doc: Check that Python- and C-produced ndarrays have same strides. On difference: (0) - ignore, (1) warn, or (2) raise error Value: 0 DebugMode__warn_input_not_reused (>) Doc: Generate a warning when destroy_map or view_map says that an op works inplace, but the op did not reuse the input for its output. Value: True DebugMode__check_preallocated_output () Doc: Test thunks with pre-allocated memory as output storage. This is a list of strings separated by ":". Valid values are: "initial" (initial storage in storage map, happens with Scan),"previous" (previously-returned memory), "c_contiguous", "f_contiguous", "strided" (positive and negative strides), "wrong_size" (larger and smaller dimensions), and "ALL" (all of the above). Value: DebugMode__check_preallocated_output_ndim () Doc: When testing with "strided" preallocated output memory, test all combinations of strides over that number of (inner-most) dimensions. You may want to reduce that number to reduce memory or time usage, but it is advised to keep a minimum of 2. Value: 4 profiling__time_thunks (>) Doc: Time individual thunks when profiling Value: True profiling__n_apply () Doc: Number of Apply instances to print by default Value: 20 profiling__n_ops () Doc: Number of Ops to print by default Value: 20 profiling__output_line_width () Doc: Max line width for the profiling output Value: 512 profiling__min_memory_size () Doc: For the memory profile, do not print Apply nodes if the size of their outputs (in bytes) is lower than this threshold Value: 1024 profiling__min_peak_memory (>) Doc: The min peak memory usage of the order Value: False profiling__destination () Doc: File destination of the profiling output Value: stderr profiling__debugprint (>) Doc: Do a debugprint of the profiled functions Value: False profiling__ignore_first_call (>) Doc: Do we ignore the first call of an Aesara function. Value: False on_shape_error ({'raise', 'warn'}) Doc: warn: print a warning and use the default value. raise: raise an error Value: warn openmp (>) Doc: Allow (or not) parallel computation on the CPU with OpenMP. This is the default value used when creating an Op that supports OpenMP parallelization. It is preferable to define it via the Aesara configuration file ~/.aesararc or with the environment variable AESARA_FLAGS. Parallelization is only done for some operations that implement it, and even for operations that implement parallelism, each operation is free to respect this flag or not. You can control the number of threads used with the environment variable OMP_NUM_THREADS. If it is set to 1, we disable openmp in Aesara by default. Value: False openmp_elemwise_minsize () Doc: If OpenMP is enabled, this is the minimum size of vectors for which the openmp parallelization is enabled in element wise ops. Value: 200000 optimizer_excluding () Doc: When using the default mode, we will remove optimizer with these tags. Separate tags with ':'. Value: optimizer_including () Doc: When using the default mode, we will add optimizer with these tags. Separate tags with ':'. Value: optimizer_requiring () Doc: When using the default mode, we will require optimizer with these tags. Separate tags with ':'. Value: optdb__position_cutoff () Doc: Where to stop eariler during optimization. It represent the position of the optimizer where to stop. Value: inf optdb__max_use_ratio () Doc: A ratio that prevent infinite loop in EquilibriumGraphRewriter. Value: 8.0 cycle_detection ({'regular', 'fast'}) Doc: If cycle_detection is set to regular, most inplaces are allowed,but it is slower. If cycle_detection is set to faster, less inplacesare allowed, but it makes the compilation faster.The interaction of which one give the lower peak memory usage iscomplicated and not predictable, so if you are close to the peakmemory usage, triyng both could give you a small gain. Value: regular check_stack_trace ({'raise', 'warn', 'log', 'off'}) Doc: A flag for checking the stack trace during the optimization process. default (off): does not check the stack trace of any optimization log: inserts a dummy stack trace that identifies the optimizationthat inserted the variable that had an empty stack trace.warn: prints a warning if a stack trace is missing and also a dummystack trace is inserted that indicates which optimization insertedthe variable that had an empty stack trace.raise: raises an exception if a stack trace is missing Value: off metaopt__verbose () Doc: 0 for silent, 1 for only warnings, 2 for full output withtimings and selected implementation Value: 0 metaopt__optimizer_excluding () Doc: exclude optimizers with these tags. Separate tags with ':'. Value: metaopt__optimizer_including () Doc: include optimizers with these tags. Separate tags with ':'. Value: profile (>) Doc: If VM should collect profile information Value: False profile_optimizer (>) Doc: If VM should collect optimizer profile information Value: False profile_memory (>) Doc: If VM should collect memory profile information and print it Value: False Doc: Useful only for the VM Linkers. When lazy is None, auto detect if lazy evaluation is needed and use the appropriate version. If the C loop isn't being used and lazy is True, use the Stack VM; otherwise, use the Loop VM. Value: None unittests__rseed () Doc: Seed to use for randomized unit tests. Special value 'random' means using a seed of None. Value: 666 warn__round (>) Doc: Warn when using `tensor.round` with the default mode. Round changed its default from `half_away_from_zero` to `half_to_even` to have the same default as NumPy. Value: False numba__vectorize_target ({'cuda', 'parallel', 'cpu'}) Doc: Default target for numba.vectorize. Value: cpu numba__fastmath (>) Doc: If True, use Numba's fastmath mode. Value: True numba__cache (>) Doc: If True, use Numba's file based caching. Value: True compiledir_format () Doc: Format string for platform-dependent compiled module subdirectory (relative to base_compiledir). Available keys: aesara_version, device, gxx_version, hostname, numpy_version, platform, processor, python_bitwidth, python_int_bitwidth, python_version, short_platform. Defaults to compiledir_%(short_platform)s-%(processor)s- %(python_version)s-%(python_bitwidth)s. Value: compiledir_%(short_platform)s-%(processor)s-%(python_version)s-%(python_bitwidth)s Doc: platform-independent root directory for compiled modules Value: C:\Users\Opher local\AppData\Local\Aesara Doc: platform-dependent cache directory for compiled modules Value: C:\Users\Opher local\AppData\Local\Aesara\compiledir_Windows-10-10.0.19043-SP0-Intel64_Family_6_Model_142_Stepping_12_GenuineIntel-3.10.6-64 blas__ldflags () Doc: lib[s] to include for [Fortran] level-3 blas implementation Value: -lmkl_rt blas__check_openmp (>) Doc: Check for openmp library conflict. WARNING: Setting this to False leaves you open to wrong results in blas-related operations. Value: True scan__allow_gc (>) Doc: Allow/disallow gc inside of Scan (default: False) Value: False scan__allow_output_prealloc (>) Doc: Allow/disallow memory preallocation for outputs inside of scan (default: True) Value: True ```
maresb commented 1 year ago

Thanks @opherdonchin for the extra info! I see that @brandonwillard has added the MWE needed tag. Would it be possible for you to strip your current model to the bare minimum required to reproduce the error, and then post it here? Thanks!

brandonwillard commented 1 year ago

Thanks @opherdonchin for the extra info! I see that @brandonwillard has added the MWE needed tag. Would it be possible for you to strip your current model to the bare minimum required to reproduce the error, and then post it here? Thanks!

We may also need the commands used to build the (virtual) environment in which this issue occurs from scratch.

Also, don't use PyMC in these reproductions.

opherdonchin commented 1 year ago

Hi @brandonwillard ,

I don't know enough about aesara to build an aesara model without pymc. Sorry about that.

I used a minimal environment for testing:

`mamba create --name pymc_env_aesara --channel conda-forge --strict-channel-priority pymc` *expand for output* ``` ███████████████/ /██/ /██/ /██/ /████████████████████████ / / \ / \ / \ / \ \____ / / \_/ \_/ \_/ \ o \__, / _/ \_____/ ` |/ ███╗ ███╗ █████╗ ███╗ ███╗██████╗ █████╗ ████╗ ████║██╔══██╗████╗ ████║██╔══██╗██╔══██╗ ██╔████╔██║███████║██╔████╔██║██████╔╝███████║ ██║╚██╔╝██║██╔══██║██║╚██╔╝██║██╔══██╗██╔══██║ ██║ ╚═╝ ██║██║ ██║██║ ╚═╝ ██║██████╔╝██║ ██║ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝ mamba (0.24.0) supported by @QuantStack GitHub: https://github.com/mamba-org/mamba Twitter: https://twitter.com/QuantStack █████████████████████████████████████████████████████████████ Looking for: ['pymc'] pkgs/main/noarch 816.3kB @ 705.5kB/s 1.2s pkgs/r/win-64 742.8kB @ 599.3kB/s 1.3s pkgs/msys2/noarch 111.0 B @ 82.0 B/s 0.2s pkgs/msys2/win-64 39.8kB @ 23.1kB/s 0.4s pkgs/r/noarch 1.3MB @ 501.3kB/s 1.5s pkgs/main/win-64 4.3MB @ 1.4MB/s 3.3s conda-forge/noarch 9.4MB @ 1.6MB/s 6.7s conda-forge/win-64 16.5MB @ 1.9MB/s 9.7s warning libmamba Extracted package cache 'C:\miniconda3\pkgs\msys2-conda-epoch-20160418-1' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\msys2-conda-epoch-20160418-1' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-gmp-6.1.0-2' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-gmp-6.1.0-2' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-windows-default-manifest-6.4-3' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-windows-default-manifest-6.4-3' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-isl-0.16.1-2' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-isl-0.16.1-2' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-libiconv-1.14-6' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-libiconv-1.14-6' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-make-4.1.2351.a80a8b8-2' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-make-4.1.2351.a80a8b8-2' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-libwinpthread-git-5.0.0.4634.697f757-2' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-libwinpthread-git-5.0.0.4634.697f757-2' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-libmangle-git-5.0.0.4509.2e5a9a2-2' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-libmangle-git-5.0.0.4509.2e5a9a2-2' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-headers-git-5.0.0.4636.c0ad18a-2' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-headers-git-5.0.0.4636.c0ad18a-2' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-mpfr-3.1.4-4' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-mpfr-3.1.4-4' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-gcc-libs-core-5.3.0-7' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-gcc-libs-core-5.3.0-7' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-pkg-config-0.29.1-2' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-pkg-config-0.29.1-2' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-crt-git-5.0.0.4636.2595836-2' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-crt-git-5.0.0.4636.2595836-2' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-mpc-1.0.3-3' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-mpc-1.0.3-3' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-gcc-libgfortran-5.3.0-6' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-gcc-libgfortran-5.3.0-6' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-winpthreads-git-5.0.0.4634.697f757-2' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-winpthreads-git-5.0.0.4634.697f757-2' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-gcc-libs-5.3.0-7' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-gcc-libs-5.3.0-7' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-bzip2-1.0.6-6' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-bzip2-1.0.6-6' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-tools-git-5.0.0.4592.90b8472-2' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-tools-git-5.0.0.4592.90b8472-2' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-zlib-1.2.8-10' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-zlib-1.2.8-10' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-binutils-2.25.1-5' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-binutils-2.25.1-5' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-gcc-5.3.0-6' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-gcc-5.3.0-6' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-gcc-objc-5.3.0-6' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-gcc-objc-5.3.0-6' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-gcc-fortran-5.3.0-6' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-gcc-fortran-5.3.0-6' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-gcc-ada-5.3.0-6' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-gcc-ada-5.3.0-6' has invalid SHA-256 checksum warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-toolchain-5.3.0-7' has invalid size warning libmamba Extracted package cache 'C:\miniconda3\pkgs\m2w64-toolchain-5.3.0-7' has invalid SHA-256 checksum Transaction Prefix: C:\miniconda3\envs\pymc_env_aesara Updating specs: - pymc Package Version Build Channel Size ---------------------------------------------------------------------------------------------------------------- Install: ---------------------------------------------------------------------------------------------------------------- + aeppl 0.0.36 pyhd8ed1ab_0 conda-forge/noarch 5kB + aeppl-base 0.0.36 pyhd8ed1ab_0 conda-forge/noarch 44kB + aesara 2.8.6 py310hfa0c5ed_0 conda-forge/win-64 8kB + aesara-base 2.8.6 py310h5588dad_0 conda-forge/win-64 2MB + arviz 0.12.1 pyhd8ed1ab_1 conda-forge/noarch Cached + blas 2.116 mkl conda-forge/win-64 Cached + blas-devel 3.9.0 16_win64_mkl conda-forge/win-64 Cached + brotli 1.0.9 h8ffe710_7 conda-forge/win-64 Cached + brotli-bin 1.0.9 h8ffe710_7 conda-forge/win-64 Cached + bzip2 1.0.8 h8ffe710_4 conda-forge/win-64 Cached + ca-certificates 2022.9.24 h5b45459_0 conda-forge/win-64 Cached + cachetools 5.2.0 pyhd8ed1ab_0 conda-forge/noarch Cached + certifi 2022.9.24 pyhd8ed1ab_0 conda-forge/noarch Cached + cftime 1.6.2 py310h9b08ddd_0 conda-forge/win-64 Cached + cloudpickle 2.2.0 pyhd8ed1ab_0 conda-forge/noarch Cached + cons 0.4.5 pyhd8ed1ab_0 conda-forge/noarch Cached + contourpy 1.0.5 py310h232114e_0 conda-forge/win-64 Cached + curl 7.83.1 h789b8ee_0 conda-forge/win-64 Cached + cycler 0.11.0 pyhd8ed1ab_0 conda-forge/noarch Cached + etuples 0.3.8 pyhd8ed1ab_0 conda-forge/noarch Cached + fastprogress 1.0.3 pyhd8ed1ab_0 conda-forge/noarch Cached + filelock 3.8.0 pyhd8ed1ab_0 conda-forge/noarch Cached + fonttools 4.37.4 py310h8d17308_0 conda-forge/win-64 Cached + freetype 2.12.1 h546665d_0 conda-forge/win-64 Cached + hdf4 4.2.15 h0e5069d_4 conda-forge/win-64 Cached + hdf5 1.12.2 nompi_h57737ce_100 conda-forge/win-64 Cached + intel-openmp 2022.1.0 h57928b3_3787 conda-forge/win-64 Cached + jpeg 9e h8ffe710_2 conda-forge/win-64 Cached + kiwisolver 1.4.4 py310h476a331_0 conda-forge/win-64 Cached + krb5 1.19.3 hc8ab02b_0 conda-forge/win-64 Cached + lcms2 2.12 h2a16943_0 conda-forge/win-64 Cached + lerc 4.0.0 h63175ca_0 conda-forge/win-64 Cached + libblas 3.9.0 16_win64_mkl conda-forge/win-64 Cached + libbrotlicommon 1.0.9 h8ffe710_7 conda-forge/win-64 Cached + libbrotlidec 1.0.9 h8ffe710_7 conda-forge/win-64 Cached + libbrotlienc 1.0.9 h8ffe710_7 conda-forge/win-64 Cached + libcblas 3.9.0 16_win64_mkl conda-forge/win-64 Cached + libcurl 7.83.1 h789b8ee_0 conda-forge/win-64 Cached + libdeflate 1.14 hcfcfb64_0 conda-forge/win-64 Cached + libffi 3.4.2 h8ffe710_5 conda-forge/win-64 Cached + liblapack 3.9.0 16_win64_mkl conda-forge/win-64 Cached + liblapacke 3.9.0 16_win64_mkl conda-forge/win-64 Cached + libnetcdf 4.8.1 nompi_h85765be_104 conda-forge/win-64 Cached + libpng 1.6.38 h19919ed_0 conda-forge/win-64 Cached + libpython 2.2 py310h5588dad_1 conda-forge/win-64 Cached + libsqlite 3.39.3 hcfcfb64_0 conda-forge/win-64 Cached + libssh2 1.10.0 h9a1e1f7_3 conda-forge/win-64 Cached + libtiff 4.4.0 h8e97e67_4 conda-forge/win-64 Cached + libwebp-base 1.2.4 h8ffe710_0 conda-forge/win-64 Cached + libxcb 1.13 hcd874cb_1004 conda-forge/win-64 Cached + libzip 1.9.2 h519de47_1 conda-forge/win-64 Cached + libzlib 1.2.12 hcfcfb64_3 conda-forge/win-64 Cached + logical-unification 0.4.5 pyhd8ed1ab_0 conda-forge/noarch Cached + m2w64-binutils 2.25.1 5 conda-forge/win-64 Cached + m2w64-bzip2 1.0.6 6 conda-forge/win-64 Cached + m2w64-crt-git 5.0.0.4636.2595836 2 conda-forge/win-64 Cached + m2w64-gcc 5.3.0 6 conda-forge/win-64 Cached + m2w64-gcc-ada 5.3.0 6 conda-forge/win-64 Cached + m2w64-gcc-fortran 5.3.0 6 conda-forge/win-64 Cached + m2w64-gcc-libgfortran 5.3.0 6 conda-forge/win-64 Cached + m2w64-gcc-libs 5.3.0 7 conda-forge/win-64 Cached + m2w64-gcc-libs-core 5.3.0 7 conda-forge/win-64 Cached + m2w64-gcc-objc 5.3.0 6 conda-forge/win-64 Cached + m2w64-gmp 6.1.0 2 conda-forge/win-64 Cached + m2w64-headers-git 5.0.0.4636.c0ad18a 2 conda-forge/win-64 Cached + m2w64-isl 0.16.1 2 conda-forge/win-64 Cached + m2w64-libiconv 1.14 6 conda-forge/win-64 Cached + m2w64-libmangle-git 5.0.0.4509.2e5a9a2 2 conda-forge/win-64 Cached + m2w64-libwinpthread-git 5.0.0.4634.697f757 2 conda-forge/win-64 Cached + m2w64-make 4.1.2351.a80a8b8 2 conda-forge/win-64 Cached + m2w64-mpc 1.0.3 3 conda-forge/win-64 Cached + m2w64-mpfr 3.1.4 4 conda-forge/win-64 Cached + m2w64-pkg-config 0.29.1 2 conda-forge/win-64 Cached + m2w64-toolchain 5.3.0 7 conda-forge/win-64 Cached + m2w64-toolchain_win-64 2.4.0 0 conda-forge/win-64 Cached + m2w64-tools-git 5.0.0.4592.90b8472 2 conda-forge/win-64 Cached + m2w64-windows-default-manifest 6.4 3 conda-forge/win-64 Cached + m2w64-winpthreads-git 5.0.0.4634.697f757 2 conda-forge/win-64 Cached + m2w64-zlib 1.2.8 10 conda-forge/win-64 Cached + matplotlib-base 3.6.0 py310h51140c5_0 conda-forge/win-64 Cached + minikanren 1.0.3 pyhd8ed1ab_0 conda-forge/noarch Cached + mkl 2022.1.0 h6a75c08_874 conda-forge/win-64 Cached + mkl-devel 2022.1.0 h57928b3_875 conda-forge/win-64 Cached + mkl-include 2022.1.0 h6a75c08_874 conda-forge/win-64 Cached + mkl-service 2.4.0 py310h3d5ec83_0 conda-forge/win-64 Cached + msys2-conda-epoch 20160418 1 conda-forge/win-64 Cached + multipledispatch 0.6.0 py_0 conda-forge/noarch Cached + munkres 1.1.4 pyh9f0ad1d_0 conda-forge/noarch Cached + netcdf4 1.6.1 nompi_py310h459bb5f_100 conda-forge/win-64 Cached + numpy 1.23.3 py310h4a8f9c9_0 conda-forge/win-64 Cached + openjpeg 2.5.0 hc9384bd_1 conda-forge/win-64 Cached + openssl 3.0.5 hcfcfb64_2 conda-forge/win-64 Cached + packaging 21.3 pyhd8ed1ab_0 conda-forge/noarch Cached + pandas 1.5.0 py310h1c4a608_0 conda-forge/win-64 Cached + pillow 9.2.0 py310h52929f7_2 conda-forge/win-64 Cached + pip 22.2.2 pyhd8ed1ab_0 conda-forge/noarch Cached + pthread-stubs 0.4 hcd874cb_1001 conda-forge/win-64 Cached + pymc 4.2.1 hd8ed1ab_0 conda-forge/noarch 10kB + pymc-base 4.2.1 pyhd8ed1ab_0 conda-forge/noarch 408kB + pyparsing 3.0.9 pyhd8ed1ab_0 conda-forge/noarch Cached + python 3.10.6 hcf16a7b_0_cpython conda-forge/win-64 Cached + python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge/noarch Cached + python_abi 3.10 2_cp310 conda-forge/win-64 Cached + pytz 2022.2.1 pyhd8ed1ab_0 conda-forge/noarch Cached + scipy 1.9.1 py310h578b7cb_0 conda-forge/win-64 Cached + setuptools 65.4.0 pyhd8ed1ab_0 conda-forge/noarch Cached + six 1.16.0 pyh6c4a22f_0 conda-forge/noarch Cached + tbb 2021.6.0 h91493d7_0 conda-forge/win-64 Cached + tk 8.6.12 h8ffe710_0 conda-forge/win-64 Cached + toolz 0.12.0 pyhd8ed1ab_0 conda-forge/noarch Cached + typing-extensions 4.3.0 hd8ed1ab_0 conda-forge/noarch Cached + typing_extensions 4.3.0 pyha770c72_0 conda-forge/noarch Cached + tzdata 2022d h191b570_0 conda-forge/noarch Cached + ucrt 10.0.20348.0 h57928b3_0 conda-forge/win-64 Cached + unicodedata2 14.0.0 py310he2412df_1 conda-forge/win-64 Cached + vc 14.2 hb210afc_7 conda-forge/win-64 Cached + vs2015_runtime 14.29.30139 h890b9b1_7 conda-forge/win-64 Cached + wheel 0.37.1 pyhd8ed1ab_0 conda-forge/noarch Cached + xarray 2022.9.0 pyhd8ed1ab_0 conda-forge/noarch Cached + xarray-einstats 0.3.0 pyhd8ed1ab_0 conda-forge/noarch Cached + xorg-libxau 1.0.9 hcd874cb_0 conda-forge/win-64 Cached + xorg-libxdmcp 1.1.3 hcd874cb_0 conda-forge/win-64 Cached + xz 5.2.6 h8d14728_0 conda-forge/win-64 Cached + zstd 1.5.2 h7755175_4 conda-forge/win-64 Cached Summary: Install: 124 packages Total download: 3MB ---------------------------------------------------------------------------------------------------------------- Confirm changes: [Y/n] Y aeppl-base 44.4kB @ 97.3kB/s 0.5s aesara 7.6kB @ 13.8kB/s 0.6s aeppl 5.1kB @ 9.3kB/s 0.5s pymc 9.8kB @ 14.7kB/s 0.2s pymc-base 408.1kB @ 455.2kB/s 0.9s aesara-base 2.1MB @ 900.8kB/s 2.3s Preparing transaction: done Verifying transaction: done Executing transaction: done To activate this environment, use $ mamba activate pymc_env_aesara To deactivate an active environment, use $ mamba deactivate ```

In response to @maresb request for the miminal model, this post includes the full minimal model (see below). In producing it, it seems to me that the key lines in the model may be:

    beta = pm.Normal('beta', mu=0, sigma=1.5, dims=['process', 'measure'])
    mu_y = pm.Deterministic('mu_y', pm.math.dot(x,beta), dims=['subject', 'measure'])

Because if these lines are replaced by the following:

    beta = pm.Normal('beta', mu=0, sigma=1.5, dims=['measure'])
    mu_y = pm.Deterministic('mu_y', beta, dims=['subject', 'measure'])

This error goes away (and is replaced with a different one).

Here is the full model:

Expand for the minimal model that generates the error. ```python import numpy as np import pandas as pd import pymc as pm def latent_variable_model(y,x,P): s_idx, subject_list = pd.factorize(y.index) m_idx, measure_list = pd.factorize(y.columns) coords = {'subject': subject_list, 'measure': measure_list, 'process': range(P)} with pm.Model(coords=coords) as model: # Minimal model that generates the missing mkl_rt error beta = pm.Normal('beta', mu=0, sigma=1.5, dims=['process', 'measure']) mu_y = pm.Deterministic('mu_y', pm.math.dot(x,beta), dims=['subject', 'measure']) # Even more minimal model that does not generate the mkl_rt error. # This model generates a pymc error that may be easy to fix. # beta = pm.Normal('beta', mu=0, sigma=1.5, dims=['measure']) # mu_y = pm.Deterministic('mu_y', beta, dims=['subject', 'measure']) obs_y = pm.Normal('obs_y', mu=mu_y, sigma=0.1, observed=y, dims=['subject', 'measure']) return model y = pd.DataFrame(np.random.normal(loc=0.8, scale=0.3, size=(420,6))) x = np.random.normal(loc=0.5, scale=0.1, size=(420,2)) model = latent_variable_model(y, x, 2) with model: fit = pm.sample() ```
Expand for the output: ```PowerShell PS C:\Opher\GitHub\bsf_donchin_jordan_2022> conda activate C:\miniconda3\envs\pymc_env_aesara PS C:\Opher\GitHub\bsf_donchin_jordan_2022> & C:/miniconda3/envs/pymc_env_aesara/python.exe c:/Opher/GitHub/bsf_donchin_jordan_2022/mkl_rt_test_stripped.py You can find the C code in this temporary file: C:\Users\OPHERL~1\AppData\Local\Temp\aesara_compilation_error_xgfvafb_ library mkl_rt is not found. Traceback (most recent call last): File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\vm.py", line 1246, in make_all node.op.make_thunk(node, storage_map, compute_map, [], impl=impl) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\op.py", line 131, in make_thunk return self.make_c_thunk(node, storage_map, compute_map, no_recycling) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\op.py", line 96, in make_c_thunk outputs = cl.make_thunk( File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\basic.py", line 1202, in make_thunk cthunk, module, in_storage, out_storage, error_storage = self.__compile__( File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\basic.py", line 1122, in __compile__ thunk, module = self.cthunk_factory( File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\basic.py", line 1647, in cthunk_factory module = cache.module_from_key(key=key, lnk=self) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\cmodule.py", line 1229, in module_from_key module = lnk.compile_cmodule(location) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\basic.py", line 1546, in compile_cmodule module = c_compiler.compile_str( File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\cmodule.py", line 2640, in compile_str raise CompileError( aesara.link.c.exceptions.CompileError: Compilation failed (return status=1): "C:\miniconda3\envs\pymc_env_strict\Library\mingw-w64\bin\g++.exe" -shared -g -O3 -fno-math-errno -Wno-unused-label -Wno-unused-variable -Wno-write-strings -Wno-c++11-narrowing -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -march=broadwell -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mmovbe -maes -mno-sha -mpclmul -mpopcnt -mabm -mno-lwp -mfma -mno-fma4 -mno-xop -mbmi -mbmi2 -mno-tbm -mavx -mavx2 -msse4.2 -msse4.1 -mlzcnt -mno-rtm -mno-hle -mrdrnd -mf16c -mfsgsbase -mrdseed -mprfchw -madx -mfxsr -mxsave -mxsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 -mclflushopt -mxsavec -mxsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl -mno-avx512ifma -mno-avx512vbmi -mno-clwb -mno-pcommit -mno-mwaitx --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=8192 -mtune=generic -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -DMS_WIN64 -I"C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\numpy\core\include" -I"C:\miniconda3\envs\pymc_env_aesara\include" -I"C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\c_code" -L"C:\miniconda3\envs\pymc_env_aesara\libs" -L"C:\miniconda3\envs\pymc_env_aesara" -o "C:\Users\Opher local\AppData\Local\Aesara\compiledir_Windows-10-10.0.19043-SP0-Intel64_Family_6_Model_142_Stepping_12_GenuineIntel-3.10.6-64\tmp78frcsc_\mebd8dae10522ca0870e1a82f1ea908002d7232440c31ecf6eadb09903ee4931b.pyd" "C:\Users\Opher local\AppData\Local\Aesara\compiledir_Windows-10-10.0.19043-SP0-Intel64_Family_6_Model_142_Stepping_12_GenuineIntel-3.10.6-64\tmp78frcsc_\mod.cpp" -lmkl_rt "C:\miniconda3\envs\pymc_env_aesara\python310.dll" C:/miniconda3/envs/pymc_env_strict/Library/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmkl_rt collect2.exe: error: ld returned 1 exit status During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\Opher\GitHub\bsf_donchin_jordan_2022\mkl_rt_test_stripped.py", line 29, in fit = pm.sample() File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\pymc\sampling.py", line 530, in sample step = assign_step_methods(model, step, methods=pm.STEP_METHODS, step_kwargs=kwargs) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\pymc\sampling.py", line 228, in assign_step_methods return instantiate_steppers(model, steps, selected_steps, step_kwargs) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\pymc\sampling.py", line 146, in instantiate_steppers step = step_class(vars=vars, model=model, **args) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\pymc\step_methods\hmc\nuts.py", line 178, in __init__ super().__init__(vars, **kwargs) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\pymc\step_methods\hmc\base_hmc.py", line 95, in __init__ super().__init__(vars, blocked=blocked, model=self._model, dtype=dtype, **aesara_kwargs) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\pymc\step_methods\arraystep.py", line 276, in __init__ func = model.logp_dlogp_function(vars, dtype=dtype, **aesara_kwargs) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\pymc\model.py", line 642, in logp_dlogp_function return ValueGradFunction(costs, grad_vars, extra_vars_and_values, **kwargs) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\pymc\model.py", line 382, in __init__ self._aesara_function = compile_pymc(inputs, outputs, givens=givens, **kwargs) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\pymc\aesaraf.py", line 970, in compile_pymc aesara_function = aesara.function( File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\compile\function\__init__.py", line 317, in function fn = pfunc( File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\compile\function\pfunc.py", line 371, in pfunc return orig_function( File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\compile\function\types.py", line 1759, in orig_function fn = m.create(defaults) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\compile\function\types.py", line 1652, in create _fn, _i, _o = self.linker.make_thunk( File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\basic.py", line 254, in make_thunk return self.make_all( File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\vm.py", line 1255, in make_all raise_with_op(fgraph, node) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\utils.py", line 534, in raise_with_op raise exc_value.with_traceback(exc_trace) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\vm.py", line 1246, in make_all node.op.make_thunk(node, storage_map, compute_map, [], impl=impl) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\op.py", line 131, in make_thunk return self.make_c_thunk(node, storage_map, compute_map, no_recycling) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\op.py", line 96, in make_c_thunk outputs = cl.make_thunk( File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\basic.py", line 1202, in make_thunk cthunk, module, in_storage, out_storage, error_storage = self.__compile__( File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\basic.py", line 1122, in __compile__ thunk, module = self.cthunk_factory( File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\basic.py", line 1647, in cthunk_factory module = cache.module_from_key(key=key, lnk=self) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\cmodule.py", line 1229, in module_from_key module = lnk.compile_cmodule(location) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\basic.py", line 1546, in compile_cmodule module = c_compiler.compile_str( File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\cmodule.py", line 2640, in compile_str raise CompileError( aesara.link.c.exceptions.CompileError: Compilation failed (return status=1): "C:\miniconda3\envs\pymc_env_strict\Library\mingw-w64\bin\g++.exe" -shared -g -O3 -fno-math-errno -Wno-unused-label -Wno-unused-variable -Wno-write-strings -Wno-c++11-narrowing -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -march=broadwell -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mmovbe -maes -mno-sha -mpclmul -mpopcnt -mabm -mno-lwp -mfma -mno-fma4 -mno-xop -mbmi -mbmi2 -mno-tbm -mram l2-cache-size=8192 -mtune=generic -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -DMS_WIN64 -I"C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\numpy\core\include" -I"C:\miniconda3\envs\pymc_1 -mclflushopt -menv_aesara\include" -I"C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\aesara\link\c\c_code" -L"C:\miniconda3\envs\pymc_env_aesara\libs" -L"C:\miniconda3\envs\pymc_env_aesara" -o "C:\Users\Opher l=8192 -mtune=geneocal\AppData\Local\Aesara\compiledir_Windows-10-10.0.19043-SP0-Intel64_Family_6_Model_142_Stepping_12_GenuineIntel-3.10.6-64\tmp78frcsc_\mebd8dae10522ca0870e1a82f1ea908002d7232440c31ecf6eadb09903ee4931a3\envs\pymc_env_b.pyd" "C:\Users\Opher local\AppData\Local\Aesara\compiledir_Windows-10-10.0.19043-SP0-Intel64_Family_6_Model_142_Stepping_12_GenuineIntel-3.10.6-64\tmp78frcsc_\mod.cpp" -lmkl_rt "C:\miniconda3\envs\py0.19043-SP0-Intelmc_env_aesara\python310.dll" -10-10.0.19043-SP C:/miniconda3/envs/pymc_env_strict/Library/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmkl_rt collect2.exe: error: ld returned 1 exit status Apply node that caused the error: Gemm{no_inplace}(obs_y{[[0.757696..72087676]]}, TensorConstant{-1.0}, TensorConstant{[[0.383318..30498162]]}, beta, TensorConstant{1.0}) Toposort index: 0 Inputs types: [TensorType(float64, (420, 6)), TensorType(float64, ()), TensorType(float64, (420, 2)), TensorType(float64, (None, None)), TensorType(float64, ())] HINT: Use a linker other than the C linker to print the inputs' shapes and strides. HINT: Re-running with most Aesara optimizations disabled could provide a back-trace showing when this node was created. This can be done by setting the Aesara flag 'optimizer=fast_compile'. If that does not work, Aesars not work, Aesara optimizations can be disabled with 'optimizer=None'. HINT: Use the Aesara flag `exception_verbosity=high` for a debug print-out and storage map footprint of this Apply node. PS C:\Opher\GitHub\bsf_donchin_jordan_2022> & C:/miniconda3/envs/pymc_env_aesara/python.exe c:/Opher/GitHub/bsf_donchin_jordan_2022/mkl_rt_test_stripped.py Traceback (most recent call last): File "c:\Opher\GitHub\bsf_donchin_jordan_2022\mkl_rt_test_stripped.py", line 26, in model = latent_variable_model(y, x, 2) File "c:\Opher\GitHub\bsf_donchin_jordan_2022\mkl_rt_test_stripped.py", line 17, in latent_variable_model beta = pm.Normal('beta', mu=0, sigma=1.5, dims=['measure']) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\pymc\distributions\distribution.py", line 292, in __new__ rv_out = model.register_rv( File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\pymc\model.py", line 1365, in register_rv self.add_random_variable(rv_var, dims) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\pymc\model.py", line 1550, in add_random_variable raise ValueError(f"Variable name {var.name} already exists.") ValueError: Variable name beta already exists. ```

In contrast, by commenting out the lines indicate and removing comments from the ones shown, I get the following:

Expand for the output: ```PowerShell PS C:\Opher\GitHub\bsf_donchin_jordan_2022> conda activate C:\miniconda3\envs\pymc_env_aesara PS C:\Opher\GitHub\bsf_donchin_jordan_2022> & C:/miniconda3/envs/pymc_env_aesara/python.exe c:/Opher/GitHub/bsf_donchin_jordan_2022/mkl_rt_test_stripped.py Auto-assigning NUTS sampler... Initializing NUTS using jitter+adapt_diag... Multiprocess sampling (4 chains in 4 jobs) NUTS: [beta] Auto-assigning NUTS sampler... Initializing NUTS using jitter+adapt_diag... Multiprocess sampling (4 chains in 4 jobs) NUTS: [beta] Traceback (most recent call last): File "", line 1, in File "C:\miniconda3\envs\pymc_env_aesara\lib\multiprocessing\spawn.py", line 116, in spawn_main exitcode = _main(fd, parent_sentinel) File "C:\miniconda3\envs\pymc_env_aesara\lib\multiprocessing\spawn.py", line 125, in _main prepare(preparation_data) File "C:\miniconda3\envs\pymc_env_aesara\lib\multiprocessing\spawn.py", line 236, in prepare _fixup_main_from_path(data['init_main_from_path']) File "C:\miniconda3\envs\pymc_env_aesara\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path main_content = runpy.run_path(main_path, File "C:\miniconda3\envs\pymc_env_aesara\lib\runpy.py", line 289, in run_path return _run_module_code(code, init_globals, run_name, File "C:\miniconda3\envs\pymc_env_aesara\lib\runpy.py", line 96, in _run_module_code _run_code(code, mod_globals, init_globals, File "C:\miniconda3\envs\pymc_env_aesara\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "c:\Opher\GitHub\bsf_donchin_jordan_2022\mkl_rt_test_stripped.py", line 29, in fit = pm.sample() File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\pymc\sampling.py", line 613, in sample mtrace = _mp_sample(**sample_args, **parallel_args) File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\pymc\sampling.py", line 1526, in _mp_sample sampler = ps.ParallelSampler( File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\pymc\parallel_sampling.py", line 417, in __init__ self._samplers = [ File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\pymc\parallel_sampling.py", line 418, in ProcessAdapter( File "C:\miniconda3\envs\pymc_env_aesara\lib\site-packages\pymc\parallel_sampling.py", line 286, in __init__ self._process.start() File "C:\miniconda3\envs\pymc_env_aesara\lib\multiprocessing\process.py", line 121, in start self._popen = self._Popen(self) File "C:\miniconda3\envs\pymc_env_aesara\lib\multiprocessing\context.py", line 336, in _Popen return Popen(process_obj) File "C:\miniconda3\envs\pymc_env_aesara\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__ prep_data = spawn.get_preparation_data(process_obj._name) File "C:\miniconda3\envs\pymc_env_aesara\lib\multiprocessing\spawn.py", line 154, in get_preparation_data _check_not_importing_main() File "C:\miniconda3\envs\pymc_env_aesara\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main raise RuntimeError(''' RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase. This probably means that you are not using fork to start your child processes and you have forgotten to use the proper idiom in the main module: if __name__ == '__main__': freeze_support() ... The "freeze_support()" line can be omitted if the program is not going to be frozen to produce an executable. ```
brandonwillard commented 1 year ago

I don't know enough about aesara to build an aesara model without pymc. Sorry about that.

That's fine, but it means that the PyMC-related work being done in this issue should be done in a PyMC issue or Discussion first (i.e. until the Aesara parts of the issue are understood and reproducible). The basic idea is that readers and/or developers here may know nothing about PyMC, so it's less likely that progress would be made here than elsewhere, and that increases the chances of this becoming a stale issue.

maresb commented 1 year ago

Agreed. I should have mentioned that I pinged @lucianopaz, and he intends to take a look at this (in particular in relation to #947) when he finds the time.

lucianopaz commented 1 year ago

@opherdonchin, I reproduced your pymc model to see if I could dive into the issue further, but the model works for me.

I noticed that your aesara.config.blas__ldflags says -lmkl_rt only. Mine says: '-L"C:\\...\\anaconda3\\envs\\pymc-issue-test\\Library\\bin" -lmkl_core -lmkl_intel_thread -lmkl_rt'. So the problem you are seeing is caused by the missing library directory in the blas__ldflags. It's also strange that you don't have the other mkl libraries in those flags.

By any chance, are you attempting to modify the default blas__ldflags? There are three ways to do so:

If imagine that if you are not setting the aesara.config value in your script, it's highly unlikely that you are using environment variables by mistake. I think that the most likely cause to your problem is that you have an .aesararc file in one of the paths listed here that is leading to the incorrect blas flags setup. If you don't have this file, then this might indicate that there is some deeper problem with how aesara sets the default blas__ldflags (which I find very strange), or from where this configuration option is read.

opherdonchin commented 1 year ago

Hi @lucianopaz !

Thanks for the suggestions. In the related PyMC discourse discussion, you suggested I try adding the line:

aesara.config.blas__ldflags = f'"-L{os.path.join(sys.prefix, "Library", "bin")}" -lmkl_core -lmkl_intel_thread -lmkl_rt'

And that works! At least, it works in the stripped down environment with the stripped down script I made for this issue. I'll check the full version later but I don't see why there should be a problem.

I tried following up on the suggestions here as well. I did not find an AESARA_FLAGS or AESARARC environment variable and I also did not find a $HOME$.aesararc or $HOME\.aesararc.txt. Thus, I don't know how the aesara flags have gotten out of whack.

Is there a way to keep following this up beyond this point to identify the original problem? I mean, it is fixed for me, but it would be nice to know what went wrong.

Opher

lucianopaz commented 1 year ago

I honestly don’t know how the blas flags could have gotten to the state they were. If you search for mkl in aesara you find that it’s set in a few scripts in the library, so I don’t understand what could have broken them. Maybe @brandonwillard has an idea?