Skip to main content

Visualize and Debug Numba compiled code in Jupyter

Project description

numba-inspector

Visualize and Debug Numba compiled code in Jupyter

Quickstart

Installation

Install the package:

pip install numba-inspector

%%numba magic command

%load_ext numba_inspector
%%numba --bytecode

from numba import njit

@njit
def func(x,y):
    if x:
        x=x+1
        if y:
            y=y+1
        else:
            y=y-1
    else:
        x=x-1
        if y:
            y=y+1
        else:
            y=y-1
    return x+y

func(1,2)

View the bytecode of a jitted function (CPUDispatcher object)

Install the cudatoolkit:

conda install cudatoolkit
%%numba --ptx

from numba import cuda
import numpy as np

@cuda.jit(lineinfo=True)
def increment_by_one(an_array):
    # Thread id in a 1D block
    tx = cuda.threadIdx.x
    # Block id in a 1D grid
    ty = cuda.blockIdx.x
    # Block width, i.e. number of threads per block
    bw = cuda.blockDim.x
    # Compute flattened index inside the array
    pos = tx + ty * bw
    if pos < an_array.size:  # Check array boundaries
        an_array[pos] += 1
        
a = np.arange(4096,dtype=np.float32)
d_a = cuda.to_device(a)
blocks = 32
threads = 128
increment_by_one[blocks, threads](d_a)
cuda.synchronize()
d_a.copy_to_host()

View the PTX of CUDA kernel (CPUDispatcher object example)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

numba_inspector-0.0.5.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

numba_inspector-0.0.5-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file numba_inspector-0.0.5.tar.gz.

File metadata

  • Download URL: numba_inspector-0.0.5.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for numba_inspector-0.0.5.tar.gz
Algorithm Hash digest
SHA256 1d0e176663d438a0505d40e1754f37466877533758948bad54b50622434d4418
MD5 2fb925a64d66def3e2a6b05a6a92c2a5
BLAKE2b-256 8fde64e2ef9a8fbd9da070f7b2d5dce1366d2df37210f0ab4a69eba3974a1f37

See more details on using hashes here.

File details

Details for the file numba_inspector-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: numba_inspector-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for numba_inspector-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 fa9009d10d4b855e442e9fd289aef0177574139c1e30e7dd87a1210da5bf8c8e
MD5 52fbeac7fa554f18cd0664e3b47425d4
BLAKE2b-256 7dec97ff86c8687af75ba6ec21236840ccbd4be5feb355d928ccdc03a06ab48d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page