Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/pytorch-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Update PyTorch Templates

on:
push:
branches-ignore:
- main
paths:
- "official-templates/pytorch/**"
pull_request:
paths:
- "official-templates/pytorch/**"
workflow_dispatch:
inputs:
specific_template:
description: "Specific template to update (leave empty to update all)"
required: false
type: string

jobs:
update-templates:
runs-on: ubuntu-latest-public-m
strategy:
fail-fast: false
matrix:
include:
# Map PyTorch variants to template IDs
# CUDA variants
- target: 210-py310-cuda1180-devel-ubuntu2204
template_id: runpod-torch-v21
- target: 240-py311-cuda1241-devel-ubuntu2204
template_id: runpod-torch-v240
- target: 220-py310-cuda1211-devel-ubuntu2204
template_id: runpod-torch-v220
- target: 211-py310-cuda1211-devel-ubuntu2204
template_id: runpod-torch-v211
- target: 201-py310-cuda1180-devel-ubuntu2204
template_id: runpod-torch
- target: 1131-py38-cuda1171-devel-ubuntu2204
template_id: runpod-torch-v1
# ROCM variants
- target: 240-py310-rocm610-ubuntu2204
template_id: runpod-torch-v240-rocm61
- target: 201-py310-rocm57-ubuntu2204
template_id: runpod-torch-v201-rocm57
- target: 201-py39-rocm61-ubuntu2004
template_id: runpod-torch-v201-rocm61
- target: 201-py38-rocm56-ubuntu2004
template_id: runpod-torch-v201-rocm56
- target: 211-py39-rocm60-ubuntu2004
template_id: runpod-torch-v211-rocm60
- target: 212-py310-rocm602-ubuntu2204
template_id: runpod-torch-v212-rocm602
- target: 212-py310-rocm61-ubuntu2204
template_id: runpod-torch-v212-rocm61

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Skip if specific template is set and doesn't match
id: check_template
run: |
if [[ "${{ github.event.inputs.specific_template }}" != "" && "${{ github.event.inputs.specific_template }}" != "${{ matrix.template_id }}" ]]; then
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi

- name: Make script executable
if: steps.check_template.outputs.skip != 'true'
run: chmod +x official-templates/pytorch/update-template.sh

- name: Update template via script
if: steps.check_template.outputs.skip != 'true'
env:
RUNPOD_API_KEY: ${{ secrets.RUNPOD_API_KEY }}
run: ./official-templates/pytorch/update-template.sh ${{ matrix.template_id }}
11 changes: 11 additions & 0 deletions official-templates/pytorch/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Build Instructions

- To build with the default options, simply run `docker buildx bake`.
- To build a specific target, use `docker buildx bake <target>`.
- To specify the platform, use `docker buildx bake <target> --set <target>.platform=linux/amd64`.

Example:

```bash
docker buildx bake 240-py311-cuda1241-devel-ubuntu2204 --set 240-py311-cuda1241-devel-ubuntu2204.platform=linux/amd64
```
24 changes: 13 additions & 11 deletions official-templates/pytorch/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
## Build Instructions
# PyTorch Environment

- To build with the default options, simply run `docker buildx bake`.
- To build a specific target, use `docker buildx bake <target>`.
- To specify the platform, use `docker buildx bake <target> --set <target>.platform=linux/amd64`.
Ready-to-use PyTorch + Python development environment with JupyterLab and common development tools pre-installed:

Example:
- Jupyter Notebook 6.5.5
- JupyterLab with widgets and extensions
- Pre-configured workspace directory
- SSH access
- NGINX server
- Development tools

```bash
docker buildx bake 240-py311-cuda1241-devel-ubuntu2204 --set 240-py311-cuda1241-devel-ubuntu2204.platform=linux/amd64
```
## Ports

## Exposed Ports

- 22/tcp (SSH)
| Application | Port | Type |
| ----------- | ---- | ---- |
| Jupyter | 8888 | HTTP |
| SSH | 22 | TCP |
62 changes: 62 additions & 0 deletions official-templates/pytorch/update-template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
set -e

# Check if template ID is provided
if [ -z "$1" ]; then
echo "Error: Template ID is required"
echo "Usage: $0 <template_id>"
exit 1
fi

TEMPLATE_ID=$1
README_PATH="official-templates/pytorch/README.md"
API_KEY=$RUNPOD_API_KEY

# Check if API key is set
if [ -z "$API_KEY" ]; then
echo "Error: RUNPOD_API_KEY environment variable is not set"
exit 1
fi

# Read README content
if [ ! -f "$README_PATH" ]; then
echo "Error: README file not found at $README_PATH"
exit 1
fi

# Use Node.js to escape the README content for JSON
README_JSON=$(node -e "console.log(JSON.stringify(require('fs').readFileSync('$README_PATH', 'utf8')))")

# Create GraphQL query
cat << EOF > query.json
{
"query": "mutation AdminUpdatePodTemplate(\$input: AdminUpdatePodTemplateInput!) { adminUpdatePodTemplate(input: \$input) { id name } }",
"variables": {
"input": {
"id": "$TEMPLATE_ID",
"readme": $README_JSON
}
}
}
EOF

# Execute GraphQL mutation
echo "Updating template $TEMPLATE_ID..."
response=$(curl -s -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-d @query.json \
https://api.runpod.io/graphql)

# Check for errors
if echo "$response" | grep -q "errors"; then
echo "❌ GraphQL mutation failed for template $TEMPLATE_ID:"
echo "$response"
exit 1
else
echo "✅ GraphQL mutation successful for template $TEMPLATE_ID:"
echo "$response"
fi

# Clean up
rm query.json