cuTensorNet (cu12)
raw JSON → 24.10.0 verified Fri May 01 auth: no python
cuTensorNet is a component of NVIDIA cuQuantum SDK for tensor network computations, enabling efficient contraction of tensor networks on GPUs. This package (cutensornet-cu12) targets CUDA 12.x. Current version: 24.10.0. It is part of the cuQuantum Python ecosystem, maintained by NVIDIA with quarterly releases.
pip install cutensornet-cu12 Common errors
error ModuleNotFoundError: No module named 'cuquantum' ↓
cause Missing `cuquantum-python-cu12` package (the Python bindings).
fix
Run
pip install cuquantum-python-cu12. error AttributeError: module 'cutensornet' has no attribute 'NetworkOperator' ↓
cause Using wrong import path. The high-level API is in `cuquantum`, not `cutensornet`.
fix
Change to
from cuquantum import NetworkOperator. error TypeError: expected cupy.ndarray, got numpy.ndarray ↓
cause Tensor operands must be GPU arrays (CuPy).
fix
Convert NumPy arrays:
cp.asarray(numpy_array). error cuTensorNet error: CUTENSORNET_STATUS_NOT_SUPPORTED ↓
cause Tensor data type or network topology not supported on the current GPU architecture.
fix
Check cuQuantum compatibility matrix; ensure GPU compute capability >= 7.0 (Volta).
Warnings
breaking The import path for the main API changed from `cutensornet` to `cuquantum` starting in version 22.x. Code using `import cutensornet` will break. ↓
fix Change imports to `from cuquantum import ...`.
gotcha The `cutensornet-cu12` PyPI package only provides the C/CUDA native library. The Python bindings are in `cuquantum-python-cu12`. Installing only `cutensornet-cu12` is insufficient; you must also install `cuquantum-python-cu12`. ↓
fix Install both: `pip install cutensornet-cu12 cuquantum-python-cu12`.
deprecated The `cuquantum` Python package now recommends using `NetworkOperator` instead of the older `einsum` style interface. The old `cutensornet.contract` function is deprecated. ↓
fix Replace `cutensornet.contract(...)` with `NetworkOperator` and `ContractionOptimizer`.
gotcha Tensor operands must be on the GPU (CuPy or similar). Passing NumPy arrays will raise an error. ↓
fix Convert NumPy arrays to CuPy arrays before passing to `NetworkOperator`.
Imports
- NetworkOperator wrong
from cutensornet import NetworkOperatorcorrectfrom cuquantum import NetworkOperator - ContractionOptimizer wrong
from cutensornet.cutensornet import ContractionOptimizercorrectfrom cuquantum import ContractionOptimizer
Quickstart
import cupy as cp
from cuquantum import NetworkOperator, ContractionOptimizer
# Define tensor network
expr = 'ij,jk,kl->il'
operands = [
cp.random.rand(2, 3),
cp.random.rand(3, 4),
cp.random.rand(4, 2)
]
# Create network operator
net = NetworkOperator(expr, *operands)
# Optimize contraction path
optimizer = ContractionOptimizer(net)
path, cost = optimizer.optimize()
# Contract
tn_result = net.contract(path)
print(tn_result)