-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add datacenter selection example and update volume examples #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KAJdev
wants to merge
2
commits into
main
Choose a base branch
from
zeke/ae-2422-datacenter-examples
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+151
−2
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # 02_datacenters | ||
|
|
||
| Pin endpoints to specific RunPod data centers for latency, compliance, or availability reasons. | ||
|
|
||
| ## Overview | ||
|
|
||
| By default, endpoints deploy across all available data centers. The `datacenter` parameter restricts placement to one or more specific DCs. CPU endpoints are limited to a subset of DCs that support CPU serverless (see `CPU_DATACENTERS`). | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ```bash | ||
| pip install -r requirements.txt | ||
| flash run | ||
| ``` | ||
|
|
||
| ## What You'll Learn | ||
|
|
||
| - How to pin a GPU endpoint to a single datacenter | ||
| - How to deploy across multiple datacenters | ||
| - How CPU datacenter restrictions work | ||
|
|
||
| ## Available Data Centers | ||
|
|
||
| | ID | Location | | ||
| |----|----------| | ||
| | `US-GA-1` | US - Georgia | | ||
| | `US-KS-1` | US - Kansas | | ||
| | `US-TX-1` | US - Texas | | ||
| | `US-OR-1` | US - Oregon | | ||
| | `CA-MTL-1` | Canada - Montreal | | ||
| | `EU-NL-1` | Europe - Netherlands | | ||
| | `EU-CZ-1` | Europe - Czech Republic | | ||
| | `EU-RO-1` | Europe - Romania | | ||
| | `EU-NO-1` | Europe - Norway | | ||
| | `EU-SE-1` | Europe - Sweden | | ||
|
|
||
| CPU endpoints support: `EU-RO-1`, `US-TX-1`, `EU-SE-1`. | ||
|
|
||
| ## Examples | ||
|
|
||
| **Single datacenter:** | ||
|
|
||
| ```python | ||
| @Endpoint(name="us-worker", gpu=GpuGroup.ANY, datacenter=DataCenter.US_GA_1) | ||
| async def inference(data: dict) -> dict: | ||
| ... | ||
| ``` | ||
|
|
||
| **Multiple datacenters:** | ||
|
|
||
| ```python | ||
| @Endpoint( | ||
| name="global-worker", | ||
| gpu=GpuGroup.ANY, | ||
| datacenter=[DataCenter.US_GA_1, DataCenter.EU_RO_1], | ||
| ) | ||
| async def inference(data: dict) -> dict: | ||
| ... | ||
| ``` | ||
|
|
||
| **No datacenter (default, all DCs):** | ||
|
|
||
| ```python | ||
| @Endpoint(name="anywhere", gpu=GpuGroup.ANY) | ||
| async def inference(data: dict) -> dict: | ||
| ... | ||
| ``` | ||
|
|
||
| ## Project Structure | ||
|
|
||
| ``` | ||
| 02_datacenters/ | ||
| ├── gpu_worker.py # single-DC and multi-DC GPU endpoints | ||
| ├── cpu_worker.py # CPU endpoint in a supported DC | ||
| └── README.md | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,29 @@ | ||||||
| # cpu worker pinned to a cpu-supported datacenter. | ||||||
| # cpu endpoints are only available in a subset of datacenters | ||||||
| # (see CPU_DATACENTERS). selecting an unsupported DC raises an error. | ||||||
|
||||||
| # (see CPU_DATACENTERS). selecting an unsupported DC raises an error. | |
| # (see CPU_DATACENTERS). Selecting an unsupported DC raises an error. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # gpu workers pinned to specific datacenters. | ||
| # run with: flash run | ||
| from runpod_flash import Endpoint, GpuGroup, DataCenter | ||
|
|
||
|
|
||
| # pin to a single datacenter | ||
| @Endpoint( | ||
| name="04_02_gpu_us", | ||
| gpu=GpuGroup.ANY, | ||
| workers=(0, 3), | ||
| datacenter=DataCenter.US_GA_1, | ||
| ) | ||
| async def us_inference(payload: dict) -> dict: | ||
| """GPU inference pinned to US-GA-1.""" | ||
| return {"datacenter": "US-GA-1", "result": payload} | ||
|
|
||
|
|
||
| # deploy across multiple datacenters for broader availability | ||
| @Endpoint( | ||
| name="04_02_gpu_multi", | ||
| gpu=GpuGroup.ANY, | ||
| workers=(0, 3), | ||
| datacenter=[DataCenter.US_GA_1, DataCenter.EU_RO_1], | ||
| ) | ||
| async def multi_dc_inference(payload: dict) -> dict: | ||
| """GPU inference available in US-GA-1 and EU-RO-1.""" | ||
| return {"result": payload} | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| import asyncio | ||
|
|
||
| async def test(): | ||
| print("=== US datacenter ===") | ||
| print(await us_inference({"prompt": "hello"})) | ||
| print("\n=== Multi-DC ===") | ||
| print(await multi_dc_inference({"prompt": "hello"})) | ||
|
|
||
| asyncio.run(test()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Quick Start instructs
pip install -r requirements.txt, but this example directory does not include arequirements.txt. Update the instructions to reference the repo-level setup (as other examples do) or add the missing requirements file so the commands work as written.