I have a script that runs fine unless I have `import CairoMakie`

at the top. Then it hangs. How can I diagnose this?

It hangs at `mcmc_with_warmup`

. The same thing happens whether I have `using CairoMakie`

or `import CairoMakie`

. However, if I run the script before importing `CairoMakie`

, then import it and run the script again, it works fine.

It seems like it’s hanging before it starts executing the line.

```
using AbstractGPs
using Distributions
using StatsFuns
using DynamicHMC
using LogDensityProblems
# import CairoMakie
using Random
Random.seed!(1234)
n = 100
x_train = collect(range(-5.0, 5.0; length=n))
y_train = rand(n) + sin.(x_train .* 2);
function gp_loglikelihood(x, y)
function loglikelihood(params)
kernel =
softplus(params[1]) * (Matern52Kernel() ∘ ScaleTransform(softplus(params[2])))
f = GP(kernel)
fx = f(x, 0.1)
return logpdf(fx, y)
end
return loglikelihood
end
function gp_posterior(x, y, p)
kernel = softplus(p[1]) * (Matern52Kernel() ∘ ScaleTransform(softplus(p[2])))
f = GP(kernel)
return posterior(f(x, 0.1), y)
end
loglik_train = gp_loglikelihood(x_train, y_train)
logprior(params) = logpdf(MvNormal(2, 1), params)
n_samples = 2_000
n_adapts = 1_000
# Log joint density
function LogDensityProblems.logdensity(ℓ::typeof(loglik_train), params)
return ℓ(params) + logprior(params)
end
# The parameter space is two-dimensional
LogDensityProblems.dimension(::typeof(loglik_train)) = 2
# `loglik_train` does not allow to evaluate derivatives of
# the log-likelihood function
function LogDensityProblems.capabilities(::Type{<:typeof(loglik_train)})
return LogDensityProblems.LogDensityOrder{0}()
end
mcmc_result = mcmc_with_warmup(
Random.GLOBAL_RNG,
ADgradient(:ForwardDiff, loglik_train),
n_samples;
reporter=NoProgressReport(),
)
samples = mcmc_result.chain
samples_constrained = [map(softplus, p) for p in samples]
mean_samples = mean(samples_constrained)
```

Julia 1.5.3

Linux