AlexTitovWork / numba_perfomance

NUMBA is good calculation wrapper.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Project to test the performance of NUMBA and JIT-compilation.

numba_perfomance

@created by Alex Titov( @AlexTitovWork)

NUMBA is good calculation wrapper.

Info from NUMDA site.

https://numba.readthedocs.io/en/stable/cuda/index.html
## NUMBA like np.array and don't like pandas.
## Test JIT numba compillation and cashe second start.
## NUMBA is good calculation wrapper. The efficiency of DevOps or loader is not surprising!
What is nopython mode?
The Numba @jit decorator fundamentally operates in two compilation modes, nopython mode and object mode.
In the go_fast example above, nopython=True is set in the @jit decorator,
this is instructing Numba to operate in nopython mode.
The behaviour of the nopython compilation mode is to essentially compile
the decorated function so that it will run entirely without the involvement of the Python interpreter.
This is the recommended and best-practice way to use the Numba jit decorator as it leads to the best performance.
Should the compilation in nopython mode fail, Numba can compile using object mode,
this is a fall back mode for the @jit decorator if nopython=True is not set (as seen in the use_pandas example above).
In this mode Numba will identify loops that it can compile and compile those into functions that run in machine code,
and it will run the rest of the code in the interpreter. For best performance avoid using this mode!
### USAGE:
Install on computation machine:
pip3 install --upgrade pip
pip3 install -r requirements.txt
Test NUMBA JIT compillation and caching
python compare_perfomance_py_vs_numba.py
or
Test for CUDA.JIT:
python3 cuda_numba_perfomance.py

RESULT:

Image loading time (with compilation) = 2.229041337966919

On local machine GTX 850

NVIDIA-SMI 495.29.05 Driver Version: 495.29.05 CUDA Version: 11.5

Elapsed (with compilation) = 1.7185752391815186

Elapsed (after compilation) = 4.100799560546875e-05

Elapsed (after compilation and caching) = 2.86102294921875e-05

Diagonal:
[103. 104. 104. 104. 104.]
Invert matrix:
[[-0.02483749 -0.00989922 0.02612057 0.09516573 0.00248375]
[ 0. 0.03125 -0.03125 0. -0. ]
[ 0.00602527 -0.00012553 0.02584002 -0.02578144 -0.00060253]
[ 0.01867832 -0.00038913 -0.01989593 0.02007753 -0.00186783]
[-0.00046696 -0.00780277 0.0083099 -0.02550194 0.0250467 ]]
Eigen value:
[ 5.20203783e+02 -2.84054242e+00 1.71715708e+00 -8.03980207e-02 4.62287827e-14]

On server machine GeForce RTX 2080

NVIDIA-SMI 460.91.03 Driver Version: 460.91.03 CUDA Version: 11.2

Elapsed (with compilation) = 1.0186493396759033

Elapsed (after compilation) = 1.1444091796875e-05

Elapsed (after compilation and caching) = 8.58306884765625e-06

About

NUMBA is good calculation wrapper.

License:MIT License


Languages

Language:Python 100.0%