You can test the full Neural Amp Modeler (NAM) workflow without preparing an amplifier: train a model, export it, reload it, and process audio. I used a known three-tap filter as the target and trained NAM's smallest model to reproduce the same response. The experiment runs on a CPU alone and ends with a .nam file plus WAV files before and after processing.
This serves as a calibration bench before capturing a real guitar amplifier. Running through the environment setup and model round trip that stand in for the wiring first leaves fewer uncertain steps when you bring in recorded data.
I tested neural-amp-modeler 0.13.0, torch 2.13.0+cpu, and Python 3.12.13. The project publishes the NAM source under the MIT License (*1).
1. Set up an isolated environment
Our sandbox uses rootless Podman to isolate the container. It mounts the working directory and leaves the host's home directory outside the container. The setup allows network access during installation and blocks it at runtime with --network none. A standard local environment does not require this isolation. A venv alone reproduces the steps below.
Create a working directory.
mkdir -p nam-trial && cd nam-trial
2. Install a venv and CPU PyTorch
Start with a plain python:3.12-slim image and create a venv. I mount the current directory at /work, so the dependencies remain in the local .venv/ after Podman removes the container.
podman run --rm -v "$(pwd)":/work -w /work docker.io/library/python:3.12-slim \
sh -lc 'python -m venv .venv && .venv/bin/python --version && .venv/bin/pip --version'
This run reported Python 3.12.13 and pip 25.0.1.
Install CPU PyTorch. The explicit CPU index keeps CUDA binaries out of a CPU-only test. I pinned the version.
podman run --rm -v "$(pwd)":/work -w /work docker.io/library/python:3.12-slim \
.venv/bin/pip install --index-url https://download.pytorch.org/whl/cpu 'torch==2.13.0+cpu'
Pin NAM too.
podman run --rm -v "$(pwd)":/work -w /work docker.io/library/python:3.12-slim \
.venv/bin/pip install 'neural-amp-modeler==0.13.0'
In our sandbox, the outer execution layer blocked the DNS socket, so the two commands above failed in this environment. The failure came from the execution environment rather than NAM or pip, and a closed CI runner can hit the same communication error. I reran the installation from wheelhouse/, a local wheel directory that pip can read.
podman run --rm -v "$(pwd)":/work -w /work docker.io/library/python:3.12-slim \
.venv/bin/pip install --no-index --find-links wheelhouse 'torch==2.13.0+cpu' 'neural-amp-modeler==0.13.0'
With a normal network connection, use the two standard commands above. In a closed environment, prepare wheels in wheelhouse that match the target Python version, CPU architecture, and package versions. Mixing wheels from other environments can let installation finish and then fail when a shared library loads.
3. First snag: missing libtk8.6.so
Check the learning CLI with the network disabled after installation.
podman run --rm --network none -v "$(pwd)":/work -w /work docker.io/library/python:3.12-slim \
.venv/bin/nam-full --help
The command produced this error.
ImportError: libtk8.6.so: cannot open shared object file: No such file or directory
A python:*-slim or minimal Debian image may include Python's tkinter package without the linked system library libtk8.6.so. NAM 0.13.0 imports nam.train.core while nam-full starts, and that import chain loads tkinter. A CLI that skips the GUI hits the dependency.
Install tk-dev in the container image and rebuild it. Adding another Python package to the venv will not supply this system library.
Save the following as Dockerfile.
FROM docker.io/library/python:3.12-slim
RUN apt-get update && apt-get install -y --no-install-recommends tk-dev && rm -rf /var/lib/apt/lists/*
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install --quiet --index-url https://download.pytorch.org/whl/cpu torch
RUN pip install --quiet neural-amp-modeler
WORKDIR /work
Build the image.
podman build -t nam-sandbox .
During this rebuild, Podman reused the verified layers from the same Dockerfile, so all seven steps came from its cache. The final image ID was 5f92b1eb1ed9029ae46e99a7a0ed3a341ac96dd2521cb4abc9543d14629b0b2.
Check the dependencies and Tk.
podman run --rm --network none -v "$(pwd)":/work -w /work nam-sandbox \
sh -lc '.venv/bin/pip check && .venv/bin/python -c "import tkinter; print(f\"Tk={tkinter.TkVersion}\")"'
The command returned No broken requirements found. and Tk=8.6. Check the installed versions as well.
podman run --rm --network none -v "$(pwd)":/work -w /work nam-sandbox \
sh -lc '.venv/bin/python --version && .venv/bin/pip show torch neural-amp-modeler | sed -n "/^Name:/p;/^Version:/p" && .venv/bin/pip check'
4. Choose the headless CLI
Rerun nam-full with the repaired image.
podman run --rm --network none -v "$(pwd)":/work -w /work nam-sandbox \
.venv/bin/nam-full --help
The command showed the four positional arguments for training: data configuration, model configuration, training configuration, and output path. The CLI provides --no-show, which skips opening the graph, and --no-plots, which skips creating graphs.
The log may begin with the warning joblib will operate in serial mode in a strict container without shared memory. Our sandbox does not provide /dev/shm, so joblib gave up on parallel processing and fell back to serial execution. The warning does not affect the CLI or this small training run. The demo code calls torch.set_num_threads(1) to make CPU execution explicit. In a normal Podman or Docker environment, the runtime mounts /dev/shm into the container by default, so a full training run can use a parallel data loader without this warning.
Headless servers present another snag. nam --help launches the GUI before it processes the help option.
podman run --rm --network none -v "$(pwd)":/work -w /work nam-sandbox \
.venv/bin/nam --help
The command returned this error.
_tkinter.TclError: no display name and no $DISPLAY environment variable
The nam entry point is a GUI launcher, so it creates a Tk window before handling --help. This issue is separate from the missing Tk library. X11 forwarding can provide a desktop display, but a server run needs nam-full or the Python API, so use one of those paths.
The Python wheel for 0.13.0 included no executables named loadmodel or benchmodel. The published entry points were these three:
find .venv/bin -maxdepth 1 -type f -printf '%f\n' | sort | rg 'nam|model|bench|load'
The output was nam, nam-full, and nam-hello-world. I used nam.models.Linear, export() to write a .nam file, and init_from_nam() to reload it.
5. Train a small NAM on synthetic data
Without a real amplifier recording, you can test whether the learner memorizes a known transformation and whether the exported model returns the same sound. I used a three-tap filter, [0.20, 0.60, 0.20], as the target. NAM uses a Linear model with a receptive field of 3 and no bias.
Save the following as demo_train_export.py.
from __future__ import annotations
import json
from pathlib import Path
import numpy as np
import torch
import torch.nn.functional as F
from scipy.io import wavfile
from nam.models import Linear, init_from_nam
torch.manual_seed(7)
torch.set_num_threads(1)
sample_rate = 48_000
target_weights = torch.tensor([0.20, 0.60, 0.20])
train_input = torch.randn(1, 8_192)
train_target = F.conv1d(
train_input[:, None], target_weights[None, None]
)[:, 0]
model = Linear(receptive_field=3, bias=False, sample_rate=sample_rate)
optimizer = torch.optim.Adam(model.parameters(), lr=0.05)
with torch.no_grad():
initial_loss = F.mse_loss(
model(train_input, pad_start=False), train_target
).item()
for _ in range(200):
prediction = model(train_input, pad_start=False)
loss = F.mse_loss(prediction, train_target)
optimizer.zero_grad()
loss.backward()
optimizer.step()
model.eval()
with torch.no_grad():
final_loss = F.mse_loss(
model(train_input, pad_start=False), train_target
).item()
results = Path("results")
results.mkdir(exist_ok=True)
model.export(results, include_snapshot=True, basename="synthetic_fir")
nam_path = results / "synthetic_fir.nam"
with nam_path.open() as file:
exported = json.load(file)
reloaded = init_from_nam(exported).eval()
seconds = 1.0
t = torch.arange(int(sample_rate * seconds)) / sample_rate
audio_in = 0.40 * torch.sin(2 * torch.pi * 220 * t)
audio_in += 0.15 * torch.sin(2 * torch.pi * 12_000 * t)
with torch.no_grad():
audio_out = model(audio_in, pad_start=True)
reloaded_out = reloaded(audio_in, pad_start=True)
wavfile.write(results / "input.wav", sample_rate, audio_in.numpy().astype(np.float32))
wavfile.write(
results / "processed.wav",
sample_rate,
audio_out.numpy().astype(np.float32),
)
learned_weights = model._net.weight.detach().flatten()
max_reload_delta = torch.max(torch.abs(audio_out - reloaded_out)).item()
input_spectrum = torch.abs(torch.fft.rfft(audio_in))
output_spectrum = torch.abs(torch.fft.rfft(audio_out))
gain_220 = 20 * torch.log10(output_spectrum[220] / input_spectrum[220])
gain_12000 = 20 * torch.log10(output_spectrum[12_000] / input_spectrum[12_000])
print(f"torch={torch.__version__}")
print(f"cuda_available={torch.cuda.is_available()}")
print(f"device={learned_weights.device}")
print(f"initial_mse={initial_loss:.9f}")
print(f"final_mse={final_loss:.12f}")
print("target_weights=" + ",".join(f"{value:.6f}" for value in target_weights))
print("learned_weights=" + ",".join(f"{value:.6f}" for value in learned_weights))
print(f"architecture={exported['architecture']}")
print(f"sample_rate={exported['sample_rate']:.0f}")
print(f"exported_weight_count={len(exported['weights'])}")
print(f"reload_max_abs_delta={max_reload_delta:.12f}")
print(f"gain_220_hz_db={gain_220.item():.6f}")
print(f"gain_12000_hz_db={gain_12000.item():.6f}")
for path in sorted(results.iterdir()):
print(f"artifact={path.name} bytes={path.stat().st_size}")
Run it with the network disabled.
podman run --rm --network none -v "$(pwd)":/work -w /work nam-sandbox \
.venv/bin/python demo_train_export.py
Training reduced the mean squared error from 1.303633213 to 0.000000000516 after 200 steps. The target weights were 0.200000, 0.600000, 0.200000, and the learned weights were 0.200008, 0.600018, 0.199988. CUDA remained unused, and the output reported device=cpu.
I loaded the exported .nam file as a new model with init_from_nam() and processed the same one-second sound. The maximum absolute difference before and after export was 0.000000000000. The 220 Hz gain was -0.001320 dB, so it stayed near zero. The 12 kHz gain was -4.437128 dB. The learned filter acts on a real audio array.
6. Plot the frequency response
Numbers alone make the low-pass behavior harder to see, so I calculated the frequency response from the exported .nam weights and plotted it. I used scipy.signal.freqz to calculate the transfer function of the three-tap filter and overlaid the two measured points from above, 220 Hz and 12 kHz.
import json
from pathlib import Path
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import numpy as np
from scipy.signal import freqz
results = Path("results")
with (results / "synthetic_fir.nam").open() as f:
exported = json.load(f)
weights = np.array(exported["weights"], dtype=np.float64)
sample_rate = exported["sample_rate"]
w, h = freqz(weights, worN=4096, fs=sample_rate)
mag_db = 20 * np.log10(np.maximum(np.abs(h), 1e-12))
fig, ax = plt.subplots(figsize=(9, 4.4), dpi=200)
ax.plot(w, mag_db, linewidth=2)
ax.set_xscale("log")
ax.set_xlim(20, sample_rate / 2)
ax.set_xlabel("Frequency (Hz)")
ax.set_ylabel("Magnitude (dB)")
fig.savefig(results / "frequency_response.png")
podman run --rm --network none -v "$(pwd)":/work -w /work nam-sandbox \
.venv/bin/python demo_plot.py
The script produced results/frequency_response.png at 69,767 bytes. The curve stays near 0 dB around 220 Hz, begins to attenuate toward 12 kHz, and matches the two measured points.
7. Inspect the .nam and WAV files
Because .nam files use JSON, you can inspect their contents in place.
podman run --rm --network none -v "$(pwd)":/work -w /work nam-sandbox \
.venv/bin/python -m json.tool results/synthetic_fir.nam
The JSON reported architecture as Linear, receptive_field as 3, and sample_rate as 48000. The weights field contains the three learned values.
Record the file sizes and hashes.
podman run --rm --network none -v "$(pwd)":/work -w /work nam-sandbox \
sh -lc 'ls -lh results && sha256sum results/*'
The output contained a 354-byte synthetic_fir.nam, 188 KiB each for input.wav and processed.wav, and 563 KiB each for the input and output snapshots. NAM generated the snapshots because the script passed include_snapshot=True.
Conclusion
You can import NAM in an isolated CPU environment, train a model, export it to .nam, reload it with the same result, and apply the effect to WAV audio. The files and numeric results on disk record all five results.
To move to a real amplifier, replace the synthetic input and three-tap filter output with a DI signal and a time-aligned recording through the amplifier. Move the model size and training settings into a nam-full configuration file. The image with Tk, CPU PyTorch, network-disabled execution, and .nam round-trip validation remain the same foundation.
The run ends with a plugin-ready model format, audio before and after processing, proof of a matching reload, and minimal code you can adapt to real recordings.
Sources
*1 Neural Amp Modeler, GitHub, https://github.com/sdatkinson/neural-amp-modeler, MIT License