Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 1c71ce6e-1a3e-4f53-bb5d-77cdd22b8ea3
148 lines
4.6 KiB
Bash
148 lines
4.6 KiB
Bash
#!/bin/bash
|
|
# =========================================================================
|
|
# SCRIPT INSTALLAZIONE CUDA + TENSORFLOW GPU SU ALMALINUX 9.6
|
|
# =========================================================================
|
|
|
|
set -e
|
|
|
|
echo "🐧 CONFIGURAZIONE CUDA + TENSORFLOW GPU - ALMALINUX 9.6"
|
|
echo "========================================================"
|
|
|
|
# Verifica sistema
|
|
echo "📋 Verifica sistema..."
|
|
cat /etc/redhat-release
|
|
uname -r
|
|
|
|
# 1. AGGIORNAMENTO SISTEMA
|
|
echo "🔄 Aggiornamento sistema..."
|
|
sudo dnf update -y
|
|
|
|
# 2. INSTALLAZIONE REPOSITORY EPEL
|
|
echo "📦 Installazione EPEL..."
|
|
sudo dnf install -y epel-release
|
|
|
|
# 3. INSTALLAZIONE STRUMENTI SVILUPPO
|
|
echo "🔧 Installazione strumenti sviluppo..."
|
|
sudo dnf groupinstall -y "Development Tools"
|
|
sudo dnf install -y kernel-devel kernel-headers gcc gcc-c++ make dkms
|
|
|
|
# 4. DISABILITAZIONE NOUVEAU (driver open source NVIDIA)
|
|
echo "🚫 Disabilitazione driver Nouveau..."
|
|
sudo tee /etc/modprobe.d/blacklist-nouveau.conf <<EOF
|
|
blacklist nouveau
|
|
options nouveau modeset=0
|
|
EOF
|
|
|
|
# Rigenera initramfs
|
|
sudo dracut --force
|
|
|
|
# 5. DOWNLOAD E INSTALLAZIONE DRIVER NVIDIA
|
|
echo "🎮 Download driver NVIDIA..."
|
|
NVIDIA_VERSION="550.144.03" # Versione compatibile con Tesla M60
|
|
DRIVER_URL="https://us.download.nvidia.com/tesla/$NVIDIA_VERSION/NVIDIA-Linux-x86_64-$NVIDIA_VERSION.run"
|
|
|
|
cd /tmp
|
|
wget $DRIVER_URL -O nvidia-driver.run
|
|
chmod +x nvidia-driver.run
|
|
|
|
echo "⚠️ IMPORTANTE: Installa driver NVIDIA manualmente:"
|
|
echo " sudo ./nvidia-driver.run --silent --dkms"
|
|
echo " (Riavvia il sistema dopo l'installazione)"
|
|
|
|
# 6. INSTALLAZIONE CUDA TOOLKIT 12.4
|
|
echo "🚀 Configurazione repository CUDA..."
|
|
sudo dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/cuda-rhel9.repo
|
|
|
|
echo "🚀 Installazione CUDA Toolkit..."
|
|
sudo dnf install -y cuda-toolkit-12-4
|
|
|
|
# 7. CONFIGURAZIONE VARIABILI AMBIENTE
|
|
echo "🌍 Configurazione variabili ambiente..."
|
|
sudo tee /etc/profile.d/cuda.sh <<EOF
|
|
export CUDA_HOME=/usr/local/cuda-12.4
|
|
export PATH=\$CUDA_HOME/bin:\$PATH
|
|
export LD_LIBRARY_PATH=\$CUDA_HOME/lib64:\$LD_LIBRARY_PATH
|
|
export CUDA_PATH=\$CUDA_HOME
|
|
EOF
|
|
|
|
source /etc/profile.d/cuda.sh
|
|
|
|
# 8. INSTALLAZIONE cuDNN
|
|
echo "📚 Download cuDNN..."
|
|
echo "⚠️ MANUALE: Scarica cuDNN da https://developer.nvidia.com/cudnn"
|
|
echo " versione compatibile con CUDA 12.4"
|
|
echo " tar -xzf cudnn-*.tar.xz"
|
|
echo " sudo cp cudnn-*/include/cudnn*.h /usr/local/cuda/include"
|
|
echo " sudo cp cudnn-*/lib/libcudnn* /usr/local/cuda/lib64"
|
|
echo " sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*"
|
|
|
|
# 9. PYTHON E TENSORFLOW
|
|
echo "🐍 Configurazione Python e TensorFlow..."
|
|
|
|
# Verifica Python
|
|
python3 --version
|
|
pip3 --version
|
|
|
|
# Upgrade pip
|
|
pip3 install --upgrade pip
|
|
|
|
# Installazione TensorFlow GPU
|
|
echo "🤖 Installazione TensorFlow GPU..."
|
|
pip3 install tensorflow[and-cuda]==2.17.*
|
|
|
|
# 10. TEST CONFIGURAZIONE
|
|
echo "🧪 Creazione script test..."
|
|
cat > test_cuda_almalinux.py <<'PYEOF'
|
|
#!/usr/bin/env python3
|
|
import tensorflow as tf
|
|
import os
|
|
|
|
print("🔍 TEST CUDA ALMALINUX 9.6")
|
|
print("=" * 40)
|
|
|
|
print(f"TensorFlow: {tf.__version__}")
|
|
print(f"CUDA built: {tf.test.is_built_with_cuda()}")
|
|
|
|
gpus = tf.config.list_physical_devices('GPU')
|
|
print(f"GPU devices: {len(gpus)}")
|
|
|
|
if gpus:
|
|
for i, gpu in enumerate(gpus):
|
|
print(f" GPU {i}: {gpu}")
|
|
|
|
# Test computation
|
|
try:
|
|
with tf.device('/GPU:0'):
|
|
a = tf.constant([[1.0, 2.0], [3.0, 4.0]])
|
|
b = tf.constant([[1.0, 1.0], [0.0, 1.0]])
|
|
c = tf.matmul(a, b)
|
|
print(f"✅ Test GPU: {c}")
|
|
except Exception as e:
|
|
print(f"❌ Errore GPU: {e}")
|
|
else:
|
|
print("❌ Nessuna GPU trovata")
|
|
|
|
# Test CUDA libraries
|
|
print(f"\nCUDA version: {tf.sysconfig.get_build_info().get('cuda_version', 'N/A')}")
|
|
print(f"cuDNN version: {tf.sysconfig.get_build_info().get('cudnn_version', 'N/A')}")
|
|
PYEOF
|
|
|
|
chmod +x test_cuda_almalinux.py
|
|
|
|
echo ""
|
|
echo "✅ INSTALLAZIONE COMPLETATA!"
|
|
echo "================================"
|
|
echo ""
|
|
echo "📋 PROSSIMI PASSI:"
|
|
echo "1. Riavvia il sistema: sudo reboot"
|
|
echo "2. Verifica driver: nvidia-smi"
|
|
echo "3. Test CUDA: nvcc --version"
|
|
echo "4. Test TensorFlow: python3 test_cuda_almalinux.py"
|
|
echo ""
|
|
echo "🔧 CONFIGURAZIONE TENSORFLOW v04:"
|
|
echo " export TF_GPU_MEMORY_GROWTH=1"
|
|
echo " export CUDA_VISIBLE_DEVICES=0"
|
|
echo ""
|
|
echo "🚀 COMANDI SISTEMA v04:"
|
|
echo " python3 analisys_04.py --max-records 1000000"
|
|
echo " python3 detect_multi_04.py --advanced --batch-size 1000" |