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 15:08] 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: 
 + 
 + 
 +===== Zona horaria ===== 
 +Configurar la zona horaria 
 + 
 +<sxh bash> 
 +sudo timedatectl set-timezone Europe/Madrid 
 +</sxh>   
      
-===== Tarjeta gŕafica =====  +===== Tarjeta gráfica =====  
   * Instalar la tarjeta gráfica     * Instalar la tarjeta gráfica  
      
Línea 15: Línea 24:
 </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 104: Línea 203:
 </sxh> </sxh>
  
 +===== Programas de seguridad =====
 +
 +  * Evitar ataques de fuerza bruta.
 +
 +<sxh bash>
 +sudo apt install fail2ban
 +</sxh>
 +
 +
 +  * Instalar automáticamente los parches de seguridad
 +
 +<sxh bash>
 +sudo apt update && sudo apt install unattended-upgrades update-notifier-common -y
 +sudo dpkg-reconfigure --priority=low unattended-upgrades
 +</sxh>
 +
 +  * En ''/etc/apt/apt.conf.d/50unattended-upgrades'' descomentar las siguiente líneas y dejarlas como se indica:
 +
 +<sxh text>
 +Unattended-Upgrade::Automatic-Reboot "true";
 +Unattended-Upgrade::Automatic-Reboot-Time "06:00";
 +Unattended-Upgrade::Remove-Unused-Dependencies "true";
 +</sxh>
 +
 +
 +  * Comprobar si está bien configurado
 +
 +<sxh bash>
 +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>
  
tutoriales/configurarservidor.1781010480.txt.gz · Última modificación: por Lorenzo