NOTE: this required CUDA/ROCm (GPU driver) already pre-installed (since this requires root permission)
# Directly serve (without systemd user service)
~/.local/bin/ollama serve
# Test API
curl http://127.0.0.1:11434/api/tags| import asyncio | |
| import random | |
| import time | |
| from contextlib import asynccontextmanager | |
| from fastapi import FastAPI, WebSocket, WebSocketDisconnect | |
| from fastapi.responses import HTMLResponse | |
| # Store connected WebSocket clients globally | |
| connected_clients = [] | |
| # Task references to properly manage background tasks |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>EastMoney K-line Picture Viewer</title> | |
| <style> | |
| body { | |
| font-family: Arial, sans-serif; | |
| margin: 2em; | |
| } |
| .PHONY: venv install run clean | |
| # Create virtual environment | |
| venv: | |
| python3 -m venv .venv | |
| # Install dependencies | |
| install: venv | |
| . .venv/bin/activate && pip install fastapi "uvicorn[standard]" pydantic |