greta-dev / greta-dev/greta

Cholesky fails on a non-M1 system

Open
#589 2 comments 0 reactions 0 assignees View on GitHub
distributions
Dominant language
C++
Stars
607
Forks
67
Avg merge
3d 8h
Merged PRs (30d)
1

Description

Hi there, facing `chol` failures on Windows. Decided to open a new thread in case this can be closed apart from the M1-related issues.

I was trying to fit some spatial correlation structure but couldn't calculate. `mcmc` also complains about failing to find initial values, but I think maybe isolate this to `calculate` first, before testing `mcmc`... Maybe I have simply mispecified the model.

``` r
library(greta)
#> Warning: package 'greta' was built under R version 4.2.3
#>
#> Attaching package: 'greta'
#> The following objects are masked from 'package:stats':
#>
#> binomial, cov2cor, poisson
#> The following objects are masked from 'package:base':
#>
#> %*%, apply, backsolve, beta, chol2inv, colMeans, colSums, diag,
#> eigen, forwardsolve, gamma, identity, rowMeans, rowSums, sweep,
#> tapply

n <- 10

distance <- .7 ^ as.matrix(dist(1:n))
range <- exponential(1)
#> ℹ Initialising python and checking dependencies, this may take a moment.
#> ✔ Initialising python and checking dependencies ... done!
log_sd <- normal(0, 1)
Sigma <- exp(log_sd - 0.5 * (distance * range)^2)
L <- chol(Sigma)
Z <- normal(0, 1, n)
e <- t(t(Z) %*% L)

calculate(e, nsim = 1)
#> Cholesky decomposition was not successful. The input might not be valid.
#> [[node Cholesky (defined at \ops\gen_linalg_ops.py:830) ]]
#>
#> Errors may have originated from an input operation.
#> Input Source operations connected to node Cholesky:
#> Exp (defined at \ops\gen_math_ops.py:4064)
#>
#> Original stack trace for 'Cholesky':
#> File "\ops\gen_linalg_ops.py", line 830, in cholesky
#> "Cholesky", input=input, name=name)
#> File "\framework\op_def_library.py", line 788, in _apply_op_helper
#> op_def=op_def)
#> File "\util\deprecation.py", line 507, in new_func
#> return func(*args, **kwargs)
#> File "\framework\ops.py", line 3616, in create_op
#> op_def=op_def)
#> File "\framework\ops.py", line 2005, in __init__
#> self._traceback = tf_stack.extract_stack()
```

Created on 2023-10-19 with [reprex v2.0.2](https://reprex.tidyverse.org)

```
> sessionInfo()
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_New Zealand.utf8 LC_CTYPE=English_New Zealand.utf8 LC_MONETARY=English_New Zealand.utf8
[4] LC_NUMERIC=C LC_TIME=English_New Zealand.utf8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] greta_0.4.3

loaded via a namespace (and not attached):
[1] Rcpp_1.0.11 pillar_1.9.0 compiler_4.2.2 prettyunits_1.1.1 base64enc_0.1-3 tools_4.2.2
[7] progress_1.2.2 digest_0.6.33 tibble_3.2.1 evaluate_0.21 jsonlite_1.8.7 lifecycle_1.0.3
[13] lattice_0.21-8 pkgconfig_2.0.3 png_0.1-8 rlang_1.1.1 reprex_2.0.2 Matrix_1.6-1
[19] cli_3.6.1 rstudioapi_0.15.0 yaml_2.3.7 parallel_4.2.2 xfun_0.40 fastmap_1.1.1
[25] coda_0.19-4 withr_2.5.0 knitr_1.44 vctrs_0.6.3 fs_1.6.3 globals_0.16.2
[31] hms_1.1.3 rappdirs_0.3.3 grid_4.2.2 reticulate_1.32.0 glue_1.6.2 listenv_0.9.0
[37] R6_2.5.1 processx_3.8.2 fansi_1.0.4 parallelly_1.36.0 rmarkdown_2.24 callr_3.7.3
[43] clipr_0.8.0 whisker_0.4.1 magrittr_2.0.3 htmltools_0.5.6 codetools_0.2-19 ps_1.7.5
[49] tfruns_1.5.1 future_1.33.0 tensorflow_2.13.0 utf8_1.2.3 crayon_1.5.2
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.