Questions tagged [numba]

Numba is an open source NumPy-aware optimizing compiler for Python.

Numba is an Open Source NumPy-aware optimizing compiler for Python sponsored by Continuum Analytics, Inc. It uses the remarkable LLVM compiler infrastructure to compile Python syntax to machine code.

It is aware of NumPy arrays as typed memory regions and so can speed-up code using NumPy arrays. Other, less well-typed code will be translated to Python C-API calls effectively removing the "interpreter" but not removing the dynamic indirection.

Numba is also not a tracing jit. It compiles your code before it gets run either using run-time type information or type information you provide in the decorator.

Numba is a mechanism for producing machine code from Python syntax and typed data structures such as those that exist in NumPy.

Source: README.rst of the Numba project (GitHub).

More informations about the package can be found on the Numba homepage and documentation.

2244 questions
0
votes
2 answers

Automatic parallelization with @jit

I want to make use of the numba Automatic parallelization with @jit, to help me speed runing my function as i am using very larg inputs, i have no experience with parralisation before, i tried several solutions using multiprocessing, i had many…
0
votes
0 answers

Numba's parallelized logistic regression example

I'm having a difficulty understanding how the loop in this logistic regression example from Numba's documentation (https://numba.readthedocs.io/en/stable/user/parallel.html#numba-parallel) could be parallelized: @numba.jit(nopython=True,…
0
votes
1 answer

Fast way of getting all positions of the elements of a sub-list

I'm trying to obtain all positions of a sub-list of elements taken from a big list. In Python, using numpy, say I have from datetime import datetime as dt import numpy as np from numba import jit, int64 n, N = 20, 120000 int_vocabulary =…
FraSchelle
  • 249
  • 4
  • 10
0
votes
0 answers

Stack overflow "-1073741571 (0xC00000FD)" when activating parallelization in Numba, no recursive functions

I am working on Python 3.10, Pycharm IDE. I have this quite long code with loops that I accelerated using numba. The code runs fine if I don't add the flag (parallel=True) to the decorator @njit, but if I do, the error Process finished with exit…
0
votes
0 answers

numba prints do not show (until I interrupt the ipynb kernel), buffering

How do I set something like pythonunbuffered=1 but for numba? It works fine in terminal, lines get printed sequentially as expected, but in my ipynb it prints many lines at once always. @numba.njit def test_print(): for i in range(100000): …
Adam
  • 1,724
  • 4
  • 21
  • 31
0
votes
1 answer

Numba how to use dict in a class

as specified below, the dict should have keys 2-tuples of int and values ints. from numba.experimental import jitclass import numba @jitclass({'shape': numba.types.Tuple((numba.int32, numba.int32)), 'dict':…
Adam
  • 1,724
  • 4
  • 21
  • 31
0
votes
1 answer

Is cuda.to_device asynchronous?

Does cuda.to_device use the same stream as kernel launches? It seems that memcpy is synchronous (with respect to the host). from numba import cuda import numpy as np A = np.ones((10000, 10000)) %timeit cuda.to_device(A) 188 ms ± 5.3 ms per loop…
BPDev
  • 397
  • 1
  • 9
0
votes
1 answer

Numba: how to get indexes for all rows that contain at least one nan values?

Suppose I have a numpy 2d array (m by n), I want to get indexes of all its rows contain at least one nan values. It is relatively straightforward to do it in pure numpy as follows: import numpy as np X = np.array([[1, 2], [3, np.nan], [6,…
Keptain
  • 147
  • 7
0
votes
0 answers

Join arrays in numba

I am having trouble neatly joining numpy arrays that are in a list or from a generator in numba jited functions. The simplest example is as follows: import numpy as np from numba import njit @njit def my_program(): array_1 = np.array([0,3]) …
Patrick
  • 53
  • 5
0
votes
0 answers

How can I write a faster Lempel-Ziv complexity calculator function, for a time series, in Python?

I'm trying to improve upon the execution time of the below function for large input arrays (of a time series with 5-10 million data points). After trying different variations for hours (and not quite understanding the numda documentation) I figured…
0
votes
1 answer

Calling functions on arrays moved to GPU with Numba

I didn't think we could print anything from the GPU since calling print inside a @cuda.jit function doesn't work, but then I tried calling A.shape to see what would happen. import numpy as np from numba import cuda A = np.random.randn(1000,…
BPDev
  • 397
  • 1
  • 9
0
votes
1 answer

How to calculate the correlation coefficient on a rolling window of a vector using numba?

People were kind enough to explain : How to calculate the correlation coefficient on a rolling window of a vector using numpy? with this answer where I picked up: f_PH_numpy is my approach, which uses the sliding_window_view and the vectorized…
tibibou
  • 164
  • 10
0
votes
0 answers

Pyodide with numba compiled .so library

I have a python library which has a numba AOT compile function into a .so file. I am trying to bundle this into a pyodide wheel. When I examine the wheel file, the .so file (or webasm version) is missing. First installed: mamba install…
Seraj Ahmad
  • 405
  • 6
  • 10
0
votes
1 answer

Numba cannot resolve function (np.digitize)

I get an error by numba, it is complaining it can't resolve a function. The minimal code to reproduce my errors is import numba import numpy as np @numba.jit("float64(float64)", nopython=True) def get_cut_tight_nom(eta): binning_abseta =…
Ruggero Turra
  • 16,929
  • 16
  • 85
  • 141
0
votes
0 answers

Numba JIT on static method works on one computer but throws an error on another

I have a static method that I want to speed up with Numba: @nb.njit def numba_loop_choice(population, weights, k): wc = np.cumsum(weights) m = wc[-1] sample = np.empty(k, population.dtype) sample_idx = np.full(k, -1, np.int32) i…
Nik
  • 1,093
  • 7
  • 26
1 2 3
99
100