{"id":24130,"library":"nvidia-mathdx","title":"nvidia-mathdx","description":"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.","status":"active","version":"25.6.0","language":"python","source_language":"en","source_url":"https://github.com/NVIDIA/MathDx","tags":["gpu","cuda","math","nvidia","array","high-performance"],"install":[{"cmd":"pip install nvidia-mathdx","lang":"bash","label":"Standard PyPI install"}],"dependencies":[{"reason":"MathDx often depends on CuPy for array operations and GPU context.","package":"cupy-cuda12x","optional":true},{"reason":"Required for CUDA runtime if using MathDx kernels directly.","package":"nvidia-cuda-runtime-cu12","optional":true}],"imports":[{"note":"The package name uses underscore, not hyphen.","symbol":"mathdx","correct":"import nvidia_mathdx as mathdx"}],"quickstart":{"code":"import nvidia_mathdx as mathdx\nimport cupy as cp\n\n# Create a CuPy array\na = cp.array([1.0, 2.0, 3.0, 4.0])\n\n# Use mathdx elementwise math (example: sin)\nb = mathdx.sin(a)\nprint(b)","lang":"python","description":"Basic usage showing import pattern and calling an elementwise math function on a CuPy array."},"warnings":[{"fix":"Update imports to use subpackages: e.g., `from nvidia_mathdx.fft import fft`.","message":"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.","severity":"breaking","affected_versions":">=24.12.0"},{"fix":"Use `cp.cuda.Stream.null.synchronize()` before reading results back to host, or use CuPy's default synchronization.","message":"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.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace calls to `mathdx.matrix_inverse` with `mathdx.linalg.inv`.","message":"The top-level function `mathdx.matrix_inverse` is deprecated in favor of `mathdx.linalg.inv`.","severity":"deprecated","affected_versions":">=25.03.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use `import nvidia_mathdx as mathdx` (note underscore).","cause":"Incorrect import statement: using hyphen instead of underscore.","error":"ModuleNotFoundError: No module named 'nvidia_mathdx'"},{"fix":"Use `from nvidia_mathdx.math import sin` or `import nvidia_mathdx.math as math`.","cause":"Trying to import the old monolithic module; in newer versions, functions are in subpackages.","error":"AttributeError: module 'nvidia_mathdx' has no attribute 'sin'"},{"fix":"Call `cupy.cuda.Stream.null.synchronize()` or use `cupy.asnumpy(result)` which implicitly synchronizes.","cause":"Missing CUDA stream synchronization before host-device copy.","error":"Segmentation fault (core dumped) when accessing GPU array on host"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}