Requirements
- Runpod account with a verified email address.
- An API key with All access permissions to your Runpod account.
- Python 3.10, 3.11, 3.12, or 3.13 installed.
- uv installed.
Step 1: Install Flash
Flash runs natively on macOS and Linux. Windows users can run Flash through WSL2.
Optional: Install coding agent integration
If you’re using an AI coding agent like Claude Code, Cline, or Cursor, you can install the Flash skill package to give your agent detailed context about the Flash SDK:Step 2: Authenticate with Runpod
Log in to your Runpod account:Step 3: Copy this code
Create a file calledgpu_demo.py and paste this code into it:
Step 4: Run it
Execute the script:Step 5: Update and run again
With your endpoint running, make a change and run the script again:-
Open
gpu_demo.pyand change the matrix size from1000to2000: -
Run the script again:
Step 6: Understand what you just did
Let’s break down the code you just ran:Imports and setup
asyncio: Enables asynchronous execution (endpoint functions run async).Endpoint: The class that marks functions for remote execution.GpuGroup: Enum for selecting GPU types or groups of GPUs.
flash login or the RUNPOD_API_KEY environment variable.
The @Endpoint decorator
@Endpoint decorator configures everything in one place:
name: Identifies your endpoint in the Runpod console.gpu: Which GPU to use (GpuGroup.ANYaccepts any available GPU for faster provisioning).workers: Maximum parallel workers (allows 3 concurrent executions).idle_timeout: Seconds a worker stays active after completing a request before scaling down. Setting this to 300 (5 minutes) gives you more time to iterate on your code while the worker remains warm.dependencies: Python packages to install on the worker.- Function body: The matrix multiplication code runs on the remote GPU, not your local machine.
- Return value: The result is returned to your local machine as a Python dictionary.
Calling the function
@Endpoint decorated function:
- Flash checks if the endpoint specified in your decorator already exists.
- If yes: It updates the endpoint if the configuration has changed.
- If no: It creates a new endpoint, initializes a worker, and installs your dependencies.
- Flash sends your code to the GPU worker
- The GPU worker executes the function with the provided inputs.
- The result is returned to your local machine as a Python dictionary, where it’s printed in your terminal.
@Endpoint function (all the print statements, etc.) runs locally on your machine. Only the decorated function runs remotely.
Step 7: Run multiple operations in parallel
Flash makes it easy to run multiple GPU operations concurrently. Replace yourmain() function with the code below:
Clean up
When you’re done testing, clean up the endpoints:Next steps
You’ve successfully run GPU code on Runpod! Now you’re ready to learn more about Flash:Generate images with Flash
Use Stable Diffusion XL to generate images from text prompts.
Endpoint functions
Learn how to configure and optimize endpoint functions.
Build Flash apps
Deploy production APIs.
Explore Flash examples
Browse example Flash scripts and apps on GitHub.
Troubleshooting
Authentication error
flash login to authenticate with your Runpod account:
RUNPOD_API_KEY environment variable:
Template name conflict
name. If you’ve deployed an endpoint before with the same name, either:
- Use a different name for your new endpoint
- Undeploy the existing endpoint with
flash undeploy <name> --force
Job stuck in queue
GpuGroup.ANY to accept any available GPU:
Import errors
@Endpoint function: