Download recipe/scripts/run_nocache.py from gowombat/tiny-voca-da: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/gowombat/tiny-voca-da/resolve/main/recipe/scripts/run_nocache.py
- Command line
-
hf download hf://gowombat/tiny-voca-da/recipe/scripts/run_nocache.py
-
curl -L -o run_nocache.py https://huggingface.co/gowombat/tiny-voca-da/resolve/main/recipe/scripts/run_nocache.py
1.04 kB
| """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) | |