Skip to main content
This example demonstrates using @context to train a model at worker startup and then serve inference requests through a @remote function.

Deployment

Client

What This Demonstrates

  • Using @context to train a model at worker startup
  • The context’s __aenter__ runs GPU-intensive work (training) before the worker enters “ready” state
  • Accessing the trained model in a @remote function via app.get_context()
  • Benchmark dataset with a representative zero-image input
  • Using image.venv() to point to an existing venv in the Docker image