cloudrun-gpus-opencv-cuda-demo

APACHE-2.0 License

Stars
5

crGPU - OpenCV CUDA accelerated demo on Google Cloud Run with GPU support

crGPU is simple demo that leverages GPUs on Cloud Run to accelerate OpenCV workloads with CUDA.

Features

  • This sample demo uses Farneback algorithm for estimating optical flow. It supports both CPU and GPU (CUDA based) implementations from OpenCV.

Getting Started

Prerequisites

  • Python 3.x
  • Docker
  • Terraform
  • Google Cloud Storage bucket

Local Setup

  1. Clone this repository
  1. Build the container
  1. Start the Docker containers
  1. Access the application at: http://localhost:8080

Deploying directly to Cloud Run

  1. Build the image
  1. Push
  1. Deploy
  1. (optional) Set GCP bucket as the storage backend

Deploying with Cloud Build / Cloud Deploy

  1. Create a GCS bucket (ideally in the same region where you will deploy this demo)
  2. In the root project folder, execute Cloud Build
  1. Get the URL where the demo was deployed
  1. Check the available substitutions inside cloudbuild.yaml for more tailored configuration (_CPU_QTY: '8', _GPU_QTY: '1', _MAX_INSTANCES: '3', _MEMORY: 32Gi, _GPU: nvidia-l4)

Usage

Open the local or deployed url and select whether you want the video to be processed on the CPU or the GPU. Also select the post-processing effect and the resolution. Compare the stats for multiple resolutions to observe what improvments in performance GPUs bring.

Disclaimer

⚠️ Warning This demo in its default state uses relatively expensive GPU resources. Running this demo for an extended amount of time may incur significant costs.

License

Apache License 2.0. See the LICENSE file.

This is not an officially supported Google product