Julia 包在第一次运行时加载非常慢 [英] Julia package load extremely slow in first run

查看:26
本文介绍了Julia 包在第一次运行时加载非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Linux 5.4.0 下使用 Julia 1.5.2 并为 Pkg.add("DifferentialEquations") 等待了大约 15 分钟.然后我在 Jupyter Notebook 中启动内核并运行以下代码.执行需要 1 分钟(实际上我第一次执行此操作需要 225 秒).

I'm using Julia 1.5.2 under Linux 5.4.0 and waited around 15 minutes for Pkg.add("DifferentialEquations"). Then I started the Kernel in Jupyter Notebook and ran the following code. It took terribly 1 minute to execute (the actual first time that I did this it took 225s).

t = time()
using Printf
using BenchmarkTools
using OrdinaryDiffEq
using Plots
tt = time() - t
@sprintf("It took %f seconds to import Printf, BenchmarkTools, OrdinaryDiffEq and Plots.", tt)
# It took 58.545894 seconds to import Printf, BenchmarkTools, OrdinaryDiffEq and Plots.

最后,我做了与上面相同的操作,但针对每个包.这是摘要:

Finally, I done the same as above, but for each package. This is the summary:

Printf:           0.004755973815917969
BenchmarkTools:   0.06729602813720703
Plots:            19.99405598640442
OrdinaryDiffEq:   19.001102209091187

我从 here 知道 Pkg 运行缓慢过去,但我认为 15 分钟根本不是正常的安装时间.不过,这不是我的大问题.

I know from here that Pkg was slow in the past, but I think that 15 minutes isn't a normal installing time at all. However, this is not my big problem.

我知道 Julia 需要在每次启动内核或加载某些包时编译所有内容.但这显然不是编译时间,而是编译永恒.

I know that Julia needs to compile everything everytime the Kernel is started or some package is loaded. But it obviously is not a compilation time, it's a compilation eternity.

谁能弄清楚为什么这非常慢?而且,如果正常的话,给Pkg提供预编译的包,比如numpy和朋友都是Python的不是更好吗?或者至少在第一个 using 中永远编译?

Can anyone figure out why this is so terribly slow? And, if it's normal, wouldn't it be better to provide precompiled packages to Pkg such as numpy and friends are in Python? Or at least compile forever in the first using?

谢谢!

我的完整平台信息:

Julia Version 1.5.2
Commit 539f3ce943 (2020-09-23 23:17 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i3-6100U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)

推荐答案

这个问题一般称为latencytime-to-first-plot (TTFP)julia-lang.使用这些关键字时,您可以找到一些讨论.

This problem is generally called latency or time-to-first-plot (TTFP) when referring to julia-lang. There are some discussions you can find when using these keywords.

文章"Analyzing sources of compilerJulia 中的延迟:方法失效"

在撰写本文时(2020 年底,稳定版本 v1.5.3),尚无通用解决方案,但讨论了大规模预编译包而不是 JIT 的策略,并取得了一定的成功.

At the time of writing (end 2020, stable release v1.5.3), no general solution is available but strategies of massive precompilation of packages instead of JIT is discussed, with marginal success.

这篇关于Julia 包在第一次运行时加载非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆