Skip to content

GPU Acceleration

If your server has an NVIDIA graphics card, PhotoPrism can use it to run its built-in AI models for image classification, NSFW detection, and face recognition. This makes indexing faster, while image decoding and thumbnail generation still run on the CPU.

Setup

Our photoprism/photoprism:cuda image includes everything PhotoPrism needs to use an NVIDIA GPU. It is available for 64-bit Intel and AMD processors only.

In addition, you need:

Then change the image of the photoprism service in your compose.yaml and assign the GPU to it, as shown in the example below:1

services:
  photoprism:
    image: photoprism/photoprism:cuda
    deploy:
      resources:
        reservations:
          devices:
            - driver: "nvidia"
              capabilities: [gpu]
              count: 1

Finally, run docker compose pull and docker compose up -d to apply the changes. The cuda image is about 1.7 GB larger than our regular image.

Do not add onnxruntime or onnxruntime-gpu to PHOTOPRISM_INIT when using the cuda image, as it already includes the required libraries.

Checking That the GPU Is Used

When PhotoPrism loads a model, it logs a line that names the execution provider it runs on. If the GPU cannot be used, for example because it was not assigned to the container, PhotoPrism logs a warning and uses the CPU instead. Once you have fixed the cause, restart PhotoPrism so that it tries the GPU again.

The cuda image also allows hardware video transcoding with NVIDIA, which you can enable with PHOTOPRISM_FFMPEG_ENCODER: "nvidia".

What to Expect

How much faster indexing gets depends on your GPU and your CPU. With an NVIDIA GeForce RTX 4060, indexing a library of about 2,400 photos was 1.8 times faster than with an Intel Core i7-14700 alone, with identical results. An entry-level card such as an NVIDIA T400 ran the AI models no faster than a recent CPU.

During indexing, PhotoPrism used up to about 6 GB of GPU memory on the RTX 4060. If you also run Ollama on the same card, it may not have enough memory left for its model, so consider reducing the number of index workers.

Learn more ›


  1. Unrelated configuration details have been omitted for brevity. ↩