numba 缓存问题:无法缓存功能/没有可用于文件的定位器 [英] numba caching issue: cannot cache function / no locator available for file

查看:133
本文介绍了numba 缓存问题:无法缓存功能/没有可用于文件的定位器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 cache=True 部署具有多个 numba.njit 函数的代码库.

I am trying to deploy a codebase that has a number numba.njit functions with cache=True.

它在本地运行良好(Mac OS X 10.12.3),但在远程机器(AWS 上的 Ubuntu 14.04)上我收到以下错误:

It works fine running locally (Mac OS X 10.12.3), but on the remote machine (Ubuntu 14.04 on AWS) I am getting the following error:

RuntimeError at /portal/

cannot cache function 'filter_selection': 

no locator available for file:
'/srv/run/miniconda/envs/mbenv/lib/python2.7/site-packages/mproj/core_calcs/filter.py'

我浏览了 numba 代码库,看到了这个文件:https://github.com/numba/numba/blob/master/numba/caching.py

I looked through the numba codebase, and I saw this file: https://github.com/numba/numba/blob/master/numba/caching.py

似乎以下函数返回 None 而不是定位器,以引发此异常

It appears that the following function is returning None instead of a locator, for this exception to be raised

cls.from_function(py_func, source_path)

猜测这是写入 pycache 文件夹的权限,但我在 numba 文档中没有看到指定缓存文件夹位置 (CACHE_DIR) 的方法.

Guessing this is a permission to write the pycache folders, but I didn't see in the numba docs a way to specify the cache folder location (CACHE_DIR).

以前有人遇到过这种情况吗?如果有,建议的解决方法是什么?

Has anyone hit this before, and if so, what is the suggested work-around?

推荐答案

Set sys.frozen = True before for cls in self._locator_classes: in caching.py 可以消除这个问题.

Set sys.frozen = True before for cls in self._locator_classes: in caching.py can eliminate the issue.

我不知道这样的设置是否会影响性能.

I have no idea whether such setting will impact performance.

这篇关于numba 缓存问题:无法缓存功能/没有可用于文件的定位器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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