Herramientas de usuario

Herramientas del sitio


tutoriales:configurarservidor

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anteriorRevisión previa
Próxima revisión
Revisión previa
tutoriales:configurarservidor [2026/06/09 12:12] Lorenzotutoriales:configurarservidor [2026/07/14 09:21] (actual) Lorenzo
Línea 1: Línea 1:
-====== Configurar un servidor con Ollama ====== +====== Configurar un servidor con Ollama ======   
 +  
 Para configurar un servidor con ollama hay que seguir los siguientes pasos: Para configurar un servidor con ollama hay que seguir los siguientes pasos:
  
-===== Tarjeta gŕafica ===== + 
-  * Instalar la tarjeta gráfica+===== Zona horaria ===== 
 +Configurar la zona horaria
  
 <sxh bash> <sxh bash>
-ubuntu-drivers devices +sudo timedatectl set-timezone Europe/Madrid 
-sudo apt install nvidia-driver-595-server-open +</sxh>  
-sudo reboot + 
-nvidia-smi +  
-sudo apt install nvtop +===== Tarjeta gráfica =====  
-nvtop+  * Instalar la tarjeta gráfica  
 +  
 +<sxh bash>  
 +ubuntu-drivers devices   
 +sudo apt install nvidia-driver-595-server-open   
 +sudo reboot   
 +nvidia-smi   
 +sudo apt install nvtop   
 +nvtop  
 </sxh> </sxh>
  
 +===== CUDA =====  
 +
 +  * Instalar CUDA
 +<sxh bash>
 +wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2604/x86_64/cuda-keyring_1.1-1_all.deb
 +sudo dpkg -i cuda-keyring_1.1-1_all.deb
 +sudo apt update
 +sudo apt install cuda-toolkit-13-2
 +</sxh>
 +
 +<note warning>
 +Ejecutar ''nvidia-smi'' y ver la versión máxima que soporta de CUCA. En este caso es ''CUDA 13.2''
 +
 +<sxh>
 ++-----------------------------------------------------------------------------------------+
 +| NVIDIA-SMI 595.71.05              Driver Version: 595.71.05      CUDA Version: 13.2     |
 ++-----------------------------------------+------------------------+----------------------+
 +| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
 +| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
 +|                                                                |               MIG M. |
 +|=========================================+========================+======================|
 +|    NVIDIA GeForce RTX 4090        Off |   00000000:01:00.0 Off |                  Off |
 +|  0%   43C    P8              9W /  450W |       1MiB /  24564MiB |      0%      Default |
 +|                                                                |                  N/A |
 ++-----------------------------------------+------------------------+----------------------+
 +
 ++-----------------------------------------------------------------------------------------+
 +| Processes:                                                                              |
 +|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
 +|        ID   ID                                                               Usage      |
 +|=========================================================================================|
 +|  No running processes found                                                             |
 ++-----------------------------------------------------------------------------------------+
 +</sxh>
 +
 +</note>
 +
 +
 +  * El ''PATH''
 +
 +<sxh bash>
 +echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.bashrc
 +echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
 +source ~/.bashrc
 +</sxh>
 +
 +  * Comprobar que funciona:
 +
 +<sxh bash>
 +nvcc --version
 +</sxh>
 +
 +
 +===== NVIDIA Container Toolkit =====
 +
 +
 +  * Añadir la clave GPG y el repositorio
 +<sxh bash>
 +curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
 +curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' |   sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
 +</sxh>
 +
 +
 +  * Instalar el toolkit
 +<sxh bash>
 +sudo apt-get update
 +sudo apt-get install -y nvidia-container-toolkit
 +</sxh>
 +
 +  * Configurar el runtime de Docker
 +<sxh bash>
 +sudo nvidia-ctk runtime configure --runtime=docker
 +sudo systemctl restart docker
 +</sxh>
 +
 +  * Verificar
 +<sxh bash>
 +docker run --rm --gpus all ubuntu nvidia-smi
 +</sxh>
 +
 +
 +===== Zeroconf =====
 +Para que el servidor linux publique su nombre DNS con mDNS (multicast DNS) y DNS-SD (Service Discovery) 
 +  * Bonjour: Implementación de Apple
 +  * Avahi: Implementación de Linux
 +
 +<sxh bash>
 +sudo apt install avahi-daemon
 +sudo systemctl enable --now avahi-daemon
 +</sxh>
 ===== NGINX ===== ===== NGINX =====
  
Línea 28: Línea 127:
  
  
-<sxh text>+<sxh text;highlight: [23,26];>
 # --- SERVICIO 1 --- # --- SERVICIO 1 ---
 server { server {
Línea 68: Línea 167:
  
 </sxh> </sxh>
 +
 +<note>Si quieres añadir otro servicio además de ollama, copia las líneas ''server'' y modifica el nombre de dominio y el puerto interno.</note>
 +
  
   * Modificar ''nginx.conf'' y añade la linea '' client_max_body_size 100M;'' es para permitir subir ficheros grandes.   * Modificar ''nginx.conf'' y añade la linea '' client_max_body_size 100M;'' es para permitir subir ficheros grandes.
  
-<sxh text>+<sxh text;highlight: [6];>
 http { http {
     sendfile on;     sendfile on;
Línea 100: Línea 202:
 sudo systemctl reload nginx sudo systemctl reload nginx
 </sxh> </sxh>
- 
  
 ===== Programas de seguridad ===== ===== Programas de seguridad =====
Línea 122: Línea 223:
 <sxh text> <sxh text>
 Unattended-Upgrade::Automatic-Reboot "true"; Unattended-Upgrade::Automatic-Reboot "true";
-Unattended-Upgrade::Automatic-Reboot-Time "04:00";+Unattended-Upgrade::Automatic-Reboot-Time "06:00";
 Unattended-Upgrade::Remove-Unused-Dependencies "true"; Unattended-Upgrade::Remove-Unused-Dependencies "true";
 </sxh> </sxh>
Línea 131: Línea 232:
 <sxh bash> <sxh bash>
 sudo unattended-upgrades --dry-run --debug sudo unattended-upgrades --dry-run --debug
 +</sxh>
 +
 +
 +===== Ollama =====
 +
 +  * Instalar Ollama
 +
 +<sxh bash>
 +curl -fsSL https://ollama.com/install.sh | sh
 +</sxh>
 +
 +  * Comprobar que el servicio está activo y escuchando en el puerto ''11434''
 +
 +<sxh bash>
 +sudo systemctl status ollama
 +curl http://127.0.0.1:11434
 +</sxh>
 +
 +<note>
 +El instalador detecta la GPU NVIDIA automáticamente (por eso este paso va después de instalar los drivers). Para confirmar que Ollama usa la GPU, ejecuta ''nvtop'' mientras hay un modelo en marcha.
 +</note>
 +
 +  * Descargar (pull) un modelo
 +
 +<sxh bash>
 +ollama pull llama3.1
 +</sxh>
 +
 +  * Comprobar los modelos descargados y probar uno
 +
 +<sxh bash>
 +ollama list
 +ollama run llama3.1 "Hola, ¿funcionas?"
 </sxh> </sxh>
  
tutoriales/configurarservidor.1780999977.txt.gz · Última modificación: por Lorenzo