Skip to content
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

docs(runner): update dev container and docs #401

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
61 changes: 31 additions & 30 deletions runner/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "ai-runner",
// Image to use for the dev container. More info: https://containers.dev/guide/dockerfile.
"build": {
"dockerfile": "../Dockerfile",
// "dockerfile": "../docker/Dockerfile.text_to_speech",
"context": ".."
},
"runArgs": [
"--gpus=all"
],
// Features to add to the dev container. More info: https://containers.dev/features.
// Configure tool-specific properties.
"customizations": {
"vscode": {
"settings": {},
"extensions": [
"ms-python.python",
"ms-python.black-formatter"
]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
8000
],
// Use 'mounts' to make a list of local folders available inside the container.
"mounts": [
// "source=${localWorkspaceFolder}/models,target=/models,type=bind"
"source=${localEnv:HOME}/.lpData/models,target=/models,type=bind"
]
"name": "ai-runner",
// Image to use for the dev container. More info: https://containers.dev/guide/dockerfile.
"build": {
"dockerfile": "../Dockerfile",
// "dockerfile": "../docker/Dockerfile.text_to_speech",
"context": ".."
},
"runArgs": [
"--gpus=all"
// "--shm-size=1g" // Increase shared memory size to 1GB for GPU parallelism.
],
// Features to add to the dev container. More info: https://containers.dev/features.
// Configure tool-specific properties.
"customizations": {
"vscode": {
"settings": {},
"extensions": [
"ms-python.python",
"ms-python.black-formatter"
]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
8000
],
// Use 'mounts' to make a list of local folders available inside the container.
"mounts": [
// "source=${localWorkspaceFolder}/models,target=/models,type=bind"
"source=${localEnv:HOME}/.lpData/models,target=/models,type=bind"
]
}
48 changes: 43 additions & 5 deletions runner/dev/README.md
Original file line number Diff line number Diff line change
@@ -26,6 +26,42 @@ Leverage the [VSCode DevContainer](https://code.visualstudio.com/docs/remote/con

For more, see the [VSCode documentation on DevContainers](https://code.visualstudio.com/docs/devcontainers/containers).

### Debugging Locally

To debug the AI runner locally, follow these steps:

1. **Configure launch.json**: Add the following configuration to your `launch.json` file:

```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: LLM",
"type": "debugpy",
"request": "launch",
"module": "uvicorn",
"args": [
"app.main:app",
"--log-config",
"app/cfg/uvicorn_logging_config.json",
"--host",
"0.0.0.0",
"--port",
"8000"
],
"env": {
"PIPELINE": "text-to-image",
"MODEL_ID": "SG161222/RealVisXL_V4.0_Lightning"
}
}
]
}
```

2. **Set Breakpoints**: Add breakpoints to the code where you wish to pause execution.
3. **Launch Debugger**: Press `F5` to start the debugger.

### Debugging with External Services

To debug the AI runner when it operates within a container orchestrated by external services, such as [go-livepeer](https://github.com/livepeer/go-livepeer/tree/ai-video), follow these steps to attach to the container:
@@ -80,17 +116,19 @@ To debug the AI runner when it operates within a container orchestrated by exter
}
```

7. **Revert Changes**: After debugging, undo the debug patch.
7. **Set Breakpoints**: Add breakpoints to the code where you wish to pause execution.
8. **Launch Debugger**: Press `F5` to start the debugger.
9. **Revert Changes**: After debugging, undo the debug patch.

```bash
cd .. && git apply -R ./runner/dev/patches/debug.patch && cd runner
```

8. **Rebuild the Image**: Execute a rebuild of the image, ensuring to exclude the debug changes.
10. **Rebuild the Image**: Execute a rebuild of the image, ensuring to exclude the debug changes.

```bash
docker build -t livepeer/ai-runner:latest .
```
```bash
docker build -t livepeer/ai-runner:latest .
```

### Mocking the Pipelines