Installation¶
From PyPI (recommended)¶
sweep works with any PyTorch version, but the PyTorch build has to match your NVIDIA
driver. A plain pip install sweepx pulls PyPI's default torch, which on Linux is
built for CUDA 13 and needs driver >= 580. With an older driver torch cannot start
CUDA (UserWarning: ... The NVIDIA driver on your system is too old) and
impl='c' reports no visible GPU. Install the matching torch first, then sweep:
- Which CUDA?
nvidia-smishows the newest CUDA Version your driver supports; pick that or lower. Combinations your GPU cannot run are greyed out. - Older CUDA 12 builds come with an older torch (cu121: 2.5, cu124: 2.6, cu128:
2.11, cu129: 2.13). sweep runs on all of them. CUDA 11 supports
impl='eager'only. - Wrong torch already installed? Reinstall just torch with the command above plus
--force-reinstall; sweep stays as is.
Note
sweepx (Python >= 3.10) installs the solver plus the sweep-agent companion;
pip install sweep-solver installs the solver alone (Python >= 3.9). Either way
you import sweep: the bare name sweep is taken on PyPI.
From source¶
Install torch first, as above, then:
git clone https://github.com/DeepWave-KAUST/sweep
cd sweep
pip install .
python -m sweep.build # optional: build the CUDA core now, not on the first impl='c' call
A clone carries no prebuilt core: the CUDA core is compiled once for your card (2–5 min, needs an nvcc of your torch's CUDA major) and cached.
Verification¶
Run a small forward model:
import numpy as np, torch, sweep
from sweep.equations import Acoustic
from sweep.propagator.torch import PropTorch
from sweep.signal import ricker
dev = torch.device("cuda" if torch.cuda.is_available() else "cpu")
solver = PropTorch(Acoustic(device=dev), shape=(64, 64), dh=10.0, dt=1e-3, dev=dev)
wavelet = ricker(np.arange(500) * 1e-3 - 0.1, f=15.0).astype(np.float32)
gather = solver(wavelet, np.array([[32, 4]]), np.array([[[ix, 4] for ix in range(64)]]),
models=[torch.full((64, 64), 2000.0, device=dev)])
print("sweep", sweep.__version__, "| torch", torch.__version__)
print("device:", dev, "| backend:", solver.impl)
print("gather:", tuple(gather.shape), "| finite:", bool(torch.isfinite(gather).all()))
On a GPU the output should look like:
backend: c means the compiled CUDA backend is working. If you see device: cpu on
a GPU machine, torch cannot use your GPU: reinstall it with the selector above. If you
see device: cuda | backend: eager, run python -c "import sweep; sweep.precompile()":
its error says why impl='c' is unavailable. Without a GPU, backend: eager is expected. With
g++ older than 10, torch.compile cannot build the CPU step: sweep warns and runs it uncompiled
(slower, same result).
How the core is picked, when nvcc is needed, building without a GPU and developer builds: Building the CUDA core.