Skip to main content

Hardware Acceleration

SP1 supports hardware acceleration through CUDA on Nvidia GPUs and AVX256/AVX512 on Intel x86 CPUs.

GPU Acceleration

SP1 supports GPU acceleration with CUDA, which can provide dramatically better latency and cost performance compared to using the CPU prover, even with AVX acceleration.

Software Requirements

Please make sure you have the following installed before using the CUDA prover:

Hardware Requirements

  • CPU: We recommend having at least 4 CPU cores with 16GB of RAM available to fully utilize the GPU.
  • GPU: 24GB or more VRAM.

Usage

To use the CUDA prover, you have two options:

  1. Use ProverClient::from_env to build the client and set the SP1_PROVER environment variable to cuda.
  2. Use ProverClient::builder().cuda().build() to build the client.

Then, use your standard methods on the ProverClient to generate proofs.

Currently, the CUDA prover relies on a Docker image that contains state, and only utilizes the 0th GPU.

In general, the best practice is to keep an instance of a ProverClient in an Arc as they have initialization overhead. However, as the CUDA prover is "single threaded", attempting to call the methods on the CUDA prover concurrently will cause unexpected behavior and attempting to initialize a CUDA prover twice in the same process (even if the previous one was dropped) will panic.

It is recommended to store an instance of a CUDA prover in an Arc<Mutex<_>> in order to avoid any issues.

CPU Acceleration

SP1 can achieve significant CPU performance improvements through AVX vector instruction extensions. Support for both AVX256 and AVX512 acceleration on Intel x86 CPUs is provided via Plonky3. For optimal performance, we recommend using AVX512 acceleration when your hardware supports it.

Checking for AVX Support

To verify if your CPU supports AVX, run:

grep avx /proc/cpuinfo

Look for the flags avx2 and avx512 in the output.

Enabling AVX256 Acceleration

To enable AVX256 acceleration, set the RUSTFLAGS environment variable:

RUSTFLAGS="-C target-cpu=native" cargo run --release

Enabling AVX512 Acceleration

For even better performance with AVX512, use:

RUSTFLAGS="-C target-cpu=native -C target-feature=+avx512f" cargo run --release

Note that the +avx512f flag is required to enable AVX512 acceleration.