Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a352d2e15 | ||
|
|
1e5b301000 | ||
|
|
a7d3e9373a | ||
|
|
fbf567f942 | ||
|
|
6f052cf738 | ||
|
|
938ca2b268 | ||
|
|
6e311050e5 | ||
|
|
ebc420656a | ||
|
|
e39fabd31c |
No files matched your search
+30
-5
@@ -80,6 +80,23 @@ if ($TotalRamGb -lt 3.5) {
|
|||||||
}
|
}
|
||||||
Ok "RAM: $TotalRamGb GB"
|
Ok "RAM: $TotalRamGb GB"
|
||||||
|
|
||||||
|
# --- Tumbar deploy previo (antes de detectar puertos) -----------------------
|
||||||
|
cmd /c docker rm -f d0a1-hermes-ollama '>' NUL '2>&1'
|
||||||
|
Info 'Deploy previo detenido (rm; volumen con el modelo intacto).'
|
||||||
|
|
||||||
|
# --- GPU NVIDIA? (si hay, Ollama la usa y va 5-10x mas rapido) ---------------
|
||||||
|
$HasGpu = $false
|
||||||
|
if (Get-Command nvidia-smi -ErrorAction SilentlyContinue) {
|
||||||
|
$GpuInfo = & nvidia-smi --query-gpu=name,memory.total --format=csv,noheader 2>$null
|
||||||
|
if ($LASTEXITCODE -eq 0 -and $GpuInfo) {
|
||||||
|
$HasGpu = $true
|
||||||
|
$GpuName = ($GpuInfo -split ',')[0].Trim()
|
||||||
|
Info "GPU NVIDIA detectada: $GpuName (aceleracion activada)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (-not $HasGpu) {
|
||||||
|
Warn 'Sin GPU NVIDIA: modo CPU (~10-20 tokens/s). Con una GPU NVIDIA va 5-10x mas rapido.'
|
||||||
|
}
|
||||||
# --- Auto-detect Ollama port ------------------------------------------------
|
# --- Auto-detect Ollama port ------------------------------------------------
|
||||||
$OllamaPort = Find-FreePort 11434
|
$OllamaPort = Find-FreePort 11434
|
||||||
|
|
||||||
@@ -96,10 +113,11 @@ Write-Host ''
|
|||||||
|
|
||||||
# --- 1. Arrancar Ollama (Docker) -------------------------------------------
|
# --- 1. Arrancar Ollama (Docker) -------------------------------------------
|
||||||
Warn '[1/3] Arrancando Ollama (IA local)...'
|
Warn '[1/3] Arrancando Ollama (IA local)...'
|
||||||
cmd /c docker rm -f d0a1-hermes-ollama '>' NUL '2>&1'
|
|
||||||
$running = docker ps --format '{{.Names}}' | Select-String -Quiet 'd0a1-hermes-ollama'
|
$running = docker ps --format '{{.Names}}' | Select-String -Quiet 'd0a1-hermes-ollama'
|
||||||
if (-not $running) {
|
if (-not $running) {
|
||||||
docker run -d --name d0a1-hermes-ollama `
|
$GpuArgs = @()
|
||||||
|
if ($HasGpu) { $GpuArgs = @('--gpus', 'all') }
|
||||||
|
docker run -d --name d0a1-hermes-ollama --memory 6g @GpuArgs `
|
||||||
-p "${OllamaPort}:11434" `
|
-p "${OllamaPort}:11434" `
|
||||||
-v d0a1_hermes_ollama:/root/.ollama `
|
-v d0a1_hermes_ollama:/root/.ollama `
|
||||||
-e OLLAMA_HOST=0.0.0.0 `
|
-e OLLAMA_HOST=0.0.0.0 `
|
||||||
@@ -125,18 +143,24 @@ Warn ' Descargando modelo (llama3.2:3b, ~2 GB)...'
|
|||||||
# Si el usuario define $env:HTTPS_PROXY, Ollama lo usa para el pull (doc oficial):
|
# Si el usuario define $env:HTTPS_PROXY, Ollama lo usa para el pull (doc oficial):
|
||||||
$ProxyEnv = @()
|
$ProxyEnv = @()
|
||||||
if ($env:HTTPS_PROXY) { $ProxyEnv = @('-e', "HTTPS_PROXY=$env:HTTPS_PROXY", '-e', "HTTP_PROXY=$env:HTTP_PROXY") }
|
if ($env:HTTPS_PROXY) { $ProxyEnv = @('-e', "HTTPS_PROXY=$env:HTTPS_PROXY", '-e', "HTTP_PROXY=$env:HTTP_PROXY") }
|
||||||
|
# --- Modelo ya presente? (volumen persistente: no re-descargar) ------------
|
||||||
|
$ModelList = docker exec d0a1-hermes-ollama ollama list 2>$null
|
||||||
|
if ("$ModelList" -match 'llama3.2:3b') {
|
||||||
|
Info 'Modelo llama3.2:3b ya descargado (volumen intacto). Omitiendo descarga.'
|
||||||
|
} else {
|
||||||
# --- Modelo: HF primero (CDN propio, rapido) y registry de Ollama como ultimo recurso ---
|
# --- Modelo: HF primero (CDN propio, rapido) y registry de Ollama como ultimo recurso ---
|
||||||
|
|
||||||
$Gguf = Join-Path $ScriptDir 'llama3.2-3b-q4.gguf'
|
$Gguf = Join-Path $ScriptDir 'llama3.2-3b-q4.gguf'
|
||||||
$HfUrls = @(
|
$HfUrls = @(
|
||||||
'https://huggingface.co/bartowski/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf',
|
'https://huggingface.co/bartowski/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf',
|
||||||
'https://huggingface.co/unsloth/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf'
|
'https://huggingface.co/unsloth/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf'
|
||||||
)
|
)
|
||||||
foreach ($Url in $HfUrls) {
|
|
||||||
Info 'Descargando modelo de IA (llama3.2:3b, ~2 GB)...'
|
Info 'Descargando modelo de IA (llama3.2:3b, ~2 GB)...'
|
||||||
curl.exe -sL --retry 3 --max-time 1800 -o "$Gguf" $Url
|
foreach ($Url in $HfUrls) {
|
||||||
|
curl.exe -# -L --retry 3 --max-time 1800 -o "$Gguf" $Url
|
||||||
if ($LASTEXITCODE -eq 0 -and (Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) { break }
|
if ($LASTEXITCODE -eq 0 -and (Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) { break }
|
||||||
Warn "Mirror no accesible, probando el siguiente..."
|
|
||||||
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
|
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
|
||||||
|
if ($Url -ne $HfUrls[-1]) { Warn 'Mirror no accesible, probando el siguiente...' }
|
||||||
}
|
}
|
||||||
if ((Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) {
|
if ((Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) {
|
||||||
Info 'Importando modelo en Ollama...'
|
Info 'Importando modelo en Ollama...'
|
||||||
@@ -166,6 +190,7 @@ if (-not $PullOk) {
|
|||||||
}
|
}
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Ok "Ollama corriendo en http://localhost:${OllamaPort}"
|
Ok "Ollama corriendo en http://localhost:${OllamaPort}"
|
||||||
|
|
||||||
# --- 2. Instalar Hermes Agent ------------------------------------------------
|
# --- 2. Instalar Hermes Agent ------------------------------------------------
|
||||||
|
|||||||
+30
-5
@@ -80,6 +80,23 @@ if ($TotalRamGb -lt 3.5) {
|
|||||||
}
|
}
|
||||||
Ok "RAM: $TotalRamGb GB"
|
Ok "RAM: $TotalRamGb GB"
|
||||||
|
|
||||||
|
# --- Tumbar deploy previo (antes de detectar puertos) -----------------------
|
||||||
|
cmd /c docker rm -f d0a1-openclaw-ollama '>' NUL '2>&1'
|
||||||
|
Info 'Deploy previo detenido (rm; volumen con el modelo intacto).'
|
||||||
|
|
||||||
|
# --- GPU NVIDIA? (si hay, Ollama la usa y va 5-10x mas rapido) ---------------
|
||||||
|
$HasGpu = $false
|
||||||
|
if (Get-Command nvidia-smi -ErrorAction SilentlyContinue) {
|
||||||
|
$GpuInfo = & nvidia-smi --query-gpu=name,memory.total --format=csv,noheader 2>$null
|
||||||
|
if ($LASTEXITCODE -eq 0 -and $GpuInfo) {
|
||||||
|
$HasGpu = $true
|
||||||
|
$GpuName = ($GpuInfo -split ',')[0].Trim()
|
||||||
|
Info "GPU NVIDIA detectada: $GpuName (aceleracion activada)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (-not $HasGpu) {
|
||||||
|
Warn 'Sin GPU NVIDIA: modo CPU (~10-20 tokens/s). Con una GPU NVIDIA va 5-10x mas rapido.'
|
||||||
|
}
|
||||||
# --- Auto-detect Ollama port ------------------------------------------------
|
# --- Auto-detect Ollama port ------------------------------------------------
|
||||||
$OllamaPort = Find-FreePort 11434
|
$OllamaPort = Find-FreePort 11434
|
||||||
|
|
||||||
@@ -96,10 +113,11 @@ Write-Host ''
|
|||||||
|
|
||||||
# --- 1. Arrancar Ollama (Docker) -------------------------------------------
|
# --- 1. Arrancar Ollama (Docker) -------------------------------------------
|
||||||
Warn '[1/3] Arrancando Ollama (IA local)...'
|
Warn '[1/3] Arrancando Ollama (IA local)...'
|
||||||
cmd /c docker rm -f d0a1-openclaw-ollama '>' NUL '2>&1'
|
|
||||||
$running = docker ps --format '{{.Names}}' | Select-String -Quiet 'd0a1-openclaw-ollama'
|
$running = docker ps --format '{{.Names}}' | Select-String -Quiet 'd0a1-openclaw-ollama'
|
||||||
if (-not $running) {
|
if (-not $running) {
|
||||||
docker run -d --name d0a1-openclaw-ollama `
|
$GpuArgs = @()
|
||||||
|
if ($HasGpu) { $GpuArgs = @('--gpus', 'all') }
|
||||||
|
docker run -d --name d0a1-openclaw-ollama --memory 6g @GpuArgs `
|
||||||
-p "${OllamaPort}:11434" `
|
-p "${OllamaPort}:11434" `
|
||||||
-v d0a1_openclaw_ollama:/root/.ollama `
|
-v d0a1_openclaw_ollama:/root/.ollama `
|
||||||
-e OLLAMA_HOST=0.0.0.0 `
|
-e OLLAMA_HOST=0.0.0.0 `
|
||||||
@@ -125,18 +143,24 @@ Warn ' Descargando modelo (llama3.2:3b, ~2 GB)...'
|
|||||||
# Si el usuario define $env:HTTPS_PROXY, Ollama lo usa para el pull (doc oficial):
|
# Si el usuario define $env:HTTPS_PROXY, Ollama lo usa para el pull (doc oficial):
|
||||||
$ProxyEnv = @()
|
$ProxyEnv = @()
|
||||||
if ($env:HTTPS_PROXY) { $ProxyEnv = @('-e', "HTTPS_PROXY=$env:HTTPS_PROXY", '-e', "HTTP_PROXY=$env:HTTP_PROXY") }
|
if ($env:HTTPS_PROXY) { $ProxyEnv = @('-e', "HTTPS_PROXY=$env:HTTPS_PROXY", '-e', "HTTP_PROXY=$env:HTTP_PROXY") }
|
||||||
|
# --- Modelo ya presente? (volumen persistente: no re-descargar) ------------
|
||||||
|
$ModelList = docker exec d0a1-openclaw-ollama ollama list 2>$null
|
||||||
|
if ("$ModelList" -match 'llama3.2:3b') {
|
||||||
|
Info 'Modelo llama3.2:3b ya descargado (volumen intacto). Omitiendo descarga.'
|
||||||
|
} else {
|
||||||
# --- Modelo: HF primero (CDN propio, rapido) y registry de Ollama como ultimo recurso ---
|
# --- Modelo: HF primero (CDN propio, rapido) y registry de Ollama como ultimo recurso ---
|
||||||
|
|
||||||
$Gguf = Join-Path $ScriptDir 'llama3.2-3b-q4.gguf'
|
$Gguf = Join-Path $ScriptDir 'llama3.2-3b-q4.gguf'
|
||||||
$HfUrls = @(
|
$HfUrls = @(
|
||||||
'https://huggingface.co/bartowski/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf',
|
'https://huggingface.co/bartowski/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf',
|
||||||
'https://huggingface.co/unsloth/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf'
|
'https://huggingface.co/unsloth/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf'
|
||||||
)
|
)
|
||||||
foreach ($Url in $HfUrls) {
|
|
||||||
Info 'Descargando modelo de IA (llama3.2:3b, ~2 GB)...'
|
Info 'Descargando modelo de IA (llama3.2:3b, ~2 GB)...'
|
||||||
curl.exe -sL --retry 3 --max-time 1800 -o "$Gguf" $Url
|
foreach ($Url in $HfUrls) {
|
||||||
|
curl.exe -# -L --retry 3 --max-time 1800 -o "$Gguf" $Url
|
||||||
if ($LASTEXITCODE -eq 0 -and (Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) { break }
|
if ($LASTEXITCODE -eq 0 -and (Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) { break }
|
||||||
Warn "Mirror no accesible, probando el siguiente..."
|
|
||||||
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
|
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
|
||||||
|
if ($Url -ne $HfUrls[-1]) { Warn 'Mirror no accesible, probando el siguiente...' }
|
||||||
}
|
}
|
||||||
if ((Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) {
|
if ((Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) {
|
||||||
Info 'Importando modelo en Ollama...'
|
Info 'Importando modelo en Ollama...'
|
||||||
@@ -166,6 +190,7 @@ if (-not $PullOk) {
|
|||||||
}
|
}
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Ok "Ollama corriendo en http://localhost:${OllamaPort}"
|
Ok "Ollama corriendo en http://localhost:${OllamaPort}"
|
||||||
|
|
||||||
# --- 2. Instalar OpenClaw -----------------------------------------------------
|
# --- 2. Instalar OpenClaw -----------------------------------------------------
|
||||||
|
|||||||
+37
-8
@@ -86,6 +86,25 @@ if ($TotalRamGb -lt 3.5) {
|
|||||||
}
|
}
|
||||||
Ok "RAM: $TotalRamGb GB"
|
Ok "RAM: $TotalRamGb GB"
|
||||||
|
|
||||||
|
# --- Tumbar deploy previo (antes de detectar puertos) ----------------------
|
||||||
|
# Mantiene los volumenes (el modelo ya descargado no se re-descarga) y libera
|
||||||
|
# los puertos para que Find-FreePort vea el estado REAL tras el down.
|
||||||
|
cmd /c docker compose -f $ComposeFile down '>' NUL '2>&1'
|
||||||
|
Info 'Deploy previo detenido (down; volumenes con el modelo intactos).'
|
||||||
|
|
||||||
|
# --- GPU NVIDIA? (si hay, Ollama la usa y va 5-10x mas rapido) ---------------
|
||||||
|
$HasGpu = $false
|
||||||
|
if (Get-Command nvidia-smi -ErrorAction SilentlyContinue) {
|
||||||
|
$GpuInfo = & nvidia-smi --query-gpu=name,memory.total --format=csv,noheader 2>$null
|
||||||
|
if ($LASTEXITCODE -eq 0 -and $GpuInfo) {
|
||||||
|
$HasGpu = $true
|
||||||
|
$GpuName = ($GpuInfo -split ',')[0].Trim()
|
||||||
|
Info "GPU NVIDIA detectada: $GpuName (aceleracion activada)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (-not $HasGpu) {
|
||||||
|
Warn 'Sin GPU NVIDIA: modo CPU (~10-20 tokens/s). Con una GPU NVIDIA va 5-10x mas rapido.'
|
||||||
|
}
|
||||||
# --- Auto-detect ports ----------------------------------------------------
|
# --- Auto-detect ports ----------------------------------------------------
|
||||||
$OllamaPort = Find-FreePort 11434
|
$OllamaPort = Find-FreePort 11434
|
||||||
$WebUiPort = Find-FreePort 3000
|
$WebUiPort = Find-FreePort 3000
|
||||||
@@ -116,17 +135,20 @@ if ($WebUiPort -ne 3000) { Warn "Puerto 3000 ocupado, usando $WebUiPort" }
|
|||||||
Write-Host ''
|
Write-Host ''
|
||||||
|
|
||||||
# --- Deploy ----------------------------------------------------------------
|
# --- Deploy ----------------------------------------------------------------
|
||||||
# Si hay un deploy previo del pack, tumbarlo primero (mantiene los volumenes:
|
|
||||||
# el modelo ya descargado no se re-descarga) para que los nuevos puertos apliquen.
|
|
||||||
cmd /c docker compose -f $ComposeFile down '>' NUL '2>&1'
|
|
||||||
Warn 'Descargando contenedores (2-3 min la primera vez)...'
|
Warn 'Descargando contenedores (2-3 min la primera vez)...'
|
||||||
$env:OLLAMA_PORT = "$OllamaPort"
|
$env:OLLAMA_PORT = "$OllamaPort"
|
||||||
$env:WEBUI_PORT = "$WebUiPort"
|
$env:WEBUI_PORT = "$WebUiPort"
|
||||||
docker compose -f $ComposeFile up -d
|
$ComposeArgs = @('-f', $ComposeFile)
|
||||||
|
if ($HasGpu) {
|
||||||
|
$OverrideFile = Join-Path $ScriptDir 'docker-compose.gpu.yml'
|
||||||
|
Set-Content -Path $OverrideFile -Value "services:`r`n ollama:`r`n gpus: all`r`n"
|
||||||
|
$ComposeArgs += @('-f', $OverrideFile)
|
||||||
|
}
|
||||||
|
docker compose @ComposeArgs up -d
|
||||||
if ($LASTEXITCODE -ne 0) { Err "docker compose up fallo (exit $LASTEXITCODE)."; exit 1 }
|
if ($LASTEXITCODE -ne 0) { Err "docker compose up fallo (exit $LASTEXITCODE)."; exit 1 }
|
||||||
|
|
||||||
# --- Pull model -------------------------------------------------------------
|
# --- Pull model -------------------------------------------------------------
|
||||||
Warn 'Descargando modelo de IA (llama3.2:3b, ~2 GB)...'
|
Info 'Esperando a que Ollama arranque...'
|
||||||
$MaxWait = 60; $Waited = 0
|
$MaxWait = 60; $Waited = 0
|
||||||
while ($true) {
|
while ($true) {
|
||||||
# Descarte de stderr via cmd /c (ver nota de PS 5.1 / PS #4002 arriba)
|
# Descarte de stderr via cmd /c (ver nota de PS 5.1 / PS #4002 arriba)
|
||||||
@@ -142,18 +164,24 @@ while ($true) {
|
|||||||
# Si el usuario define $env:HTTPS_PROXY, Ollama lo usa para el pull (doc oficial):
|
# Si el usuario define $env:HTTPS_PROXY, Ollama lo usa para el pull (doc oficial):
|
||||||
$ProxyEnv = @()
|
$ProxyEnv = @()
|
||||||
if ($env:HTTPS_PROXY) { $ProxyEnv = @('-e', "HTTPS_PROXY=$env:HTTPS_PROXY", '-e', "HTTP_PROXY=$env:HTTP_PROXY") }
|
if ($env:HTTPS_PROXY) { $ProxyEnv = @('-e', "HTTPS_PROXY=$env:HTTPS_PROXY", '-e', "HTTP_PROXY=$env:HTTP_PROXY") }
|
||||||
|
# --- Modelo ya presente? (volumen persistente: no re-descargar) ------------
|
||||||
|
$ModelList = docker exec d0a1-ollama ollama list 2>$null
|
||||||
|
if ("$ModelList" -match 'llama3.2:3b') {
|
||||||
|
Info 'Modelo llama3.2:3b ya descargado (volumen intacto). Omitiendo descarga.'
|
||||||
|
} else {
|
||||||
# --- Modelo: HF primero (CDN propio, rapido) y registry de Ollama como ultimo recurso ---
|
# --- Modelo: HF primero (CDN propio, rapido) y registry de Ollama como ultimo recurso ---
|
||||||
|
|
||||||
$Gguf = Join-Path $ScriptDir 'llama3.2-3b-q4.gguf'
|
$Gguf = Join-Path $ScriptDir 'llama3.2-3b-q4.gguf'
|
||||||
$HfUrls = @(
|
$HfUrls = @(
|
||||||
'https://huggingface.co/bartowski/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf',
|
'https://huggingface.co/bartowski/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf',
|
||||||
'https://huggingface.co/unsloth/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf'
|
'https://huggingface.co/unsloth/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf'
|
||||||
)
|
)
|
||||||
foreach ($Url in $HfUrls) {
|
|
||||||
Info 'Descargando modelo de IA (llama3.2:3b, ~2 GB)...'
|
Info 'Descargando modelo de IA (llama3.2:3b, ~2 GB)...'
|
||||||
curl.exe -sL --retry 3 --max-time 1800 -o "$Gguf" $Url
|
foreach ($Url in $HfUrls) {
|
||||||
|
curl.exe -# -L --retry 3 --max-time 1800 -o "$Gguf" $Url
|
||||||
if ($LASTEXITCODE -eq 0 -and (Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) { break }
|
if ($LASTEXITCODE -eq 0 -and (Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) { break }
|
||||||
Warn "Mirror no accesible, probando el siguiente..."
|
|
||||||
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
|
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
|
||||||
|
if ($Url -ne $HfUrls[-1]) { Warn 'Mirror no accesible, probando el siguiente...' }
|
||||||
}
|
}
|
||||||
if ((Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) {
|
if ((Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) {
|
||||||
Info 'Importando modelo en Ollama...'
|
Info 'Importando modelo en Ollama...'
|
||||||
@@ -183,6 +211,7 @@ if (-not $PullOk) {
|
|||||||
}
|
}
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# --- Done -------------------------------------------------------------------
|
# --- Done -------------------------------------------------------------------
|
||||||
Write-Host ''
|
Write-Host ''
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ services:
|
|||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 10
|
retries: 10
|
||||||
start_period: 30s
|
start_period: 30s
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: 6G
|
||||||
|
|
||||||
openwebui:
|
openwebui:
|
||||||
container_name: d0a1-openwebui
|
container_name: d0a1-openwebui
|
||||||
@@ -43,6 +47,8 @@ services:
|
|||||||
ENABLE_SIGNUP: "true"
|
ENABLE_SIGNUP: "true"
|
||||||
ENABLE_WEB_SEARCH: "false"
|
ENABLE_WEB_SEARCH: "false"
|
||||||
ENABLE_DIRECT_CONNECTIONS: "false"
|
ENABLE_DIRECT_CONNECTIONS: "false"
|
||||||
|
CHAT_RESPONSE_MAX_TOOL_CALL_ITERATIONS: "1"
|
||||||
|
DEFAULT_MODEL_PARAMS: '{"function_calling": "legacy"}'
|
||||||
depends_on:
|
depends_on:
|
||||||
ollama:
|
ollama:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|||||||
+35
-5
@@ -119,7 +119,24 @@ if (-not (Test-Path $EnvFile)) {
|
|||||||
Info "Contrasenas generadas en $EnvFile"
|
Info "Contrasenas generadas en $EnvFile"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# --- GPU NVIDIA? (si hay, Ollama la usa y va 5-10x mas rapido) ---------------
|
||||||
|
$HasGpu = $false
|
||||||
|
if (Get-Command nvidia-smi -ErrorAction SilentlyContinue) {
|
||||||
|
$GpuInfo = & nvidia-smi --query-gpu=name,memory.total --format=csv,noheader 2>$null
|
||||||
|
if ($LASTEXITCODE -eq 0 -and $GpuInfo) {
|
||||||
|
$HasGpu = $true
|
||||||
|
$GpuName = ($GpuInfo -split ',')[0].Trim()
|
||||||
|
Info "GPU NVIDIA detectada: $GpuName (aceleracion activada)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (-not $HasGpu) {
|
||||||
|
Warn 'Sin GPU NVIDIA: modo CPU (~10-20 tokens/s). Con una GPU NVIDIA va 5-10x mas rapido.'
|
||||||
|
}
|
||||||
# --- Auto-detect ports ----------------------------------------------------
|
# --- Auto-detect ports ----------------------------------------------------
|
||||||
|
# --- Tumbar deploy previo (antes de detectar puertos) ----------------------
|
||||||
|
cmd /c docker compose -f $ComposeFile down '>' NUL '2>&1'
|
||||||
|
Info 'Deploy previo detenido (down; volumenes con el modelo intactos).'
|
||||||
|
|
||||||
$OllamaPort = Find-FreePort 11434
|
$OllamaPort = Find-FreePort 11434
|
||||||
$WpPort = Find-FreePort 8080
|
$WpPort = Find-FreePort 8080
|
||||||
$WebUiPort = Find-FreePort 3000
|
$WebUiPort = Find-FreePort 3000
|
||||||
@@ -158,11 +175,17 @@ cmd /c docker compose -f $ComposeFile down '>' NUL '2>&1'
|
|||||||
$env:OLLAMA_PORT = "$OllamaPort"
|
$env:OLLAMA_PORT = "$OllamaPort"
|
||||||
$env:WP_PORT = "$WpPort"
|
$env:WP_PORT = "$WpPort"
|
||||||
$env:WEBUI_PORT = "$WebUiPort"
|
$env:WEBUI_PORT = "$WebUiPort"
|
||||||
docker compose -f $ComposeFile up -d
|
$ComposeArgs = @('-f', $ComposeFile)
|
||||||
|
if ($HasGpu) {
|
||||||
|
$OverrideFile = Join-Path $ScriptDir 'docker-compose.gpu.yml'
|
||||||
|
Set-Content -Path $OverrideFile -Value "services:`r`n ollama:`r`n gpus: all`r`n"
|
||||||
|
$ComposeArgs += @('-f', $OverrideFile)
|
||||||
|
}
|
||||||
|
docker compose @ComposeArgs up -d
|
||||||
if ($LASTEXITCODE -ne 0) { Err "docker compose up fallo (exit $LASTEXITCODE)."; exit 1 }
|
if ($LASTEXITCODE -ne 0) { Err "docker compose up fallo (exit $LASTEXITCODE)."; exit 1 }
|
||||||
|
|
||||||
# --- Pull model -------------------------------------------------------------
|
# --- Pull model -------------------------------------------------------------
|
||||||
Warn 'Descargando modelo de IA (llama3.2:3b, ~2 GB)...'
|
Info 'Esperando a que Ollama arranque...'
|
||||||
$MaxWait = 60; $Waited = 0
|
$MaxWait = 60; $Waited = 0
|
||||||
while ($true) {
|
while ($true) {
|
||||||
# Descarte de stderr via cmd /c (ver nota de PS 5.1 / PS #4002 arriba)
|
# Descarte de stderr via cmd /c (ver nota de PS 5.1 / PS #4002 arriba)
|
||||||
@@ -178,18 +201,24 @@ while ($true) {
|
|||||||
# Si el usuario define $env:HTTPS_PROXY, Ollama lo usa para el pull (doc oficial):
|
# Si el usuario define $env:HTTPS_PROXY, Ollama lo usa para el pull (doc oficial):
|
||||||
$ProxyEnv = @()
|
$ProxyEnv = @()
|
||||||
if ($env:HTTPS_PROXY) { $ProxyEnv = @('-e', "HTTPS_PROXY=$env:HTTPS_PROXY", '-e', "HTTP_PROXY=$env:HTTP_PROXY") }
|
if ($env:HTTPS_PROXY) { $ProxyEnv = @('-e', "HTTPS_PROXY=$env:HTTPS_PROXY", '-e', "HTTP_PROXY=$env:HTTP_PROXY") }
|
||||||
|
# --- Modelo ya presente? (volumen persistente: no re-descargar) ------------
|
||||||
|
$ModelList = docker exec d0a1-wp-ollama ollama list 2>$null
|
||||||
|
if ("$ModelList" -match 'llama3.2:3b') {
|
||||||
|
Info 'Modelo llama3.2:3b ya descargado (volumen intacto). Omitiendo descarga.'
|
||||||
|
} else {
|
||||||
# --- Modelo: HF primero (CDN propio, rapido) y registry de Ollama como ultimo recurso ---
|
# --- Modelo: HF primero (CDN propio, rapido) y registry de Ollama como ultimo recurso ---
|
||||||
|
|
||||||
$Gguf = Join-Path $ScriptDir 'llama3.2-3b-q4.gguf'
|
$Gguf = Join-Path $ScriptDir 'llama3.2-3b-q4.gguf'
|
||||||
$HfUrls = @(
|
$HfUrls = @(
|
||||||
'https://huggingface.co/bartowski/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf',
|
'https://huggingface.co/bartowski/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf',
|
||||||
'https://huggingface.co/unsloth/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf'
|
'https://huggingface.co/unsloth/Llama-3.2-3B-Instruct-GGUF/resolve/main/Llama-3.2-3B-Instruct-Q4_K_M.gguf'
|
||||||
)
|
)
|
||||||
foreach ($Url in $HfUrls) {
|
|
||||||
Info 'Descargando modelo de IA (llama3.2:3b, ~2 GB)...'
|
Info 'Descargando modelo de IA (llama3.2:3b, ~2 GB)...'
|
||||||
curl.exe -sL --retry 3 --max-time 1800 -o "$Gguf" $Url
|
foreach ($Url in $HfUrls) {
|
||||||
|
curl.exe -# -L --retry 3 --max-time 1800 -o "$Gguf" $Url
|
||||||
if ($LASTEXITCODE -eq 0 -and (Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) { break }
|
if ($LASTEXITCODE -eq 0 -and (Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) { break }
|
||||||
Warn "Mirror no accesible, probando el siguiente..."
|
|
||||||
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
|
Remove-Item "$Gguf" -Force -ErrorAction SilentlyContinue
|
||||||
|
if ($Url -ne $HfUrls[-1]) { Warn 'Mirror no accesible, probando el siguiente...' }
|
||||||
}
|
}
|
||||||
if ((Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) {
|
if ((Test-Path $Gguf) -and (Get-Item $Gguf).Length -gt 1900000000) {
|
||||||
Info 'Importando modelo en Ollama...'
|
Info 'Importando modelo en Ollama...'
|
||||||
@@ -219,6 +248,7 @@ if (-not $PullOk) {
|
|||||||
}
|
}
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# --- Done -------------------------------------------------------------------
|
# --- Done -------------------------------------------------------------------
|
||||||
Write-Host ''
|
Write-Host ''
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ services:
|
|||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 10
|
retries: 10
|
||||||
start_period: 30s
|
start_period: 30s
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: 6G
|
||||||
|
|
||||||
openwebui:
|
openwebui:
|
||||||
container_name: d0a1-wp-openwebui
|
container_name: d0a1-wp-openwebui
|
||||||
@@ -73,6 +77,8 @@ services:
|
|||||||
WEBUI_NAME: "d0a1"
|
WEBUI_NAME: "d0a1"
|
||||||
WEBUI_AUTH: "false"
|
WEBUI_AUTH: "false"
|
||||||
DEFAULT_LOCALE: "es"
|
DEFAULT_LOCALE: "es"
|
||||||
|
CHAT_RESPONSE_MAX_TOOL_CALL_ITERATIONS: "1"
|
||||||
|
DEFAULT_MODEL_PARAMS: '{"function_calling": "legacy"}'
|
||||||
depends_on:
|
depends_on:
|
||||||
ollama:
|
ollama:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|||||||
Reference in new issue
Block a user