简体   繁体   English

Numba Jit 自动缓存与磁盘缓存

[英]Numba Jit auto cache vs on disk caching

I've been looking for an answer in the numba docs, but I haven't been able to find anything.我一直在 numba 文档中寻找答案,但我什么也没找到。

The numba.jit decorator caches compiled functions automatically. numba.jit 装饰器自动缓存已编译的函数。 Additionally, you can pass cache=True argument to it to create an on-disk cache.此外,您可以将 cache=True 参数传递给它以创建磁盘缓存。

What's the difference between both caching methods?两种缓存方法有什么区别? Does on-disk cache persist, so that next time I execute my code, even on a "fresh" Ipython kernel, I can skip the compilation?磁盘缓存是否持续存在,以便下次我执行我的代码时,即使在“新鲜的”Ipython kernel 上,我也可以跳过编译?

Thanks in advance!提前致谢!

A year and a half later, this question was a top result when I was looking for the same answer.一年半后,当我在寻找相同答案时,这个问题是一个顶级结果。

Looking in the code , I found the jit results are cached by default under __pycache__ on a function-by-function basis.查看代码,我发现 jit 结果默认缓存在__pycache__下,逐个函数。 I removed these and saw them repopulate when running the code again.我删除了这些并在再次运行代码时看到它们重新填充。

AFAIK the "automatic" caching you are referring to is just in memory, while the disk cache is of course on disk. AFAIK 您所指的“自动”缓存就在 memory 中,而磁盘缓存当然在磁盘上。 The disk cache persists and is loaded next time you run your program, skipping the compilation as you said.磁盘缓存会持续存在并在您下次运行程序时加载,如您所说跳过编译。

After delving into the sources, I did end up finding the answer in the docs , too.在深入研究资源后,我最终也在文档中找到了答案 Looks like you can override the cache location using the NUMBA_CACHE_DIR environment variable.看起来您可以使用NUMBA_CACHE_DIR环境变量覆盖缓存位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM