Agenda :
  • Verschil tussen Google en ChatGPT
  • Hardware en Software
  • Introductie NeuraalNetwerk
  • - Maak tekeningen op het bord
  • WSL : Podman : Node
  • Toon code 'Eigen Neuraal Netwerken'
  • Demo XOR met Eigen Neuraal Netwerk
  • Demo BrainJS XOR
  • Demo BrainJS LSTM (long short Term Memory)
  • Demo GPT4All : Windows met tinydolphin model : Zoeken, maar niet localdocs
  • Demo Reinforment Learining BrainJs
  • Demo GPT4All : RAG : Retrieval Augmented Generation : localdocs
  • Demo Ollama : WSL : Podman : Oracle Linux 9 : Ollama
  • Demo Open WebUI : WSL : Podman : WebUI
  • Demo WIN : VSCode : verbind met Ollama
  • uitleg en demo Stable Diffusion (BesDev virtualbox)
  • Demo : WSL : BesDev : Stable Diffusion (Dit werkt alleen met systeem > 10GB memory)

  • Windows / Linux installatie AI Machine

    Hardware


    Low-end systemen getest:
  • HP Envy dv7 : i7 , 8GB , GEForce GT 630M 2GB ... later 8GB erbij = 16GB (Voor Stable Diffusion)
  • Acer Aspire 5640 : i5 4 cores 2.27Ghz, 8GB (Alles behalve GPT4All en Stable Diffusion)
  • Thuis Tower Desktop : I7-6700, 4 cores, 8 log, 16GB memory (Alleen op Windows Pro + WSL getet!)
  • HP Z620 Workstation/158A : 2x Xeon E5 2660, 2.20Ghz, 64GB DDR3 (32 cores)

    Update systeem (Windows Updates / apt update -y / yum update -y



  • Windows : Defender uitschakelen
  • Windows : afstand .. externe verbindingen toestaan
  • Linux : firewall uitzetten / SELinux uit

  • HP Z (Oracle Linux 8) : dnf group install -y "Server with GUI"



  • Software

    Windows op HP Laptop (Installatie pre-requisites : 4 uur)
  • Windows Pro
  • Laatste updates
  • WSL : DSIM powershell commando's
  • Putty (PSCP)
  • Chrome
  • 7zip
  • VirtualBox
  • VCRedist

  • GPT

    Generative Pre-trained Transformer
    Het is een LSTM die woorden voorspeld op basis van de input

  • Input Endoding : Invoer wordt omgezet in een lijst met nummers (tokens)
  • Er is een positie in het model voor de woord. Dat heeft met context te maken.
  • Dus een woord Reclassering zal dicht bij het woord Justitie ' liggen ' qua numerieke waarde
  • Naast context wordt ook de invoer door een snel opgezet neuraal netwerkje gehaald
  • Dat neuraalnetwerkje wordt gevoed met de invoer en het geeft een score op basis van relaties.
  • Voorbeeld : Een robot moet de opdrachten die het
  • Self Attention Proces : De invoer (woordje 'het') wordt vervolgens aan het neuraal
  • netwerkje gevoed om de waarschijnlijke relatie met ' robot ' te achterhalen.
  • De Input Encoding (Tokens) waarde wordt gebruikt om de prediction (voorspelling) te vinden
  • De voorspelling wordt vervolgens door grammatica checker en censor filters gehaald

  • Dat je niet mag vragen hoe een bom te maken

  • Bron: https://jalammar.github.io/illustrated-gpt2/

  • GPT4ALL


    De Ollama omgeving is wat complexer om te installeren.
    GPT4All is een veel snellere installatie en 'gebruikers' vriendelijker manier.
    Voordelen van GPT4ALL
  • blijft geheel lokaal (buiten het ophalen van de modellen)
  • No GPU required
  • 'draait' op oudere hardware
  • Je kan verschillende modellen laden
  • Voordeel m.b.t gebruik van RAG (LocalDocs) Retrieval Augmented Generation

  • https://www.nomic.ai/gpt4all

  • Linux : wget https://gpt4all.io/installers/gpt4all-installer-linux.run (Oracle Linux 9 only!)
  • Windows : Installeer Redisributable VC++ daarna download EXE (next, next , finish)

  • Linux


    Geen GPT4ALL in podman container!!!! TO BE DONE: uitzoeken

    podman & GUI

    GPT4ALL LINUX install


    Requirements

    In GUI : Desktop : Open terminal
    yum install -y wget 
    yum install -y libxkbcommon-x11
    yum install -y xcb-util-keysyms -y
    yum  install -y xcb-util-wm
    yum install -y xcb-util-image
    yum install -y xcb-util-keysyms
    yum install -y  xcb-util-renderutil
    yum install -y freeglut-devel
    
  • chmod +x gpt*
  • ./gpt(tab)

    GUI Linux

  • cd gpt4all/bin
  • ./chat

    Op Acer op Windows & Linux: Incompatible Hardware Detected

    Windows GPT4all


    vcredist x64 download:
  • https://aka.ms/vs/17/release/vc_redist.x64.exe
    (Behoeft deinstallatie van 2013 redist bijvoorbeeld)

    GUI : Click op GPT4ALL icoon

    GPT4ALL : Model + Add Model
  • Llama 3.2 1B Instruct of 8B als je systeem > 8GB memory heeft
  • Reasoner v1 (Javacript)
    error handling
  • On XenServer, what causes this error: SR_BACKEND_FAILURE_107 Error parameters: , The SCSIid parameter is missing or incorrect


    Het is dus wel 'self containted' m.a.w. het heeft verder geen andere servers nodig.

  • Settings
  • LocalDocs
  • Allowed File Extensions : voeg to html,js,sh
    Ga dan naar [LocalDocs]
  • Add Doc Collection


    Chat


    Kies / Load Model
    Daarna kun je 'send message gebruiken '

    RAG = Retrieval Augmented Generation



    Je kan gebruik maken van de LocalDocs om je eigen data toe te voegen.

    Het model gebruikt de Retrieval Augmented Generation data om antwoorden te genereren MET de data.

    Fine Tuning een model wordt bedoeld dat het model wordt aangepast.
    Dat fijn mazig omvormen van het model kost heel veel rekenkracht en tijd. De RAG methode is veel sneller.
    Wel is het zo dat als je (het liefst een heel kleine LLM) fijnmazig verbeterd dat het model veel betere
    antwoorden geeft en minder 'hallucineert'
    Zie het 'Jane' brainjs model

    Podman Containers

    Windows


    WSL





    Windows update (win10pro bijvoorbeeld)
    Windows Subsystem Linux


    Command Prompt Administrator

  • powershell
  • dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
  • dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
  • reb00t
  • wsl.exe --install Hiermee kun je Linux gebruiken op het windows systeem (zonder docker/virtualbox)


  • wsl --list -online
    Install using 'wsl --install -d '.
    
    NAME                            FRIENDLY NAME
    Ubuntu                          Ubuntu
    Debian                          Debian GNU/Linux
    kali-linux                      Kali Linux Rolling
    Ubuntu-18.04                    Ubuntu 18.04 LTS
    Ubuntu-20.04                    Ubuntu 20.04 LTS
    Ubuntu-22.04                    Ubuntu 22.04 LTS
    Ubuntu-24.04                    Ubuntu 24.04 LTS
    OracleLinux_7_9                 Oracle Linux 7.9
    OracleLinux_8_7                 Oracle Linux 8.7
    OracleLinux_9_1                 Oracle Linux 9.1
    openSUSE-Leap-15.6              openSUSE Leap 15.6
    SUSE-Linux-Enterprise-15-SP5    SUSE Linux Enterprise 15 SP5
    SUSE-Linux-Enterprise-15-SP6    SUSE Linux Enterprise 15 SP6
    openSUSE-Tumbleweed             openSUSE Tumbleweed
    

  • wsl --install -d OracleLinux_9_1
    Username : me
    Password : wachtwoord_voor_me
    


    ----

    Installeer Podman container




    ---- Bereid systemen voor om containers te draaien

    (Zorg dat systeem de laatste systeem updates heeft)
    Firewall uit op de windows of linux machine
  • wsl --update


    Voor WSL systeem :
    Start eerst de huidige wsl
    sudo -e /etc/wsl.conf
    [network]
    generateResolvConf = false
    localhostForwarding = true
    
    [boot] 
    systemd=true
    

  • wsl --shutdown
    start opnieuw
  • systemctl status

    Dit is voor Linux en Windows gelijk .. Windows is nu een ' Linux ' machine

    Podman


    sudo su -
    Bereid het systeem voor om podman te draaien
     
    Oracle Linux 9
    dnf install -y oracle-epel-release-el9
    dnf config-manager --enable ol9_developer_EPEL
    Oracle Linx 8 : yum install -y oracle-epel-release-el8
    Oracle Linx 8 : yum install -y yum-utils; yum-config-manager --enable ol8_baseos_latest ol8_appstream ol8_addons ol8_developer_EPEL
    
    dnf install -y podman 
    dnf install -y podman-compose 
    
    # Eventueel, als nog niet eerder :
    dnf install -y xrdp 
    systemctl enable xrdp
    systemctl start xrdp 
    



    GPU



    Test GPU (Werkt waarschijnlijk niet op WSL en HP Machine)
  • podman run --rm -it --device=nvidia.com/gpu=all ubuntu:latest nvidia-smi -L


    Ollama




    Omni-Layer Learning Language Acquisition Model
    Ollama is een provider voor LLMs. Er zijn een heleboel modellen en veel daarvan kunnen door Ollama gebruikt worden
    Zie Ollama als het doorgeef luik
    Het zal zelf niet de modellen aanpassen.
    Wat zit er in Ollama:
  • API
  • Command Line Chat
  • Ophalen van language models



    Prepare files
  • mkdir -p /home/podman/ollama
  • vi /home/podman/ollama/install.sh
    
    # This script installs Ollama on Linux.
    # It detects the current operating system architecture and installs the appropriate version of Ollama.
    
    set -eu
    
    red="$( (/usr/bin/tput bold || :; /usr/bin/tput setaf 1 || :) 2>&-)"
    plain="$( (/usr/bin/tput sgr0 || :) 2>&-)"
    
    status() { echo ">>> $*" >&2; }
    error() { echo "${red}ERROR:${plain} $*"; exit 1; }
    warning() { echo "${red}WARNING:${plain} $*"; }
    
    TEMP_DIR=$(mktemp -d)
    cleanup() { rm -rf $TEMP_DIR; }
    trap cleanup EXIT
    
    available() { command -v $1 >/dev/null; }
    require() {
        local MISSING=''
        for TOOL in $*; do
            if ! available $TOOL; then
                MISSING="$MISSING $TOOL"
            fi
        done
    
        echo $MISSING
    }
    
    [ "$(uname -s)" = "Linux" ] || error 'This script is intended to run on Linux only.'
    
    ARCH=$(uname -m)
    case "$ARCH" in
        x86_64) ARCH="amd64" ;;
        aarch64|arm64) ARCH="arm64" ;;
        *) error "Unsupported architecture: $ARCH" ;;
    esac
    
    IS_WSL2=false
    
    KERN=$(uname -r)
    case "$KERN" in
        *icrosoft*WSL2 | *icrosoft*wsl2) IS_WSL2=true;;
        *icrosoft) error "Microsoft WSL1 is not currently supported. Please use WSL2 with 'wsl --set-version  2'" ;;
        *) ;;
    esac
    
    VER_PARAM="${OLLAMA_VERSION:+?version=$OLLAMA_VERSION}"
    
    SUDO=
    if [ "$(id -u)" -ne 0 ]; then
        # Running as root, no need for sudo
        if ! available sudo; then
            error "This script requires superuser permissions. Please re-run as root."
        fi
    
        SUDO="sudo"
    fi
    
    NEEDS=$(require curl awk grep sed tee xargs)
    if [ -n "$NEEDS" ]; then
        status "ERROR: The following tools are required but missing:"
        for NEED in $NEEDS; do
            echo "  - $NEED"
        done
        exit 1
    fi
    
    for BINDIR in /usr/local/bin /usr/bin /bin; do
        echo $PATH | grep -q $BINDIR && break || continue
    done
    OLLAMA_INSTALL_DIR=$(dirname ${BINDIR})
    
    if [ -d "$OLLAMA_INSTALL_DIR/lib/ollama" ] ; then
        status "Cleaning up old version at $OLLAMA_INSTALL_DIR/lib/ollama"
        $SUDO rm -rf "$OLLAMA_INSTALL_DIR/lib/ollama"
    fi
    status "Installing ollama to $OLLAMA_INSTALL_DIR"
    $SUDO install -o0 -g0 -m755 -d $BINDIR
    $SUDO install -o0 -g0 -m755 -d "$OLLAMA_INSTALL_DIR"
    status "Downloading Linux ${ARCH} bundle"
    curl --fail --show-error --location --progress-bar \
        "https://ollama.com/download/ollama-linux-${ARCH}.tgz${VER_PARAM}" | \
        $SUDO tar -xzf - -C "$OLLAMA_INSTALL_DIR"
    if [ "$OLLAMA_INSTALL_DIR/bin/ollama" != "$BINDIR/ollama" ] ; then
        status "Making ollama accessible in the PATH in $BINDIR"
        $SUDO ln -sf "$OLLAMA_INSTALL_DIR/ollama" "$BINDIR/ollama"
    fi
    
    # Check for NVIDIA JetPack systems with additional downloads
    if [ -f /etc/nv_tegra_release ] ; then
        if grep R36 /etc/nv_tegra_release > /dev/null ; then
            status "Downloading JetPack 6 components"
            curl --fail --show-error --location --progress-bar \
                "https://ollama.com/download/ollama-linux-${ARCH}-jetpack6.tgz${VER_PARAM}" | \
                $SUDO tar -xzf - -C "$OLLAMA_INSTALL_DIR"
        elif grep R35 /etc/nv_tegra_release > /dev/null ; then
            status "Downloading JetPack 5 components"
            curl --fail --show-error --location --progress-bar \
                "https://ollama.com/download/ollama-linux-${ARCH}-jetpack5.tgz${VER_PARAM}" | \
                $SUDO tar -xzf - -C "$OLLAMA_INSTALL_DIR"
        else
            warning "Unsupported JetPack version detected.  GPU may not be supported"
        fi
    fi
    
    install_success() {
        status 'The Ollama API is now available at 127.0.0.1:11434.'
        status 'Install complete. Run "ollama" from the command line.'
    }
    trap install_success EXIT
    
    # Everything from this point onwards is optional.
    
    configure_systemd() {
        if ! id ollama >/dev/null 2>&1; then
            status "Creating ollama user..."
            $SUDO useradd -r -s /bin/false -U -m -d /usr/share/ollama ollama
        fi
        if getent group render >/dev/null 2>&1; then
            status "Adding ollama user to render group..."
            $SUDO usermod -a -G render ollama
        fi
        if getent group video >/dev/null 2>&1; then
            status "Adding ollama user to video group..."
            $SUDO usermod -a -G video ollama
        fi
    
        status "Adding current user to ollama group..."
        $SUDO usermod -a -G ollama $(whoami)
    
        status "Creating ollama systemd service..."
    #    cat </dev/null
    #[Unit]
    #Description=Ollama Service
    #After=network-online.target
    #
    #[Service]
    #ExecStart=$BINDIR/ollama serve
    #User=ollama
    #Group=ollama
    #Restart=always
    #RestartSec=3
    #Environment="PATH=$PATH"
    #
    #[Install]
    #WantedBy=default.target
    #EOF
    #    SYSTEMCTL_RUNNING="$(systemctl is-system-running || true)"
    #    case $SYSTEMCTL_RUNNING in
    #        running|degraded)
    #            status "Enabling and starting ollama service..."
    #            $SUDO systemctl daemon-reload
    #            $SUDO systemctl enable ollama
    #
    #            start_service() { $SUDO systemctl restart ollama; }
    #            trap start_service EXIT
    #            ;;
    #        *)
    #            warning "systemd is not running"
    #            if [ "$IS_WSL2" = true ]; then
    #                warning "see https://learn.microsoft.com/en-us/windows/wsl/systemd#how-to-enable-systemd to enable it"
    #            fi
    #            ;;
    #    esac
    echo "STARTING SERVE"
    /usr/local/bin/ollama serve &
    }
    
    
    #if available systemctl; then
        configure_systemd
    #fi
    
    # WSL2 only supports GPUs via nvidia passthrough
    # so check for nvidia-smi to determine if GPU is available
    if [ "$IS_WSL2" = true ]; then
        if available nvidia-smi && [ -n "$(nvidia-smi | grep -o "CUDA Version: [0-9]*\.[0-9]*")" ]; then
            status "Nvidia GPU detected."
        fi
        install_success
        exit 0
    fi
    
    # Don't attempt to install drivers on Jetson systems
    if [ -f /etc/nv_tegra_release ] ; then
        status "NVIDIA JetPack ready."
        install_success
        exit 0
    fi
    
    # Install GPU dependencies on Linux
    if ! available lspci && ! available lshw; then
        warning "Unable to detect NVIDIA/AMD GPU. Install lspci or lshw to automatically detect and install GPU dependencies."
        exit 0
    fi
    
    check_gpu() {
        # Look for devices based on vendor ID for NVIDIA and AMD
        case $1 in
            lspci)
                case $2 in
                    nvidia) available lspci && lspci -d '10de:' | grep -q 'NVIDIA' || return 1 ;;
                    amdgpu) available lspci && lspci -d '1002:' | grep -q 'AMD' || return 1 ;;
                esac ;;
            lshw)
                case $2 in
                    nvidia) available lshw && $SUDO lshw -c display -numeric -disable network | grep -q 'vendor: .* \[10DE\]' || return 1 ;;
                    amdgpu) available lshw && $SUDO lshw -c display -numeric -disable network | grep -q 'vendor: .* \[1002\]' || return 1 ;;
                esac ;;
            nvidia-smi) available nvidia-smi || return 1 ;;
        esac
    }
    
    if check_gpu nvidia-smi; then
        status "NVIDIA GPU installed."
        exit 0
    fi
    
    if ! check_gpu lspci nvidia && ! check_gpu lshw nvidia && ! check_gpu lspci amdgpu && ! check_gpu lshw amdgpu; then
        install_success
        warning "No NVIDIA/AMD GPU detected. Ollama will run in CPU-only mode."
        exit 0
    fi
    
    if check_gpu lspci amdgpu || check_gpu lshw amdgpu; then
        status "Downloading Linux ROCm ${ARCH} bundle"
        curl --fail --show-error --location --progress-bar \
            "https://ollama.com/download/ollama-linux-${ARCH}-rocm.tgz${VER_PARAM}" | \
            $SUDO tar -xzf - -C "$OLLAMA_INSTALL_DIR"
    
        install_success
        status "AMD GPU ready."
        exit 0
    fi
    
    CUDA_REPO_ERR_MSG="NVIDIA GPU detected, but your OS and Architecture are not supported by NVIDIA.  Please install the CUDA driver manually https://docs.nvidia.com/cuda/cuda-installation-guide-linux/"
    # ref: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#rhel-7-centos-7
    # ref: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#rhel-8-rocky-8
    # ref: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#rhel-9-rocky-9
    # ref: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#fedora
    install_cuda_driver_yum() {
        status 'Installing NVIDIA repository...'
    
        case $PACKAGE_MANAGER in
            yum)
                $SUDO $PACKAGE_MANAGER -y install yum-utils
                if curl -I --silent --fail --location "https://developer.download.nvidia.com/compute/cuda/repos/$1$2/$(uname -m | sed -e 's/aarch64/sbsa/')/cuda-$1$2.repo" >/dev/null ; then
                    $SUDO $PACKAGE_MANAGER-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/$1$2/$(uname -m | sed -e 's/aarch64/sbsa/')/cuda-$1$2.repo
                else
                    error $CUDA_REPO_ERR_MSG
                fi
                ;;
            dnf)
                if curl -I --silent --fail --location "https://developer.download.nvidia.com/compute/cuda/repos/$1$2/$(uname -m | sed -e 's/aarch64/sbsa/')/cuda-$1$2.repo" >/dev/null ; then
                    $SUDO $PACKAGE_MANAGER config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/$1$2/$(uname -m | sed -e 's/aarch64/sbsa/')/cuda-$1$2.repo
                else
                    error $CUDA_REPO_ERR_MSG
                fi
                ;;
        esac
    
        case $1 in
            rhel)
                status 'Installing EPEL repository...'
                # EPEL is required for third-party dependencies such as dkms and libvdpau
                $SUDO $PACKAGE_MANAGER -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-$2.noarch.rpm || true
                ;;
        esac
    
        status 'Installing CUDA driver...'
    
        if [ "$1" = 'centos' ] || [ "$1$2" = 'rhel7' ]; then
            $SUDO $PACKAGE_MANAGER -y install nvidia-driver-latest-dkms
        fi
    
        $SUDO $PACKAGE_MANAGER -y install cuda-drivers
    }
    
    # ref: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#ubuntu
    # ref: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#debian
    install_cuda_driver_apt() {
        status 'Installing NVIDIA repository...'
        if curl -I --silent --fail --location "https://developer.download.nvidia.com/compute/cuda/repos/$1$2/$(uname -m | sed -e 's/aarch64/sbsa/')/cuda-keyring_1.1-1_all.deb" >/dev/null ; then
            curl -fsSL -o $TEMP_DIR/cuda-keyring.deb https://developer.download.nvidia.com/compute/cuda/repos/$1$2/$(uname -m | sed -e 's/aarch64/sbsa/')/cuda-keyring_1.1-1_all.deb
        else
            error $CUDA_REPO_ERR_MSG
        fi
    
        case $1 in
            debian)
                status 'Enabling contrib sources...'
                $SUDO sed 's/main/contrib/' < /etc/apt/sources.list | $SUDO tee /etc/apt/sources.list.d/contrib.list > /dev/null
                if [ -f "/etc/apt/sources.list.d/debian.sources" ]; then
                    $SUDO sed 's/main/contrib/' < /etc/apt/sources.list.d/debian.sources | $SUDO tee /etc/apt/sources.list.d/contrib.sources > /dev/null
                fi
                ;;
        esac
    
        status 'Installing CUDA driver...'
        $SUDO dpkg -i $TEMP_DIR/cuda-keyring.deb
        $SUDO apt-get update
    
        [ -n "$SUDO" ] && SUDO_E="$SUDO -E" || SUDO_E=
        DEBIAN_FRONTEND=noninteractive $SUDO_E apt-get -y install cuda-drivers -q
    }
    
    if [ ! -f "/etc/os-release" ]; then
        error "Unknown distribution. Skipping CUDA installation."
    fi
    
    . /etc/os-release
    
    OS_NAME=$ID
    OS_VERSION=$VERSION_ID
    
    PACKAGE_MANAGER=
    for PACKAGE_MANAGER in dnf yum apt-get; do
        if available $PACKAGE_MANAGER; then
            break
        fi
    done
    
    if [ -z "$PACKAGE_MANAGER" ]; then
        error "Unknown package manager. Skipping CUDA installation."
    fi
    
    if ! check_gpu nvidia-smi || [ -z "$(nvidia-smi | grep -o "CUDA Version: [0-9]*\.[0-9]*")" ]; then
        case $OS_NAME in
            centos|rhel) install_cuda_driver_yum 'rhel' $(echo $OS_VERSION | cut -d '.' -f 1) ;;
            rocky) install_cuda_driver_yum 'rhel' $(echo $OS_VERSION | cut -c1) ;;
            fedora) [ $OS_VERSION -lt '39' ] && install_cuda_driver_yum $OS_NAME $OS_VERSION || install_cuda_driver_yum $OS_NAME '39';;
            amzn) install_cuda_driver_yum 'fedora' '37' ;;
            debian) install_cuda_driver_apt $OS_NAME $OS_VERSION ;;
            ubuntu) install_cuda_driver_apt $OS_NAME $(echo $OS_VERSION | sed 's/\.//') ;;
            *) exit ;;
        esac
    fi
    
    if ! lsmod | grep -q nvidia || ! lsmod | grep -q nvidia_uvm; then
        KERNEL_RELEASE="$(uname -r)"
        case $OS_NAME in
            rocky) $SUDO $PACKAGE_MANAGER -y install kernel-devel kernel-headers ;;
            centos|rhel|amzn) $SUDO $PACKAGE_MANAGER -y install kernel-devel-$KERNEL_RELEASE kernel-headers-$KERNEL_RELEASE ;;
            fedora) $SUDO $PACKAGE_MANAGER -y install kernel-devel-$KERNEL_RELEASE ;;
            debian|ubuntu) $SUDO apt-get -y install linux-headers-$KERNEL_RELEASE ;;
            *) exit ;;
        esac
    
        NVIDIA_CUDA_VERSION=$($SUDO dkms status | awk -F: '/added/ { print $1 }')
        if [ -n "$NVIDIA_CUDA_VERSION" ]; then
            $SUDO dkms install $NVIDIA_CUDA_VERSION
        fi
    
        if lsmod | grep -q nouveau; then
            status 'Reboot to complete NVIDIA CUDA driver install.'
            exit 0
        fi
    
        $SUDO modprobe nvidia
        $SUDO modprobe nvidia_uvm
    fi
    
    # make sure the NVIDIA modules are loaded on boot with nvidia-persistenced
    if available nvidia-persistenced; then
        $SUDO touch /etc/modules-load.d/nvidia.conf
        MODULES="nvidia nvidia-uvm"
        for MODULE in $MODULES; do
            if ! grep -qxF "$MODULE" /etc/modules-load.d/nvidia.conf; then
                echo "$MODULE" | $SUDO tee -a /etc/modules-load.d/nvidia.conf > /dev/null
            fi
        done
    fi
    
    status "NVIDIA GPU ready."
    install_success
    echo "DONE "
    

    Ollama Container

    startOllama
    llama3.2:1b is populair, maar de code assist kan niet met die omvang werken
    tinydolphin is een model wat voor 'alles' werkt
    
    export PODMAN_IGNORE_CGROUPSV1_WARNING=1
    
    podman stop Ollama
    podman rm Ollama
    
    podman run --name=Ollama -p 11434:11434 -v /home/podman/ollama:/ollama:z -t -d container-registry.oracle.com/os/oraclelinux:8 /bin/bash -c "yum install -y tar net-tools && sleep infinity"
    echo "Wait for linux to start "
    sleep 90
    
    podman exec -d Ollama /bin/bash -c "chmod +x /ollama/install.sh &&  sh /ollama/install.sh  "
    echo "Wait for ollama to start serving "
    sleep 180
    
    podman exec -d Ollama /bin/bash -c " export OLLAMA_HOST=0.0.0.0 && /usr/local/bin/ollama serve && sleep infinity  "
    sleep 120
    #podman exec -d Ollama /bin/bash -c " /usr/local/bin/ollama pull llama3.2:1b "
    podman exec -d Ollama /bin/bash -c " /usr/local/bin/ollama pull tinydolphin "
    sleep 120
    #echo "interactive  ollama run llama3.2:1b 'Hello'"
    echo "interactive  ollama run tinydolphin 'Hello'"
    echo " podman exec -ti Ollama /bin/bash "
    
    

  • chmod +x startOllama.sh
  • ./startOllama.sh


    In een andere sessie

    podman exec -ti Ollama /bin/bash 
    echo "command line version: "
    #ollama run  llama3.2:1b "hello"
    ollama run tinydolphin "hello"
    echo "Interactive version " 
    echo " Search and use /bye to stop " 
    #ollama run llama3.2:1b
    ollama run tinydolphin 
    


    DeepSeek R1

    DeepSeek R1 Model is gemaakt door de Chinesen. Het is open source dus we kunnen het met ollama gebruiken.


    Het model is NIET door supervised learning tot stand gekomen.

    De meeste modellen worden (deels) door supervised learning getrained

    Dat betekent dat een supervisor (= mens) de fout conditie bepaald. Wat is 1 + 1 en het resultaat is misschien 3,
    dan geeft de mens 2 als antwoord en dat wordt door back propagation gecorrigeerd


    De DeepSeek modellen zijn dus niet door mensen getrained, maar interne ' reasoning '
    Reasoning step (denken ipv next-word-prediction)
    Het model is door China gemaakt en dus gecensureerd (Taiwan bijv..)
    Let Op : Veel RAM Required! (op HP_Tower draait het op 64GB)
  • ollama run deepseek-r1:14b-qwen-distill-q4_K_M "hello"
  • ollama run deepseek-r1:32b "How to meassure ollama performance" Kijk naar het CPU gebruik: 1567% :)
        PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
       6956 ollama    20   0   23.0g  20.6g  11576 S  1567  32.9  38:40.44 ollama_lla+
    
  • ollama run deepseek-r1:70b-llama-distill-fp16 "hello"
    Error: model requires more system memory (134.7 GiB) than is available (92.8 GiB)
    
  • ollama rm deepseek-r1:70b-llama-distill-fp16
  • ollama run deepseek-r1:32b "Hello" --verbose
    
    
    
    
    Hello! How can I assist you today? 😊
    
    total duration:       9.351457242s
    load duration:        24.059731ms
    prompt eval count:    4 token(s)
    prompt eval duration: 788ms
    prompt eval rate:     5.08 tokens/s
    eval count:           16 token(s)
    eval duration:        8.537s
    eval rate:            1.87 tokens/s
    
  • ollama run tinydolphin "Hello" --verbose
     Dolphin is happy to hear that you've reached out for assistance. Please feel free to share more details about the
    situation or tasks you would like me to assist with.
    
    total duration:       1.03732973s
    load duration:        7.514242ms
    prompt eval count:    30 token(s)
    prompt eval duration: 27ms
    prompt eval rate:     1111.11 tokens/s
    eval count:           37 token(s)
    eval duration:        1.001s
    eval rate:            36.96 tokens/s
    

    Local Connect

    In de container kan met localhost worden getest of de API werkt:
  • curl http://localhost:11434/api/generate -d '{"model":"llama3.2:1b","prompt":"hello"}'
  • curl http://localhost:11434/api/generate -d '{"model":"tinydolphin","prompt":"hello"}'


  • Nu kun je dus 'command' line versie gebruiken om met het model te praten
  • De Ollama server werkt met API calls waar andere tools gebruik van kunnen maken
  • Je kan met REST API programma's (Python/nodejs etc..) praten met het model

    Verplaats modellen

    De standaard locatie van de modellen kan op een plek staan waar minder storage is.

    Op de HP_Tower was dat met /usr/share het geval. Daar draait geen podman container, maar op bare metal
  • mv /usr/share/ollama/.ollama /home/.ollama; ln -s /home/.ollama /usr/share/ollama/.ollama; chown -R ollama /usr/share/ollama; chmod -R 777 /usr/share/ollama/.ollama

    Open Web UI


  • Run container for open-webui
    Haal de podman interface op
  • (windows) wsl -- ip addr Op de host inspecteren we het netwerk (TODO : onderzoek podman network)
     
    podman inspect --format='{{.NetworkSettings.IPAddress}}' Open
    podman inspect --format='{{.NetworkSettings.IPAddress}}' Ollama
    


    Resultaten:
    [root@DESKTOP-2V6PGAI ~]# podman inspect --format='{{.NetworkSettings.IPAddress}}' Open
    10.88.0.29
    

    [root@DESKTOP-2V6PGAI ~]# podman inspect --format='{{.NetworkSettings.IPAddress}}' Ollama
    10.88.0.2
    




    Op de windows machine met WSL is het gewoon localhost

    Met deze 10.88.0.2 kunnen we vervolgens de Open Web UI geven:
    cat startOpen.sh
    
    export PODMAN_IGNORE_CGROUPSV1_WARNING=1
    
    podman stop Open
    podman rm -f Open
    mkdir /home/podman/Open
    podman run -d -e WEBUI_AUTH=False -p 3000:8080 -e OLLAMA_BASE_URL=http://10.88.0.2:11434 -v /home/podman/Open:/app/backend/data --name Open ghcr.io/open-webui/open-webui:main
    echo " Sleep while starting OpenWebUI "
    sleep 60
    podman exec -t Open /bin/bash -c "apt update -y && apt install -y net-tools curl wget inetutils-ping procps"
    echo " Sleep while starting OpenWebUI "
    sleep 60
    systemctl stop firewalld
    iptables -F
    echo "Open browser : http://localhost:3000 "
    
    
    
    
  • ./startOpen.sh
  • Via remote desktop een browser (chromium / firefox of zo ) starten en localhost 3000 browsen

    Debug in open-web ui die een debian omgeving is:
  • apt update -y && apt install -y net-tools curl wget inetutils-ping htop procps



    Conclusie

  • Windows en Linux kunnen beiden gebruik maken van podman containers
  • In een podman container kunnen we een LLM provider installeren die API aanbeidt waar andere tools gebruik van kunnen maken
  • Volledig lokaal (behalve het ophalen van de large language models en het installeren)
  • Open WEBUI geeft een grafische schil om met de LLM provider te ' praten '
    Dit kan ook allemaal in 1 pakket : GPT4ALL
    De Ollama omgeving is echter zeer populair bij allemaal andere tools en daarom handig om te hebben




    Ollama as a service


    Linux :
  • vi /etc/systemd/system/ollama.service
    [Unit]
    Description=Ollama Service
    After=network-online.target
    
    [Service]
    ExecStart=/usr/local/bin/ollama serve
    User=ollama
    Group=ollama
    Restart=always
    RestartSec=3
    Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"
    Environment="OLLAMA_HOST=0.0.0.0"
    
    [Install]
    WantedBy=default.target
    



  • systemctl daemon-reload
  • systemctl restart ollama



    Node JS

  • startNode.js
    export PODMAN_IGNORE_CGROUPSV1_WARNING=1
    podman stop Node;
    podman rm Node;
    mkdir -p /home/podman/Node
    podman run --name=Node -v /home/podman/Node:/Node:z -t -d container-registry.oracle.com/os/oraclelinux:8 /bin/bash -c " sleep infinity "
    
    echo "Start:  "
    echo "docker exec -ti Node /bin/bash"
    podman exec -ti Node /bin/bash -c "
    dnf install nodejs -y
    dnf install npm -y
    
    node -v
    npm -i nodejs
    echo ' RUN : podman exec -ti Node /bin/bash '
    "
    

  • dnf -y install wget
  • cd /home/podman/Node
  • wget https://htmlstarter.com/AI/NeuraalNetwerk.tar --no-check-certificate
  • tar xvf NeuraalNetwerk.tar ; mv home/podman/Node/* .
    Zie demo NeuraalNetwerk en BrainJS







    Web Scrape


    Om data aan het Model te geven voor RAG (LocalDocs) kunnen we een script maken om data op te halen


    GPT4All + LocalDocs

    Resultaat van WebScraper :
  • wget https://htmlstarter.com/AI/reclassering_nl_data.tar --no-check-certificate
  • Unzip in Documents\Reclassering
  • LocalDocs : Reclassering , folder: c:\users\me\Documents\Reclassering
  • Het systeem gaat indexeren
  • Kies een model (Llama 3.2 1B Instruct) En vink LocalDocs Reclassering aan
  • Stel een vraag : " Reclassering Wie moet ik bellen als ik een afspraak wil maken voor toezicht"
  • Duurt heel lang

  • In onze Node JS omgeving

  • cd /Node
  • mkdir WebScrape WebScrape
  • mkdir data
  • install.sh
    yum install -y atk alsa-lib.x86_64 lib-atk atk.x86_64 cups-libs.x86_64  gtk3.x86_64 ipa-gothic-fonts libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXrandr.x86_64 libXScrnSaver.x86_64 libXtst.x86_64 pango.x86_64  xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-fonts-cyrillic xorg-x11-fonts-misc xorg-x11-fonts-Type1 xorg-x11-utils
    yum install -y nss
    yum install -y atk java-atk-wrapper at-spi2-atk gtk3 libXt libdrm mesa-libgbm java-atk-wrapper at-spi2-atk gtk3 libXt
    dnf install -y atk cups-libs libdrm at-spi2-core libX11 libXcomposite libXdamage libXext libXfixes libXrandr mesa-libgbm libxcb libxkbcommon pango cairo alsa-lib  at-spi2-atk
    
    
    
    npm install axios
    npm install cheerio
    npm install puppeteer
    
    npm install apify
    npm install crawlee
    
    export CRAWLEE_DISABLE_BROWSER_SANDBOX=1
    node ap.js
    
    
    
  • vi WebScrape.js
    import * as fs from 'fs';
    import { Actor } from 'apify';
    import { CheerioCrawler, RequestQueue, htmlToText, downloadListOfUrls } from 'crawlee';
    var sitemapUrls=[];
    var counter=0;
    
    
    
    
    var server="photoquesting.com";
    var path="TODO";
    server="www.reclassering.nl";
    path="sitemap_index.xml";
    //http://www.reclassering.nl/sitemap_index.xml
    
    
    const requestQueue = await RequestQueue.open();
    
    
    await Actor.init();
    
    
    
    
    const crawler = new CheerioCrawler({
        minConcurrency: 1, // Minimal concurrency to avoid overwhelming the server
        maxConcurrency: 1, // Ensures requests happen one at a time
        requestHandlerTimeoutSecs: 30,
        maxRequestsPerCrawl: 10000,
        maxRequestRetries: 5, // Retry requests up to 5 times
    
        // Add delay between requests
        preNavigationHooks: [
            async () => {
                const delay = Math.random() * (2000 - 1000) + 1000; // Random delay between 1-2 seconds
                console.log(`Delaying request by ${Math.round(delay)} ms...`);
                await new Promise((resolve) => setTimeout(resolve, delay));
            },
        ],
    
        requestHandler: async ({ request, body, enqueueLinks }) => {
            if (request.url.indexOf("sitemap") < 0) {
                    if(request.url.indexOf("pdf") < 0 && request.url.indexOf("png") < 0 && request.url.indexOf("gif") < 0 ){
                console.log("Write counter: ", counter);
                const text = htmlToText(body);
                fs.writeFileSync(`data/${counter}.txt`, text);
                counter++;
                    }
            } else {
                const dataSplit = body.split("");
                for (let d = 0; d < dataSplit.length; d++) {
                    const goUrl = dataSplit[d];
                    if (!goUrl) continue;
                    const url = goUrl.split("")[0];
                    if (url.indexOf("xml") > -1) continue;
                    await requestQueue.addRequest({ url });
                }
            }
    
            // Add all links from the page to the request queue
            await enqueueLinks();
        },
    
        failedRequestHandler: async ({ request }) => {
            console.error(`Request ${request.url} failed multiple times.`);
        },
    });
    
    // Fetch list of URLs
    const listOfUrls = await downloadListOfUrls({ url: `http://${server}/${path}` });
    const browseUrls = listOfUrls.filter((u) => u && u.indexOf(server) >= 0);
    
    console.log("browserUrls: ", browseUrls);
    
    // Process in batches with a delay between each batch
    const batchSize = 10; // Number of URLs to process per batch
    const delayBetweenBatches = 30000; // 30 seconds delay between batches
    
    for (let i = 0; i < browseUrls.length; i += batchSize) {
        const batch = browseUrls.slice(i, i + batchSize);
        console.log(`Processing batch ${Math.ceil(i / batchSize) + 1}`);
        await crawler.run(batch);
    
        if (i + batchSize < browseUrls.length) {
            console.log(`Pausing for ${delayBetweenBatches / 1000} seconds before the next batch...`);
            await new Promise((resolve) => setTimeout(resolve, delayBetweenBatches));
        }
    }
    
    
    
    
    





  • De bedoeling is dat de webscraper data als local docs wordt gebruikt in de demo

  • tar cvf /tmp/data.tar data/*
  • scp /tmp/data.tar root@192.168.0.121:/tmp/data.tar


    Hevel het over


  • cd /root/gpt4all/
  • cp /tmp/data.tar .
  • tar xvf data.tar Ga nu weer naar GPT4ALL en gebruik docs



    Visual Studio Code



    Command Prompt As System Administrator
  • powershell
    wsl -- ip -o -4 addr list eth0
        eth0    inet 172.20.18.157/20 brd 172.20.31.255 scope global eth0\       valid_lft forever preferred_lft forever
    
    Gebruik dit adres om te zoeken: 
       #curl http://172.20.18.157:11434/api/generate -d "{\"model\":\"llama3.2:1b\",\"prompt\":\"hello\"}"
    	curl http://172.20.18.157:11434/api/generate -d "{\"model\":\"tinydolphin\",\"prompt\":\"hello\"}"
    
    
    
    
    Op Acer: met curl curl http://localhost:11434/api/chat -d "{\"model\":\"tinydolphin\",\"prompt\":\"hello\"}"
    OK

    Download Linux of Windows versie
  • https://code.visualstudio.com/download
    Download https://code.visualstudio.com/sha/download?build=stable&os=linux-rpm-x64
  • echo ' rpm -i code-1.96.4-1736991167.el8.x86_64.rpm '
    rpm --import https://packages.microsoft.com/keys/microsoft.asc
    echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/yum.repos.d/vscode.repo > /dev/null
    
    dnf install -y code # or code-insiders
    
    

  • Browse : https://open-vsx.org/extension/Continue/continue
  • Download For Linux the 255 release is ' too new '

  • wget https://open-vsx.org/api/Continue/continue/linux-x64/0.9.255/file/Continue.continue-0.9.255@linux-x64.vsix
  • wget https://open-vsx.org/api/Continue/continue/linux-x64/0.9.159/file/Continue.continue-0.9.159@linux-x64.vsix Belangrijk : installeer code met root, maar werk met user !!! (me)
  • Login met me
  • wget https://open-vsx.org/api/Continue/continue/linux-x64/0.9.159/file/Continue.continue-0.9.159@linux-x64.vsix
  • code --install-extension Continue.continue-0.9.159@linux-x64.vsix
  • as root code --no-sandbox --user-data-dir /home/me --install-extension Continue.continue-0.9.255@linux-x64.vsix
  • code --no-sandbox --user-data-dir /home/me --install-extension Continue.continue-0.9.159@linux-x64.vsix


  • code
  • Genereer code met modellen

    Windows

    Daarna : https://www.continue.dev/
  • Visual Studio Code kiezen
  • Linux: in code : Ctrl-P : ' ext install Continue.continue '
  • Windows: Install Continue - Codestral
  • Click op CodeStral Icon
    * v dropdown model activation * Add Chat Model ** Provider : ollama ** Click on Config files
    Put this inside the models:
    {
      "models": [
        {
          "apiBase": "http://localhost:11434/",
          "model": "tinydolphin",
          "provider": "ollama",
          "title": "MyOwn"
        } 
    	],
      "tabAutocompleteModel": {
        "title": "tinydolphin",
        "provider": "ollama",
        "model": "tinydolphin"
      },
      "embeddingsProvider": {
        "provider": "transformers.js"
      }
    }
    
    
       "models": [
        {
          "apiBase": "http://172.20.18.157:11434/",
          "model": "tinydolphin",
          "provider": "ollama",
          "title": "MyOwn"
        } 
    	]
      
  • Selecteer Wiel icoon als iets niet goed geconfigureerd staat.
  • Of het paneel met het menu 'Local' en gebruik 'config_file' om waarden te veranderen
  • Selecteer 'MyOwn'
  • Copy paste this into the chat :
    Write an index.html with a title 'Hello World' and a body with a button with a label 'Click Me' and when pressed should alert the following code 'You Hit Me'.
    

    Debug


  • (error 500 internal error (show logs : memory!)
  • Error 404 : Verkeerde URL : Doe de test met curl


    Stable Diffusion


    Op HP machine op Windows(!) niet uit te voeren, vooralsnog : te weinig geheugen!

    Wel met WSL op de i7 met 16GB

    Het model vereist 10GB vrij.
  • HP Machine Z Tower met Oracle Linux 9 en > 64GB memory (niet onderdeel van de demo)

    Maar dan weer niet met podman container
    Gebruik podman alleen op een systeem met genoeg power (16GB is net genoeg)
  • HP Laptop : geen WSL ! Virtual Box met Oracle Linux 9.5 en 11GB + 60GB diskruimte

  • Bij WSL omgeving kwam er na 32 iteraties een KILL
    32 iteraties : KILL
  • Memory > 15GB !!!

  • VirtualBox : in de directory komt output.png te staan.
  • vanuit de virtualbox-host : pscp root@192.168.0.191:/root/stable_diffusion.openvino/output.png Tests:
    python3 demo.py --prompt "A girl riding a horse on the beach with fish flying in the air. Realistic style "
    
    
  • mkdir -p /home/podman/BesDev
  • vi /home/podman/startBesDev.sh
    export PODMAN_IGNORE_CGROUPSV1_WARNING=1
    podman stop BesDev;
    podman rm BesDev;
    mkdir -p /home/podman/BesDev
    podman run --name=BesDev -v /home/podman/BesDev:/BesDev:z -t -d container-registry.oracle.com/os/oraclelinux:8 /bin/bash -c " sleep infinity "
    
    echo "Start:  "
    echo "podman exec -ti BesDev /bin/bash"
    echo " cd /BesDev; sh install.sh " 
    
  • vi /home/podman/BesDev/install.sh # Edit requirements.txt
     cd /home/podman/BesDev
     dnf install -y git 
     dnf install -y pip 
     
     yum install -y python3.9 
     yum install -y npm 
     npm install pip 
     yum install -y git 
     cp /usr/bin/python3.9 /usr/bin/python 
     python -V  
     
     git clone https://github.com/bes-dev/stable_diffusion.openvino.git
     cd stable_diffusion.openvino/
     pip3 install openvino==2024.6.0
     pip3 install openvino-dev[onnx,pytorch]==2024.6.0
     dnf install -y mesa-libGL
    pip3 install torch 
    
    echo " change requirements " 
    
    
  • Edit requirements for openvion to allow 2024.6.0 : openvino==2024.6.0 instead of the 2022 one
  • echo 'pip3 install -r requirements.txt' ???
    
    #export PYTHONPATH=$PWD:$PYTHONPATH
    #export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
    
    
    
  • echo 'python3 demo.py --prompt "Clown balancing on an elephant who is balancing on a rope in a circus in realistic style"'

    PAS OP : Wijzig REQUIREMENTS.TXT van 2023 naar 2024.6.0




    WSL + output.png
    ??
  • In directory stable staat dan output.png
  • ??? %LOCALAPPDATA%\Packages\
  • cp output.png /tmp/.
  • op windows machine bijvoorbeeld: pscp root@192.168.0.121:/tmp/output.png Pictures/.






    Eigen Neuraal Netwerken


    NodeJS Neural Net


    class Neuron {
      constructor() {
        this.inputConnections = []
        this.outputConnections = []
        this.bias = 0
        // delta is used to store a percentage of change in the weight
        this.delta = 0
        this.output = 0
        this.error = 0
      }
    
      getRandomBias() {
        const min = -3;
        const max = 3
        return Math.floor(Math.random() * (+max - +min)) +min;
      }
    
      addInputConnection(connection) {
        this.inputConnections.push(connection)
      }
    
      addOutputConnection(connection) {
        this.outputConnections.push(connection)
      }
    
      setBias(val) {
        this.bias = val
      }
    
      setOutput(val) {
        this.output = val
      }
    
      setDelta(val) {
        this.delta = val
      }
    
      setError(val) {
        this.error = val
      }
    }
    
    // End Of Neuron
    
    class Layer {
      constructor(numberOfNeurons) {
        const neurons = []
        for (var j = 0; j < numberOfNeurons; j++) {
          // const value = Math.random()
          const neuron = new Neuron()
    
          // Neurons in other than initial layer have a bias value
    
          neurons.push(neuron)
        }
    
        this.neurons = neurons
      }
    
    }
    
    // End Of Layer
    
    
    // Connect Layers
    class Connection {
      constructor(from, to) {
        this.from = from
        this.to = to
        this.weight = Math.random()
        this.change = 0
      }
    
    
      setWeight(w) {
        this.weight = w
      }
    
      setChange(val) {
        this.change = val
      }
    }
    
    // End Of Connection
    
    
    
    class Network {
      constructor(numberOfLayers) {
        this.layers = numberOfLayers.map((length, index) => {
          const layer = new Layer(length)
          if (index !== 0 ) {
            layer.neurons.forEach(neuron => {
              neuron.setBias(neuron.getRandomBias())
            })
          }
          return layer
        })
        this.learningRate = 0.3  // multiply's against the input and the delta then adds to momentum
        this.momentum =  0.1       // multiply's against the specified "change" then adds to learning rate for change
        this.iterations = 0
        this.connectLayers()
      }
    
    
      setLearningRate(value) {
        this.learningRate = value
      }
    
      setIterations(val) {
        this.iterations = val
      }
    
      connectLayers() {
        for (var layer = 1; layer < this.layers.length; layer++) {
          const thisLayer = this.layers[layer]
          const prevLayer = this.layers[layer - 1]
          for (var neuron = 0; neuron < prevLayer.neurons.length; neuron++) {
            for(var neuronInThisLayer = 0; neuronInThisLayer < thisLayer.neurons.length; neuronInThisLayer++) {
              const connection = new Connection(prevLayer.neurons[neuron], thisLayer.neurons[neuronInThisLayer])
              prevLayer.neurons[neuron].addOutputConnection(connection)
              thisLayer.neurons[neuronInThisLayer].addInputConnection(connection)
            }
          }
        }
      }
    
      // When training we will run this set of functions each time
      train(input, output) {
        this.activate(input)
    
        // Forward propagate
        this.forwardPropagation()
    
        // backpropagate
        this.backwardPropagation(output)
        this.adjustWeights()
        this.setIterations(this.iterations + 1)
      }
    
      activate(values) {
        this.layers[0].neurons.forEach((n, i) => {
          n.setOutput(values[i])
        })
      }
    
      run() {
        // For now we only use sigmoid function
        return this.forwardPropagation()
      }
    
      forwardPropagation() {
        for (var layer = 1; layer < this.layers.length; layer++) {
          for (var neuron = 0; neuron < this.layers[layer].neurons.length; neuron++) {
            const bias = this.layers[layer].neurons[neuron].bias
            // For each neuron in this layer we compute its output value
    
            const connectionsValue = this.layers[layer].neurons[neuron].inputConnections.reduce((prev, conn)  => {
              const val = conn.weight * conn.from.output
              return prev + val
            }, 0)
    
            this.layers[layer].neurons[neuron].setOutput(sigmoid(bias + connectionsValue))
          }
        }
    
        return this.layers[this.layers.length - 1].neurons.map(n => n.output)
      }
    
      backwardPropagation(target) {
        for (let layer = this.layers.length - 1; layer >= 0; layer--) {
          const currentLayer = this.layers[layer]
    
          for (let neuron = 0; neuron < currentLayer.neurons.length; neuron++) {
            const currentNeuron = currentLayer.neurons[neuron]
            let output = currentNeuron.output;
    
            let error = 0;
            if (layer === this.layers.length -1 ) {
              // Is output layer
              error = target[neuron] - output;
              // console.log('calculate delta, error, last layer', error)
            }
            else {
              // Other than output layer
              for (let k = 0; k < currentNeuron.outputConnections.length; k++) {
                const currentConnection = currentNeuron.outputConnections[k]
                error += currentConnection.to.delta * currentConnection.weight
                // console.log('calculate delta, error, inner layer', error)
              }
    
    
            }
            currentNeuron.setError(error)
            currentNeuron.setDelta(error * output * (1 - output))
          }
        }
      }
    
      adjustWeights() {
    
        for (let layer = 1; layer <= this.layers.length -1; layer++) {
          const prevLayer = this.layers[layer - 1]
          const currentLayer = this.layers[layer]
    
          for (let neuron = 0; neuron < currentLayer.neurons.length; neuron++) {
             const currentNeuron = currentLayer.neurons[neuron]
             let delta = currentNeuron.delta
    
            for (let i = 0; i < currentNeuron.inputConnections.length; i++) {
              const currentConnection = currentNeuron.inputConnections[i]
              let change = currentConnection.change
    
              change = (this.learningRate * delta * currentConnection.from.output)
                  + (this.momentum * change);
    
              currentConnection.setChange(change)
              currentConnection.setWeight(currentConnection.weight + change)
            }
    
            currentNeuron.setBias(currentNeuron.bias + (this.learningRate * delta))
    
          }
        }
      }
    
    }
    // End Of Network
    
    function sigmoid(z) {
      return 1 / (1 + Math.exp(-z));
    }
    
    // End Of Functions
    
    //
    // -------------------------
    //
    // Main
    //
    
    // Define the layer structure
    const layers = [
      2, // This is the input layer
      10, // Hidden layer 1
      10, // Hidden layer 2
      1 // Output
    ]
    
    const network = new Network(layers)
    
    // Start training
    const numberOfIterations = 20000
    
    // Training data for a "XOR" logic gate
    const trainingData = [{
      input : [0,0],
      output: [0]
    }, {
      input : [0,1],
      output: [1]
    }, {
      input : [1,0],
      output: [1]
    }, {
      input : [1,1],
      output: [0]
    }]
    
    for(var i = 0; i < numberOfIterations; i ++) {
      // Get a random training sample
      const trainingItem = trainingData[Math.floor((Math.random()*trainingData.length))]
      network.train(trainingItem.input, trainingItem.output);
    }
    
    // After training we can see if it works
    // we call activate to set a input in the first layer
    network.activate(trainingData[0].input)
    const resultA = network.run()
    
    network.activate(trainingData[1].input)
    const resultB = network.run()
    
    network.activate(trainingData[2].input)
    const resultC = network.run()
    
    network.activate(trainingData[3].input)
    const resultD = network.run()
    console.log('Expected 0 got', resultA[0])
    console.log('Expected 1 got', resultB[0])
    console.log('Expected 1 got', resultC[0])
    console.log('Expected 0 got', resultD[0])
    



    XOR Brain JS



    podman exec -ti Node /bin/bash
    cd /Node
    mkdir Brain
    cd Brain
    mkdir xor 
    cd xor 
    
  • npm install --save brain.js@1.4.10 vi xor.js
    
    
    const brain = require('brain.js');
    
    const net = new brain.NeuralNetwork();
    // Je kan hier op geven hoeveel hiddenlayers er zijn 
    // const net = new brain.NeuralNetwork({ hiddenLayers: [20] });
    
    
    net.train([
      { input: [0, 0], output: [0] },
      { input: [0, 1], output: [1] },
      { input: [1, 0], output: [1] },
      { input: [1, 1], output: [0] },
    ]);
    
    console.log("xor 1,0 : ",
     net.run([1, 0]), " Als het bijna 1 is, dan is het 1 "
    );
    
    
    
    ----

    LSTM (Long Short Term Memory)

    ----
    
    const brain = require('brain.js');
    
    const trainingData = [
      'Jane saw Doug.',
      'Doug saw Jane.',
      'Spot saw Doug and Jane looking at each other.',
      'It was love at first sight, and Spot had a frontrow seat. It was a very special moment'
    ];
    
    // zelfde opties : hiddenLayers bijvoorbeeld
    const net = new brain.recurrent.LSTM();
    
    console.log("TRAIN");
    
    net.train(trainingData, {
       iterations: 1500,
       errorThresh: 0.011,
            log: true,
            logPeriod: 10
    });
    
    console.log("Jane", net.run('Jane'));
    console.log("It was", net.run('It was'));
    
    
    
    // Show errorThresh and iterations difference ----

    Reinforcement

    -----
    //
    // Reinforcement learning
    //
    //
    // Bron: https://www.youtube.com/watch?v=6E6XecoTRVo
    const brain = require('brain.js');
    
    
    const trainingData =[
      { input: [0, 0], output: [0] },
      { input: [0, 1], output: [1] },
      //{ input: [1, 0], output: [1] },
      //{ input: [1, 1], output: [0] },
    ];
    
    const net = new brain.NeuralNetwork({hiddenLayers: [3] });
    net.train(trainingData);
    
    console.log(" Voor reinforcement (het systeem heeft deze data nog niet gezien) " )
    console.log(Array.from(net.run([1,0])));
    
    trainingData.push({ input: [1,0], output: [1] });
    net.train(trainingData);
    
    console.log(" Na reinforcement " )
    console.log(Array.from(net.run([1,0])));
    
    

    Stable Diffusion


    Modellen: VAE : Variational AutoEncoders GANs : Generative Adversarial Networks

    Diffusion Model

    Een verspreidings model .. ruis model ... een plaatje met allemaal willekeurige gekleurde pixels Hoe werkt dat? Variational AutoEncoder is een model dat de concepten van een autoencoder en een variationaal inteferentie model combinineert. Geen idee wat hier staat :D Twee methode voor een generator model: * onconditioneel : Ruis beeld (allemaal willekeurige kleurtjes) en wordt door het model omgetoverd tot een beeld * conditioneel : Door een prompt (vraag). Dit kan een tekst, label (voor gedefineerd) of bijvoorbeeld andere plaatjes. * Forward Diffusion : Gaat van een normale foto uit en maakt in elke stap een meer willekeurig-pixel-versie * DDPM Scheduler neemt een aantal stappen om van een goede : max_timesteps turn clear imae to noise Dus je gaat van prima fotos naar troep ... waarvoor? We moeten juist van troep naar iets herkenbaars.. Dat heet Reverse Diffusion. Die foward diffusion 'traint' het neurale netwerk. Dus een label van een persoon. Mijn inschatting is dat de labels van datgene wat je zoekt dan die stappen gebruiken om 'samen te voegen' maar dan van ruis naar helder. U-NET heet het architectuur dat ruis ' weghaalt ' om naar de helderheid te komen. encoding/decoding stap Die architectuur gebruikt convulutional neural networks. (CNN) Een voorbeeld van zo een convulutional neural network is het gebruik van meerdere lagen. We hoeven geen gebruik te maken van dezelfde neuron-fucties. Dus waar we bij een ' normaal ' neuraal netwerk zeiden dat een hidden layer (verborgen laag) bestond uit een aantal neurons, dan hadden we het eigenlijk over dezelfde soort neurons. Een convolutionaal neuron ' zoekt ' de kenmerken van de neuron in de verzameling. Denk hierbij aan een pizza. Er zit kaas, tomaat en servelaat op de pizza, maar overal is een beetje. Dan ' kijk ' je met een vorm naar de hele pizza. Stel de ' vorm ' is een vierkant en die begint links boven de doos. Een deel van de pizza is zichtbaar. Dit neuron kijkt naar kaas. Dus als er een stukje kaas gevonden wordt in het vierkant dan wordt die geteld. Het vierkant wordt verchoven van links boven een stukje naar rechts. Weer ' kijkt ' de neuron met de vorm (vierkant) naar de pizza en telt de delen kaas. Omdat de vorm (vierkant) groot kan zijn kan hetzelfde stukje kaas van de eerste ' scan ' weer worden gevonden: daarmee krijgt het vierkant een grote waarde. Dan kunnen er dus een heleboel verschillende neuronen allemaal die pizza bekijken. De vorm kan veranderen (cirkel, 5 horizontaal pixels bij 1 pixel, vertikaal etc..) en dat wat bekeken wordt (kaas, tomaat etc..) Een foto van een pizza levert dan een hoge score op voor kaas, cervelaat etc.. maar mogelijk ook de neuron ' algemene vorm ' = cirkel Hetzelfde geldt bijvoorbeeld voor het zoeken naar ogen ' die kunnen worden omschreven m.b.t. vorm/kleur etc.. ' en ook neuzen en monden en die neuronen allemaal bij elkaar kunnen dan weer gezichten vinden. -----
    ----
    
    

    Latent diffiusin models (LDMs) in feite compressie .. 192x192x3 pixels naar kleiner setje 32x32x3 pixels

    --- conditional Use a dataset .. And maybe use a script to generate text prompts for the features. Dus een man of een vrouw, met lang of kort haar, lachend , huilend etc .. Text embeding op basis van een CLIP model Tokenizer (maak unieke opzoekbare labels) = " jonge lachende vrouw " = " jong ", " lach " , " vrouw" Dat gaat naarde Text Encoder (LSTM zie Brainjs) en dat levert een aantal embedded vectors op (getallen) Er zijn dan hidden layers van de Text Encoder en de Hidden Layers van de Image encoder en daar wordt dan de 'dot product' van berekent. Dot Product: ' Boodschappen lijstje : 3 appels x 2 euro = 6 euro 2 eieren x 1 euro = 2 euro 5 broden x 3 euro = 15 euro Tel dit allemaal op : 23 euro <- dat is een dot product en dit wordt getoond als een soort spreadsheet: Rij 1 : [ 3,2,5 ] de aantallen Rij 2: [ 2,1,3 ] de prijzen Dus tel op ( van rij 1.kolom1 x rij 2.kolom1 ) + ( rij 1 kolom.2 x rij 2.kolom2) + (rij 1 kolom.3 x rij 2.kolom3) " diffusion model conditional nodejs brainjs noise forard diffusion ddpm scheduler reverse diffusion u-net architecture convolution network text embeding large training set labels "

    ''' Demo BesDev met Virtual Box '''
    WSL Diffusion Python code : een (sterke) GPU is nodig!
  • pip install torch torchvision diffusers matplotlib

  • // https://github.com/fastai/fastdiffusion/blob/master/nbs/tcapelle/Diffusion_models_with_fastai_conditional_cifart_EMA.ipynb

  • https://colab.research.google.com/drive/1sjy9odlSSy0RBVgMTgP7s99NXsqglsUL?usp=sharing#scrollTo=wLHSIArLcFK0
    
    
    Python:
    
    from diffusers import DDMScheduler
    
    max_timesteps = 10;
    
    noise_scheduler = DDMScheduler(num_train_timesteps=max_timesteps,
                                   beta_start = -0.00001,
    							   beta_end   = 0.02
    							   )
    # which image? Where is the method?
    image = torch.tensor(load_img()); 
    img_shape = image.shape;
    
    timesteps = torch.arrange(1, max_timesteps) 
    noise     = torch.randn(img_shape) 
    
    noise_images = noise_scheduler.add_noise(image, noise, timesteps).numpy()
    
    plot_images(timesteps, noise_images)
    
    
    
    
    
    
    Python code : 
    
    
    import os
    import torch
    import torch.nn as nn
    import torch.optim as optim
    import torchvision.transforms as transforms
    import torchvision.datasets as datasets
    from torch.utils.data import DataLoader
    from diffusers import UNet2DModel, DDPMScheduler
    
    # Download and prepare dataset
    DATASET_URL = "https://storage.googleapis.com/mnist-dataset/mnist_png.tar.gz"
    DATA_DIR = "./mnist_data"
    
    if not os.path.exists(DATA_DIR):
        os.makedirs(DATA_DIR, exist_ok=True)
        os.system(f"wget {DATASET_URL} -O mnist.tar.gz")
        os.system("tar -xzf mnist.tar.gz -C ./mnist_data")
    
    # Define image transformations
    transform = transforms.Compose([
        transforms.Grayscale(num_output_channels=1),
        transforms.Resize((28, 28)),
        transforms.ToTensor(),
        transforms.Normalize((0.5,), (0.5,))
    ])
    
    # Load the dataset
    dataset = datasets.ImageFolder(root=os.path.join(DATA_DIR, "mnist_png", "training"), transform=transform)
    data_loader = DataLoader(dataset, batch_size=64, shuffle=True)
    
    # Define the U-Net model
    model = UNet2DModel(
        sample_size=28,  # Image size (28x28 for MNIST)
        in_channels=1,  # Grayscale input
        out_channels=1,  # Grayscale output
        layers_per_block=2,
        block_out_channels=(64, 128, 256),  # Number of channels in each U-Net block
        down_block_types=("DownBlock2D", "DownBlock2D", "AttnDownBlock2D"),
        up_block_types=("AttnUpBlock2D", "UpBlock2D", "UpBlock2D"),
    )
    
    # Define the diffusion scheduler
    scheduler = DDPMScheduler(num_train_timesteps=1000)
    
    # Define the optimizer
    optimizer = optim.Adam(model.parameters(), lr=1e-4)
    
    # Define training loop
    def train_model(num_epochs=5):
        device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
        model.to(device)
        model.train()
    
        for epoch in range(num_epochs):
            for batch_idx, (images, _) in enumerate(data_loader):
                images = images.to(device)
    
                # Forward diffusion (add noise)
                timesteps = torch.randint(0, scheduler.num_train_timesteps, (images.size(0),), device=device)
                noisy_images, noise = scheduler.add_noise(images, timesteps)
    
                # Predict the noise
                predicted_noise = model(noisy_images, timesteps).sample
    
                # Compute loss (mean squared error)
                loss = nn.MSELoss()(predicted_noise, noise)
    
                # Backpropagation
                optimizer.zero_grad()
                loss.backward()
                optimizer.step()
    
                if batch_idx % 100 == 0:
                    print(f"Epoch [{epoch+1}/{num_epochs}], Step [{batch_idx+1}/{len(data_loader)}], Loss: {loss.item():.4f}")
    
        print("Training complete.")
    
    # Define a test function to visualize results
    def test_model():
        import matplotlib.pyplot as plt
        model.eval()
        device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
        images, _ = next(iter(data_loader))
        images = images.to(device)
    
        timesteps = torch.randint(0, scheduler.num_train_timesteps, (images.size(0),), device=device)
        noisy_images, _ = scheduler.add_noise(images, timesteps)
    
        with torch.no_grad():
            denoised_images = model(noisy_images, timesteps).sample
    
        # Plot original, noisy, and denoised images
        fig, axes = plt.subplots(3, 5, figsize=(10, 6))
        for i in range(5):
            axes[0, i].imshow(images[i].cpu().squeeze(), cmap="gray")
            axes[0, i].set_title("Original")
            axes[1, i].imshow(noisy_images[i].cpu().squeeze(), cmap="gray")
            axes[1, i].set_title("Noisy")
            axes[2, i].imshow(denoised_images[i].cpu().squeeze(), cmap="gray")
            axes[2, i].set_title("Denoised")
    
        plt.tight_layout()
        plt.show()
    
    # Train and test the model
    train_model(num_epochs=5)
    test_model()
    
    
    
    
    
    
    # Load Data Set
    images = load_batch_data(batch_size=128)
    img_shape = images.shape # Batch size, num channels w, h)
    
    # Run augmentations like flipping, brightness, contrast  , rotation and image size  
    augmented_images = augment(images)
    
    # Forward
    
    timesteps = torch.randint(0, max_timesteps, {len(images),})
    noise = torch.randn(img_shape)
    
    noisy_images=noise_scheduler.add_noise(images, noise, timesteps).numpy()
    
    predition = unet_model(noisy_images, timesteps, return_dict=False)[0]
    
    los = F.mse_loss(predition, noise)
    
    # Update .. back 
    los.backward()
    optimizer.step()
    optimizer.zero_grad()
    
    
    # Inference
    tareget_img_shape = [32,32,3]
    generator = torch.Generator(device=device).manual_seed(np.random.rnadnit(1,100))
    
    image=torch.randn(size=(1,*target_img_shape), generator=generator)
    
    for idx, t in enumerate(timesteps):
       model_output = unet_model(image,t)
       image = noise_scheduler.step(model_output, t, image, generator=generator).prev_sample
       
       
      
    

    Analyse



    Wat tijdens analyse naar voren kwam:

    Debug


    Podman



    Kijk of je nu met ssh op het systeem kan inloggen
  • yum install -y openssh-server
    ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ""
    ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ""
    ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ""
    ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ed25519_key -N "" 
    
    /usr/sbin/sshd # systemctl restart sshd
    Connect met putty naar 127.0.0.1 op poort 2222
    Zodra dat werkt kun je doorgaan met de andere delen van installatie
    yum install -y -q nftables





    NVIDIA



    TO BE DONE WITH GOOD NVIDIA CARD

    Windows


  • https://www.nvidia.com/en-eu/drivers/details/132997/
    Driver
  • https://uk.download.nvidia.com/Windows/391.35/391.35-notebook-win10-64bit-international-whql.exe
    GFX drivers from intel
  • https://www.intel.com/content/www/us/en/download/19344/intel-graphics-windows-dch-drivers.html

    Linux


    Na reguliere Oracle Linux installatie (terminal : ifconfig = IP adres!)
  • Vanuit putty contact maken met die linux machine
  • systemctl stop firewalld; systemctl disable firewalld
  • setenforce 0
  • vi /etc/selinux/config : SELINUX=disabled
  • yum update -y
  • yum -y install epel-release
  • yum install -y xrdp
  • # Niet doen .. werkt waarschijnlijk niet op centos : yum install xorg-x11-server-Xorg xorg-x11-xauth xorg-x11-apps -y
    
    sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
    sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
    yum update -y
    
    systemctl set-default graphical.target
    setsebool -P xrdp_selinux on
    
    dnf -y group install "xfce" && dnf -y install lightdm
    
    dnf -y install epel-release && dnf config-manager --set-enabled powertools
    
    systemctl enable lightdm
    dnf -y install xrdp xorgxrdp
    
    
    


  • Test met remote desktop op windows machine om linux systeem te benaderen.

    Sesman problemen


  • dnf install -y xorgxrdp # oel9
  • dnf install -y xorg-x11-drv-dummy # oel8 / centos 8


    wijzig /etc/xrdp/xrdp.ini
    [Xorg]
    name=Xorg
    lib=libxup.so
    username=ask
    password=ask
    port=-1
    code=20
    # Frame capture interval (milliseconds)
    h264_frame_interval=16
    rfx_frame_interval=32
    normal_frame_interval=40
    param=/usr/libexec/Xorg
    
    
    #[Xvnc]
    #name=Xvnc
    #lib=libvnc.so
    #username=ask
    #password=ask
    #ip=127.0.0.1
    #port=-1
    #xserverbpp=24
    #delay_ms=2000
    ; Disable requested encodings to support buggy VNC servers
    ; (1 = ExtendedDesktopSize)
    #disabled_encodings_mask=0
    
    
    # Ergens in de file staat ook max_bpp
    
    max_bpp=24
    
    
    uitschakelen van Wayland
    
    sed '/^#WaylandEnable/s/^#//g' /etc/gdm/custom.conf
    sed -i 's/^#.*WaylandEnable=.*/WaylandEnable=false/' /etc/gdm/custom.conf
    
    

    Linux GPU

    Sla dit over op de HP Machine : te ' kleine ' GPU om daadwerkelijk wat aan te hebben
  • wget https://us.download.nvidia.com/XFree86/Linux-x86_64/550.144.03/NVIDIA-Linux-x86_64-550.144.03.run
  • Turn off X : init 3
  • sh NVIDIA-Linux-x86_64-550.144.03.run
     Melding dat je deze moet hebben : NVIDIA 390.xx legacy Linux :
    
  • wget https://us.download.nvidia.com/XFree86/Linux-x86_64/390.157/NVIDIA-Linux-x86_64-390.157.run
  • sh NVIDIA-Linux-x86_64-390.157.run

    Nouveau Kernel driver in use

    dnf groupinstall -y "Development Tools"
    dnf install -y openssl-devel zlib-devel
    
    #Stop X from starting
    
    service gdm stop
    # vi /etc/default/grub
    # add ' 3 rd.driver.blacklist=nouveau'  to the CMDLINE 
    grub2-mkconfig -o /boot/grub2/grub.cfg
    
    
    yum install -y kernel
    yum install -y kernel-headers 
    yum install -y kernel-devel 
    
    dnf install kernel-devel
    
    yum -y install epel-release
    
    # fedora
    echo -e  "blacklist nouveau\noptions nouveau modeset=0\n"  > /usr/lib/modprobe.d/blacklist-nouveau.conf 
    # centos
    echo -e  "blacklist nouveau\noptions nouveau modeset=0\n"  > /etc/modprobe.d/blacklist-nouveau.conf
    
    yum install -y dkms 
    
    yum update -y kernel kernel-headers
     
    dracut --force
    sync 
    
    reb00t
    
    
    echo "/usr/sbin/modprobe" >  /proc/sys/kernel/modprobe
    
    
    VERSION=390.147
    wget http://us.download.nvidia.com/XFree86/Linux-x86_64/${VERSION}/NVIDIA-Linux-x86_64-${VERSION}.run
    chmod +x NVIDIA-Linux-x86_64-${VERSION}.run
    ./NVIDIA-Linux-x86_64-${VERSION}.run 
    
    Register with DKMS (yes)
    
    
    nvidia-smi  # Test
    
    


    Install VirtualBox

  • wget https://download.virtualbox.org/virtualbox/7.1.4/VirtualBox-7.1-7.1.4_165100_el8-1.x86_64.rpm
  • OEl8 dnf install -y https://download.virtualbox.org/virtualbox/7.1.2/VirtualBox-7.1-7.1.2_164945_el8-1.x86_64.rpm
  • OEL9 dnf install -y https://download.virtualbox.org/virtualbox/7.1.4/VirtualBox-7.1-7.1.4_165100_el9-1.x86_64.rpm In xterminal:
  • VirtualBox
  • Windows : Systeem
  • Beeldscherm : Grafische instellingen
  • Bureaublad-app : Bladeren
  • c:\program files\Oracle\VirtualBox\VirtualBox.exe
  • Toevoegen : Hoge Prestaties NVIDIA
    
    
  • Default vgoxuser password is changeme (unattended install) : su - (changeme), passwd root
  • Root wachtwoord eveneens changeme


    Monitoring


    We willen verkeer monitoren als we geen modellen downloaden

    Ik ben benieuwd of en welke data nog uit de server naar het internet gaat

  • export INTERFACE="eth0"
  • export IP="192.168.0.121"
  • tcpdump -i $INTERFACE src $IP and port 80 or port 8080 or port 443
  • Om eventuele URLs te bemachtigen:

  • watch -n1 ' lsof -i TCP:80,443 >> /tmp/urls '
  • Andere sessie: tail -f /tmp/urls | grep -vi listen
  • En in weer andere sessie doe een netwerk actie

    Ollama tests

    Tiny Dolphin

  • [root@localhost ~]# ollama run tinydolphin "What do I need to do when XenServer (linux based) reports error cannot attached vhd, please include commands to check and to correct" --verbose
    total duration:       12m32.390262212s
    load duration:        23.430151ms
    prompt eval count:    32 token(s)
    prompt eval duration: 5.835s
    prompt eval rate:     5.48 tokens/s
    eval count:           1171 token(s)
    eval duration:        12m26.53s
    eval rate:            1.57 tokens/s