NVIDIA cuFFT
The `nvidia-cufft` package provides the NVIDIA CUDA Fast Fourier Transform (cuFFT) native runtime libraries for Python environments. It is not a Python API itself, but rather a low-level dependency for other Python libraries (like CuPy, PyTorch, or TensorFlow) that leverage cuFFT for GPU-accelerated FFT computations. The current version is 12.2.0.37, and new versions are typically released in conjunction with NVIDIA CUDA Toolkit updates.
Warnings
- gotcha The `nvidia-cufft` package does NOT expose a direct Python API for cuFFT functions. It provides only the native runtime libraries (e.g., `.so` or `.dll` files) that other Python libraries (like CuPy, PyTorch, or TensorFlow) link against to offer GPU-accelerated FFT capabilities.
- gotcha Ensure the `nvidia-cufft` version is compatible with your installed NVIDIA CUDA Toolkit and driver version, as well as the CUDA versions targeted by other GPU-accelerated Python libraries (e.g., CuPy, PyTorch). Mismatches can lead to runtime errors, crashes, or unexpected behavior.
- gotcha For most users, `nvidia-cufft` is installed as an indirect dependency when installing other GPU-accelerated Python libraries (e.g., `cupy`). Manual installation is usually not necessary unless troubleshooting specific environment setups or dependency issues.
Install
-
pip install nvidia-cufft
Quickstart
import cupy as cp
import cupy.fft as cufft
# Ensure CUDA is available and nvidia-cufft binaries are usable by CuPy
if not cp.cuda.is_available():
print("CUDA is not available. CuPy cannot use cuFFT.")
else:
print(f"CuPy version: {cp.__version__}")
print(f"CUDA driver version: {cp.cuda.runtime.getDriverVersion()}")
print(f"CUDA runtime version: {cp.cuda.runtime.get_version()}")
# Example: Perform a 1D FFT on the GPU using CuPy
a_h = cp.arange(10, dtype=cp.float32) # Host array (CPU)
a_d = cp.asarray(a_h) # Transfer to Device (GPU)
print(f"\nOriginal array on GPU: {a_d}")
# Perform FFT on GPU using CuPy's wrapper for cuFFT
fft_result_d = cufft.fft(a_d)
print(f"FFT result on GPU: {fft_result_d}")
print("\nNote: The `nvidia-cufft` package provides the underlying native")
print("libraries that enable CuPy's GPU FFT functions to work. This")
print("package itself does not expose direct Python imports or APIs.")