nvidia-mathdx

raw JSON →
25.6.0 verified Fri May 01 auth: no python

MathDx is a NVIDIA device library for accelerated math operations on GPUs, providing high-performance implementations for common mathematical functions. Version 25.6.0 is the latest. This package is part of the NVIDIA CUDA ecosystem and is updated frequently with new GPU architectures.

pip install nvidia-mathdx
error ModuleNotFoundError: No module named 'nvidia_mathdx'
cause Incorrect import statement: using hyphen instead of underscore.
fix
Use import nvidia_mathdx as mathdx (note underscore).
error AttributeError: module 'nvidia_mathdx' has no attribute 'sin'
cause Trying to import the old monolithic module; in newer versions, functions are in subpackages.
fix
Use from nvidia_mathdx.math import sin or import nvidia_mathdx.math as math.
error Segmentation fault (core dumped) when accessing GPU array on host
cause Missing CUDA stream synchronization before host-device copy.
fix
Call cupy.cuda.Stream.null.synchronize() or use cupy.asnumpy(result) which implicitly synchronizes.
breaking The package was originally distributed as a single module; in recent versions it has been split into subpackages (e.g., nvidia_mathdx.fft, nvidia_mathdx.linalg). Old code importing `nvidia_mathdx` directly may break if relying on functions that moved.
fix Update imports to use subpackages: e.g., `from nvidia_mathdx.fft import fft`.
gotcha The function `mathdx.sin` may return a GPU array that is not automatically synchronized with the host. Accessing `.get()` on the result without explicit synchronization can cause segmentation faults.
fix Use `cp.cuda.Stream.null.synchronize()` before reading results back to host, or use CuPy's default synchronization.
deprecated The top-level function `mathdx.matrix_inverse` is deprecated in favor of `mathdx.linalg.inv`.
fix Replace calls to `mathdx.matrix_inverse` with `mathdx.linalg.inv`.

Basic usage showing import pattern and calling an elementwise math function on a CuPy array.

import nvidia_mathdx as mathdx
import cupy as cp

# Create a CuPy array
a = cp.array([1.0, 2.0, 3.0, 4.0])

# Use mathdx elementwise math (example: sin)
b = mathdx.sin(a)
print(b)