While NeuralSAT can be installed and run on any platforms satisfying its dependencies, we mainly develop and test NeuralSAT on Linux.
src: source codethird_party: external librariesvnncomp_scripts: scripts for competition
- Python 3.10 or 3.11 (recommended for best compatibility; Python 3.13+ may have package compatibility issues)
- Git (for cloning the repository)
- Gurobi: Gurobi requires a license (a free academic license is available).
git clone https://github.com/dynaroars/neuralsat.git
cd neuralsatYou can install NeuralSAT using either pip (recommended), conda with conda-forge or uv.
You can directory install all required packages by running:
pip install neuralsat- (Optional) Remove any pre-existing virtual environment
rm -rf neuralsat_env- Create a Python virtual environment
python3 -m venv neuralsat_env- Activate the virtual environment
# On Linux/Mac:
source neuralsat_env/bin/activate
# On Windows:
neuralsat_env\Scripts\activate- Install required packages
pip install -r requirements.txt- Gurobi issues? If gurobipy fails during pip install, run it separately:
pip install gurobipy- (Optional) Install specific Pytorch C++/CUDA extensions
pip install "third_party/haioc"- (Optional) Install
DNNVfor ONNX simplification
python3 -m venv dnnv_env
source dnnv_env/bin/activate
pip install --no-deps git+https://github.com/dlshriver/DNNV.git@d4f59a01810cf4dac99f8f5e5b9d7a350cbfa8d7#egg=dnnv
deactivateIf you prefer conda, use conda-forge channels (free, no licensing restrictions):
- (Optional) Remove any pre-existing NeuralSAT environment
conda deactivate
conda env remove --name neuralsat- Create a new conda environment named "neuralsat"
conda create -n neuralsat python=3.10 -c conda-forge- Activate the newly created environment
conda activate neuralsat- Install required packages from conda-forge and pip
# For GPU support (CUDA 11.8 - check your CUDA version with nvidia-smi):
conda install -c conda-forge pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
# Install other dependencies
conda install -c conda-forge numpy scipy onnx onnxruntime pillow
# Install C++ standard library only if CXXABI errors occur
conda install -c conda-forge libstdcxx-ng
# Install Gurobi (requires separate license)
conda install -c gurobi gurobi
# Install remaining packages via pip
pip install -r requirements.txtNote: Check your CUDA version with nvidia-smi. For CUDA 12.x use pytorch-cuda=12.1, for CUDA 11.x use pytorch-cuda=11.8.
If you need to manage specific Python versions (e.g., Python 3.10 for onnxsim compatibility), use uv:
- Run the setup script
./setup.sh
# Or alternatively:
bash setup.shSystem dependencies (for PyTorch/ONNX builds):
sudo apt-get update
sudo apt-get install libbz2-dev lzma liblzma-devRun NeuralSAT from the repository root directory:
If you installed with uv:
uv run src/main.py [-h] --net NET --spec SPECIf you installed with pip or conda:
python3 src/main.py [-h] --net NET --spec SPEC
[--batch BATCH] [--timeout TIMEOUT] [--device {cpu,cuda}] [--verbosity {0,1,2}]
[--result_file RESULT_FILE] [--export_cex]
[--disable_restart] [--disable_stabilize] Use -h or --help to see options that can be passed into NeuralSAT.
--net: Path toONNXmodel.--spec: Path toVNNLIBspecification file.--batch: Maximum number of parallel checking branches.--timeout: Timeout (in second) for verifying one instance.--device: Device to use (eithercpuorcuda).--verbosity: Logging options (0: NOTSET, 1: INFO, 2: DEBUG).--result_file: File to export execution results (including counter-example if found).--export_cex: Enable writing counter-example toresult_file.--disable_restart: disable RESTART heuristic.--disable_stabilize: disable STABILIZE.
Note: If you installed with uv, replace python3 with uv run in all examples below.
- Examples showing NeuralSAT verifies properties (i.e., returning `unsat``):
python3 main.py --net "example/onnx/mnistfc-medium-net-554.onnx" --spec "example/vnnlib/test.vnnlib"
# unsat,24.9284python3 main.py --net "example/onnx/cifar10_2_255_simplified.onnx" --spec "example/vnnlib/cifar10_spec_idx_4_eps_0.00784_n1.vnnlib"
# unsat,17.9806python3 main.py --net "example/onnx/ACASXU_run2a_1_1_batch_2000.onnx" --spec "example/vnnlib/prop_6.vnnlib" --disable_restart
# unsat,3.0907python3 main.py --net "example/onnx/mnist-net_256x4.onnx" --spec "example/vnnlib/prop_1_0.03.vnnlib"
# unsat,139.4125- Examples showing NeuralSAT disproves properties (i.e., returning
satand counterexample):
python3 main.py --net "example/onnx/mnist-net_256x2.onnx" --spec "example/vnnlib/prop_1_0.05.vnnlib"
# sat,0.7526python3 main.py --net "example/onnx/ACASXU_run2a_1_9_batch_2000.onnx" --spec "example/vnnlib/prop_7.vnnlib" --disable_restart
# sat,6.1320