File size: 1,039 Bytes
adabee1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Run `python -m <module> ...` with numba's on-disk cache disabled.

tiny-voca-dk: in the kit image, loading librosa's numba cache written by another
process segfaults (cold compile is fine). With a process pool, the first worker writes
the cache and the next ones crash while loading it (BrokenProcessPool). Forcing
cache=False makes every process JIT-compile in memory; results are unchanged.

Usage: python scripts/run_nocache.py -m tiny_voca.prepare --inputs ...
"""
import runpy
import sys

import numba


def _without_cache(decorator):
    def wrapped(*args, **kwargs):
        kwargs.pop('cache', None)
        return decorator(*args, **kwargs)
    return wrapped


for _name in ('jit', 'njit', 'vectorize', 'guvectorize', 'stencil'):
    if hasattr(numba, _name):
        setattr(numba, _name, _without_cache(getattr(numba, _name)))

if len(sys.argv) < 3 or sys.argv[1] != '-m':
    raise SystemExit(__doc__)
_module = sys.argv[2]
sys.argv = [_module] + sys.argv[3:]
runpy.run_module(_module, run_name='__main__', alter_sys=True)