Con HSA_OVERRIDE_GFX_VERSION y HIP_VISIBLE_DEVICES puestas, ollama arranca avisando 'user overrode visible devices / if GPUs are not correctly discovered, unset and try again' y solo encuentra la CPU. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
211 lines
6.2 KiB
YAML
211 lines
6.2 KiB
YAML
# Ollama en chemavx-k8, bajo ArgoCD (selfHeal).
|
|
#
|
|
# 2026-07-22 — DERIVA CORREGIDA. Todo el paso de la iGPU (los 3 hostPath de
|
|
# /dev/dri, /dev/kfd y /sys/devices/virtual/kfd, sus montajes, los grupos
|
|
# suplementarios 44/109, el securityContext y las 4 variables AMD) estaba puesto
|
|
# A MANO en el objeto vivo y NO en este fichero. Sobrevivía sólo por el merge de
|
|
# tres vías: `kubectl diff` no lo borraba porque no figura en la
|
|
# last-applied-configuration, y ArgoCD lo daba por Synced. Cualquier
|
|
# reconstrucción desde git se lo habría llevado en silencio. Ahora está
|
|
# declarado: lo que se lee aquí es lo que hay.
|
|
#
|
|
# Y el motivo de que la GPU no se usara: la imagen no trae ROCm (ver el
|
|
# comentario del bloque env). Se activa el backend Vulkan, que sí viene dentro.
|
|
---
|
|
apiVersion: v1
|
|
kind: Namespace
|
|
metadata:
|
|
name: ollama
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: PersistentVolumeClaim
|
|
metadata:
|
|
annotations:
|
|
# Never let ArgoCD prune this PVC: it holds the downloaded models (20Gi).
|
|
argocd.argoproj.io/sync-options: Prune=false
|
|
name: ollama-models
|
|
namespace: ollama
|
|
spec:
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
storageClassName: local-path
|
|
resources:
|
|
requests:
|
|
storage: 20Gi
|
|
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: ollama
|
|
namespace: ollama
|
|
labels:
|
|
app: ollama
|
|
spec:
|
|
replicas: 1
|
|
strategy:
|
|
type: Recreate
|
|
selector:
|
|
matchLabels:
|
|
app: ollama
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: ollama
|
|
spec:
|
|
nodeSelector:
|
|
kubernetes.io/hostname: chemavx-k8
|
|
containers:
|
|
- name: ollama
|
|
image: ollama/ollama:0.20.7
|
|
command: ["/usr/bin/bash", "-c"]
|
|
args:
|
|
- |
|
|
ollama serve &
|
|
SERVE_PID=$!
|
|
echo "Waiting for ollama to start..."
|
|
until ollama list >/dev/null 2>&1; do
|
|
sleep 2
|
|
done
|
|
echo "Pulling qwen2.5:3b..."
|
|
ollama pull qwen2.5:3b
|
|
echo "Model ready."
|
|
wait $SERVE_PID
|
|
ports:
|
|
- name: http
|
|
containerPort: 11434
|
|
protocol: TCP
|
|
env:
|
|
- name: OLLAMA_MODELS
|
|
value: /root/.ollama/models
|
|
# El default (131072) reventaba la iGPU con un KV cache enorme.
|
|
- name: OLLAMA_NUM_CTX
|
|
value: "8192"
|
|
- name: OLLAMA_KEEP_ALIVE
|
|
value: "-1"
|
|
- name: OLLAMA_METRICS
|
|
value: "1"
|
|
# --- aceleración por la iGPU (Radeon 780M, Hawk Point) ---
|
|
# AQUÍ NO VAN HSA_OVERRIDE_GFX_VERSION NI HIP_VISIBLE_DEVICES.
|
|
# Son de ROCm, y esta imagen no trae ROCm (en /usr/lib/ollama sólo
|
|
# hay cuda_v12, cuda_v13, mlx_cuda_v13, vulkan y los backends de
|
|
# CPU; ni rocBLAS ni hipBLAS). Además de inútiles eran DAÑINAS: con
|
|
# ellas puestas, ollama arrancaba avisando «user overrode visible
|
|
# devices … if GPUs are not correctly discovered, unset and try
|
|
# again» y descubría sólo la CPU (total_vram="0 B"). Si algún día se
|
|
# pasa a la imagen con sufijo -rocm, volverán a tener sentido.
|
|
#
|
|
# OLLAMA_GPU y OLLAMA_METRICS tampoco existen para ollama: no
|
|
# aparecen en el volcado de «server config» de su propio arranque.
|
|
#
|
|
# El camino que sí sirve con esta imagen: backend Vulkan
|
|
# (experimental desde ollama 0.12.6, pensado para iGPUs AMD/Intel
|
|
# donde ROCm no llega). La imagen ya trae libggml-vulkan.so y el
|
|
# driver Mesa RADV (radeon_icd.json), así que no hace falta cambiarla.
|
|
- name: OLLAMA_VULKAN
|
|
value: "1"
|
|
resources:
|
|
requests:
|
|
memory: 4Gi
|
|
cpu: "500m"
|
|
limits:
|
|
memory: 8Gi
|
|
securityContext:
|
|
privileged: false
|
|
allowPrivilegeEscalation: false
|
|
capabilities:
|
|
add: ["SYS_PTRACE"]
|
|
volumeMounts:
|
|
- name: ollama-data
|
|
mountPath: /root/.ollama
|
|
# Paso de la iGPU sin privileged: los dispositivos del kernel amdgpu.
|
|
- name: dev-dri
|
|
mountPath: /dev/dri
|
|
- name: dev-kfd
|
|
mountPath: /dev/kfd
|
|
- name: sys-kfd
|
|
mountPath: /sys/devices/virtual/kfd
|
|
readOnly: true
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /api/tags
|
|
port: 11434
|
|
initialDelaySeconds: 60
|
|
periodSeconds: 30
|
|
failureThreshold: 5
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /api/tags
|
|
port: 11434
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 10
|
|
failureThreshold: 15
|
|
# 44=video, 109=render en chemavx-k8. Sin estos grupos el proceso no
|
|
# puede abrir /dev/kfd ni renderD128 aunque estén montados.
|
|
securityContext:
|
|
supplementalGroups: [44, 109]
|
|
seccompProfile:
|
|
type: Unconfined
|
|
volumes:
|
|
- name: ollama-data
|
|
persistentVolumeClaim:
|
|
claimName: ollama-models
|
|
- name: dev-dri
|
|
hostPath:
|
|
path: /dev/dri
|
|
type: Directory
|
|
- name: dev-kfd
|
|
hostPath:
|
|
path: /dev/kfd
|
|
type: CharDevice
|
|
- name: sys-kfd
|
|
hostPath:
|
|
path: /sys/devices/virtual/kfd
|
|
type: Directory
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: ollama
|
|
namespace: ollama
|
|
labels:
|
|
app: ollama
|
|
spec:
|
|
type: ClusterIP
|
|
selector:
|
|
app: ollama
|
|
ports:
|
|
- name: http
|
|
port: 11434
|
|
targetPort: 11434
|
|
protocol: TCP
|
|
|
|
---
|
|
apiVersion: networking.k8s.io/v1
|
|
kind: Ingress
|
|
metadata:
|
|
name: ollama
|
|
namespace: ollama
|
|
annotations:
|
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
|
traefik.ingress.kubernetes.io/router.entrypoints: websecure
|
|
spec:
|
|
ingressClassName: traefik
|
|
rules:
|
|
- host: ollama.chemavx.xyz
|
|
http:
|
|
paths:
|
|
- path: /
|
|
pathType: Prefix
|
|
backend:
|
|
service:
|
|
name: ollama
|
|
port:
|
|
number: 11434
|
|
tls:
|
|
- hosts:
|
|
- ollama.chemavx.xyz
|
|
secretName: ollama-tls
|