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
0 answers

How can I reuse a Numba device / cuda function on the CPU?

I have a numba device function that can be executed on a machine wit a CUDA GPU? def kernel_test(window, kernel): np_dmisc = cuda.to_device(np.array([window])) kernel[80, 64](np_dmisc) cuda.synchronize() @cuda.jit(device=True) def…
Edy Bourne
  • 5,679
  • 13
  • 53
  • 101
0
votes
1 answer

Matrix multiplication with a transposed NumPy array using Numba JIT does not work

Environment OS: Windows 10 Python version: 3.10 Numba version: 0.57.0 NumPy version: 1.24.3 Example import numpy as np from numba import njit @njit def matmul_transposed(a: np.ndarray, b: np.ndarray) -> np.ndarray: # return a @ b.T # also…
VaNa
  • 311
  • 4
  • 17
0
votes
0 answers

numba jitclass with dictionary key tuple

Below code works with @jit, but does not work with jitclass on Dict.empty. Is it that jitclass does not support the dictionary with tuple key while @jit supports it? from numba import types, njit from numba.experimental import jitclass from…
tompal18
  • 1,164
  • 2
  • 21
  • 39
0
votes
0 answers

Running a parallelized numba-function with 1 thread is faster than the non-parallelized version

I have to perform a lot of small matrix multiplications and tried to parallelize the code with numba. If I compile the same function with parallel=True one time and with parallel=False the other, the parallelized function is faster even if I set…
TheIdealis
  • 707
  • 5
  • 13
0
votes
0 answers

Connected components in graph with numba: "native lowering" error

I am trying to compute all connected components in a graph using numba. The graph is given as a 2D numpy array (E, 2), where each edge is specified by two node identifiers (integer). I have written the following…
Qnze
  • 1
0
votes
1 answer

Singularity and numba/numpy: RuntimeError: Attempted to compile AOT function without the compiler used by `numpy.distutils` present

My software is written in Python and uses numba and numpy. I distribute it using Docker. Here is the Dockerfile. One of my users (see GitHub issue) wants to run the software on a HPC where Singularity is used instead of Docker. He gets the following…
MrTomRod
  • 345
  • 2
  • 16
0
votes
1 answer

Getting 'unsupported array index type unicode_type' error when selecting a column based on condition in Numba with NumPy structured array

I am trying to select a column of a structured NumPy array. The column to be selected depends on a condition that will be passed to the function. Numba throws the error below when I try to select the column name based on the condition. Otherwise…
D.Manasreh
  • 900
  • 1
  • 5
  • 9
0
votes
1 answer

Calling specific element from numpy array without using a tuple

I have a numpy array with several dimensions, similar to the following one: dimensions = (3, 4, 5, 6) table = np.full(dimensions, np.nan) Using a tuple it wouldn't be a big deal calling a specific element from this table using: element = tuple(1,…
Jonathan
  • 1
  • 1
0
votes
0 answers

The use load_from_data_pointer() instead in Numba

I am getting the following error when hitting a function in nopython mode. File "/home/ws10/.local/lib/python3.10/site-packages/numba/core/dispatcher.py", line 487, in _compile_for_args raise e File…
peakcipher
  • 51
  • 1
  • 7
0
votes
0 answers

Issues with Scipy.optimize.fsolve on a numba'd function

I'm working on trying to find zeros of a function that I've used numba for using scipy.optimize.fsolve. The function is below. The exact details aren't important, but the jist is that F_curr is a 2D numpy array that stores information on the…
Minty
  • 1
0
votes
1 answer

How to properly specify the type of a local array in Numba?

I have a local array declared in a cuda-compiled numba kernel: from numba import cuda, types @cuda.jit((types.void(), device=True) def A(): arr = cuda.local.array(30, dtype=types.int64) I need then to pass this array to another cuda compiled…
Edy Bourne
  • 5,679
  • 13
  • 53
  • 101
0
votes
0 answers

@njit(parallel=True) making code run slower on new laptop

I've recently gotten a new laptop, with better performance (in theory) but the same code I wrote on my old laptop, where i use @njit(parallel=True) to speed up functions using numpy and loops is now causing the code to run much slower. Any ideas? I…
0
votes
0 answers

use load_from_data_pointer() instead error in Numba

Using Numba on one of my function in nopython=True mode is giving me following error Failed in nopython mode pipeline (step: nopython frontend) Internal error at . Failed in nopython mode…
peakcipher
  • 51
  • 1
  • 7
0
votes
0 answers

numba error when compiling python script to exe

I have a python script that I have compiled into an exe. The script runs perfect in vscode but compiling to exe breaks it. The block of code that seems to be causing the error is: @njit() def mahalanobis_distance(xj, ai,sigma): inverse =…
0
votes
0 answers

Numba type error cannot store {i8*, i32, i8*, i8*, i32}* to i8*: mismatching types

I'm having issues converting simple python code to Numba, already spent hours on ChatGPT3 and the issue persisted, saying Failed in nopython mode pipeline (step: native lowering) cannot store {i8*, i32, i8*, i8*, i32}* to i8*: mismatching types I…
Diogo Neiss
  • 97
  • 2
  • 9