1.1. Installation

This guide covers installing NLSQ and verifying your setup.

1.1.1. Basic Installation

Install NLSQ using pip:

pip install nlsq

Or using uv (recommended for faster installation):

uv pip install nlsq

1.1.2. Verify Installation

import nlsq

print(f"NLSQ version: {nlsq.__version__}")
print(f"Device: {nlsq.get_device()}")

Expected output:

NLSQ version: 0.7.0
Device: cpu  # or 'cuda:0' if GPU is available

1.1.3. GPU Support (Optional)

NLSQ uses JAX for GPU acceleration. To enable GPU support:

NVIDIA CUDA:

# Install JAX with CUDA support
pip install --upgrade "jax[cuda12_pip]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html

AMD ROCm:

pip install --upgrade "jax[rocm]" -f https://storage.googleapis.com/jax-releases/jax_releases.html

Apple Silicon (M1/M2/M3):

JAX runs on Apple Silicon via the Metal backend (experimental):

pip install jax-metal

1.1.4. Verify GPU Setup

import jax

print(f"JAX devices: {jax.devices()}")
print(f"Default backend: {jax.default_backend()}")

Expected output with GPU:

JAX devices: [CudaDevice(id=0)]
Default backend: gpu

1.1.5. Desktop GUI (Optional)

To use the interactive desktop application:

pip install nlsq

Launch with:

nlsq-gui

1.1.6. Development Installation

For development with all optional dependencies:

git clone https://github.com/imewei/NLSQ.git
cd NLSQ
pip install -e .

1.1.7. Common Installation Issues

JAX installation fails:

Try installing JAX separately before NLSQ:

pip install jax jaxlib
pip install nlsq
GPU not detected:

Ensure CUDA drivers are installed and compatible with your JAX version. Check with nvidia-smi for NVIDIA GPUs.

Import errors:

Ensure Python 3.12+ is being used:

python --version  # Should be 3.12+

1.1.8. Next Steps

Continue to Your First Curve Fit to fit your first curve.