taan-burapol / nuitka-numba-workaround Goto Github PK
View Code? Open in Web Editor NEWOptimizing Python Performance using Numba JIT and Nuitka AOT Compilation
License: MIT License
Optimizing Python Performance using Numba JIT and Nuitka AOT Compilation
License: MIT License
Hi, thank you for the great work!
I am trying to compile a script with Nuitka for standalone distribution, and I have 3 functions heavily relying on Numpy that in the Python execution are accelerated with Numba jit compiler (nopython, of course; I tried with forceobj and it was waaaaay slower). I put the three Numpy-Numba functions in a single separate file in the same folder as the main file, and call it with "exec" as in your example scripts (I actually duplicated the "import" statements in a separate file so I can later obfuscate everything with Marshal).
When I compile according to your instructions I obtain execution times similar to vanilla Nuitka-compiled, that is about 6 times slower than Numba jit (3 minutes vs 30 seconds).
For completeness and reproducibility, here is the command I used for compilation:
python -m nuitka myScript.py --follow-imports --standalone --include-module=numba --module-parameter=numba-disable-jit=no --include-data-file=./numba_import.py=numba_import.py --include-data-file=./numba_jit.py=numba_jit.py
As Nuitka was giving a warning about Numba jit being disabled in Nuitka standalone compilation, I added the flag
--module-parameter=numba-disable-jit=no
to the previous command, but in this case the compiled exe is not even running, and I receive errors in the function "error_rewrite" in the file "numba\core\dispatcher.py"
I am running on a Windows 10 system, in a conda environment with Python 3.10.13 and the following packages installed via pip (to avoid MKL bloating):
numpy==1.26.3
scipy==1.11.4
numba==0.59.0
ordered-set==4.1.0
nuitka==2.0.1
simpleitk==2.3.1
numpy-stl==3.1.1
Have you experienced anything similar? Is it possible to run your proposed hybrid compilation approach when imports are required? Or simply something has changed inside Nuitka after your compilation guide?
Thank you in advance.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.