Install & Compatibility
Where this runs
tested against v1.6.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.13
✕ build_error
✕ build_error
287MB installed
● package 287MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
mxnet
✓ import mxnet as mx
ndarray
✓ from mxnet import nd
✗ import mxnet.ndarray as nd
While `import mxnet.ndarray as nd` works, the common and idiomatic way is `from mxnet import nd` or to access it via `mx.nd` after `import mxnet as mx`.
gluon
✓ from mxnet import gluon
✗ import mxnet.gluon as gluon
Similar to `ndarray`, `from mxnet import gluon` or accessing via `mx.gluon` after `import mxnet as mx` is the common pattern.
autograd
✓ from mxnet import autograd
This quickstart demonstrates defining a simple Multi-Layer Perceptron (MLP) using MXNet's Gluon API, initializing its parameters, and performing a forward pass with dummy data. It also includes a basic NDArray operation. Ensure you have the correct CPU or GPU package installed for optimal performance, and select the appropriate context (CPU/GPU).
import mxnet as mx
from mxnet import gluon, nd
from mxnet.gluon import nn
# Define a simple neural network
class MLP(nn.Block):
def __init__(self, **kwargs):
super(MLP, self).__init__(**kwargs)
self.dense0 = nn.Dense(128, activation='relu')
self.dense1 = nn.Dense(64, activation='relu')
self.dense2 = nn.Dense(10)
def forward(self, x):
x = self.dense0(x)
x = self.dense1(x)
x = self.dense2(x)
return x
# Create an instance of the network
net = MLP()
# Initialize parameters
ctx = mx.cpu(0) # Or mx.gpu(0) if GPU is available and MXNet-GPU is installed
net.initialize(mx.init.Xavier(), ctx=ctx)
# Create a dummy input (e.g., for a batch of 1 with 784 features)
dummy_input = nd.random.uniform(shape=(1, 784), ctx=ctx)
# Perform a forward pass
output = net(dummy_input)
print(f"Network output shape: {output.shape}")
# Simple tensor operation
a = nd.ones((2, 3), ctx=ctx)
b = a * 2
print(f"Simple NDArray operation result: {b.asnumpy()}")
Debug
Known issues
breakingApache MXNet has been moved to the Apache Attic as of September 2023 and is no longer actively developed or maintained. No new releases, features, or official support are expected.fixConsider migrating to actively maintained deep learning frameworks like TensorFlow or PyTorch for ongoing development and support. For existing projects, pin to `mxnet==1.9.1` and its compatible dependencies.
affects: All versions post-1.9.1
gotchaMXNet has known compatibility issues with newer versions of NumPy, often requiring older NumPy versions (e.g., `<1.20.0` or even specific versions like `1.23.5` for `1.8`) to avoid errors like `Module 'numpy' has no attribute 'bool'`.fixInstall a specific, compatible NumPy version alongside MXNet. For `mxnet==1.9.1`, `pip install numpy<1.20.0` is generally advised. Consult specific installation guides or trial-and-error with older NumPy versions if issues persist.
affects: 1.x series (especially 1.9.1 with recent NumPy)
gotchaGPU installations (`mxnet-cuXXX`) require strict matching of the installed CUDA Toolkit version with the MXNet package. With the project abandoned, there is no official support for recent CUDA versions (e.g., CUDA 12.x).fixVerify your CUDA Toolkit version using `nvcc --version` and install the corresponding `mxnet-cuXXX` package (e.g., `mxnet-cu112` for CUDA 11.2, `mxnet-cu102` for CUDA 10.2). If you have a newer CUDA version, you may need to downgrade your CUDA Toolkit or use the CPU-only MXNet package.
affects: All GPU-enabled 1.x versions
deprecatedThe (unreleased) 2.0.0 beta versions of MXNet introduced significant API changes, deprecating legacy APIs like `Model`, `Module`, `Symbol`, and the original `NDArray` API in favor of a NumPy-compatible `np` and `npx` interface and an enhanced Gluon API.fixFor the stable 1.9.1, existing Gluon and NDArray usage remains. If you were working with pre-2.0.0 beta features, be aware of the shift towards a more NumPy-like interface and Gluon for neural network construction. Given the project's abandonment, these 2.0.0 changes are largely theoretical for new users.
affects: Relevant for users attempting to use 2.0.0 beta features or migrating from older 1.x symbolic/module APIs.
Upgrade
Version history
1.9.1latest on PyPI · released May 17, 2022
Audit
Dependencies
numpyrequiredMXNet has strict and often outdated compatibility requirements with NumPy, leading to common installation and runtime errors with newer NumPy versions.