From 765406ad795532bb5cb77b67120459ce5f0e1ec5 Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Tue, 1 Apr 2025 21:34:17 +0200 Subject: [PATCH] Added install_nvidia --- install_incus_ollama.sh | 79 +++-------------------------------------- install_nvidia.sh | 74 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 75 deletions(-) create mode 100644 install_nvidia.sh diff --git a/install_incus_ollama.sh b/install_incus_ollama.sh index 9c33baa..0f666c6 100644 --- a/install_incus_ollama.sh +++ b/install_incus_ollama.sh @@ -1,78 +1,8 @@ #!/bin/bash -# Script for create a simple ai system with LXC and Incus. +newgrp incus-admin -## Install updated repos for debian 12 - -echo "Install new repos for debian..." - -sudo bash -c 'echo "deb http://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware" >> /etc/apt/sources.list.d/backports.list' - -sudo curl -fsSL https://pkgs.zabbly.com/key.asc | gpg --show-keys --fingerprint - -sudo mkdir -p /etc/apt/keyrings/ - -sudo curl -fsSL https://pkgs.zabbly.com/key.asc -o /etc/apt/keyrings/zabbly.asc - -sudo sh -c 'cat < /etc/apt/sources.list.d/zabbly-incus-stable.sources -Enabled: yes -Types: deb -URIs: https://pkgs.zabbly.com/incus/stable -Suites: $(. /etc/os-release && echo ${VERSION_CODENAME}) -Components: main -Architectures: $(dpkg --print-architecture) -Signed-By: /etc/apt/keyrings/zabbly.asc - -EOF' - -sudo apt install -y software-properties-common - -sudo apt-add-repository -y contrib - -sudo apt-add-repository -y non-free - -sudo apt-add-repository -y non-free-firmware - -sudo apt-get update && sudo apt-get upgrade - -# Install new kernel. - -sudo apt-get -y install linux-image-6.11.10+bpo-amd64 linux-headers-6.11.10+bpo-amd64 - -# Install cuda nvidia drivers - -echo "Install nvidia drivers" - -sudo apt -y purge "*nvidia*" - -wget https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/cuda-keyring_1.1-1_all.deb -sudo dpkg -i cuda-keyring_1.1-1_all.deb -sudo apt-get -y -f install -sudo apt -y update - -sudo bash -c 'echo "deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/ /" \ - | tee /etc/apt/sources.list.d/cuda-debian12-x86_64.list' - -sudo apt -y update - -sudo apt -y install cuda-drivers - -sudo apt -y install curl -sudo curl -fsSL https://ollama.com/install.sh | sh - -sudo systemctl stop ollama && sudo systemctl disable ollama - -# Installing incus - -echo "Installing Incus" - -sudo apt -y install qemu-system-x86/bookworm-backports qemu-system-common/bookworm-backports qemu-system-data/bookworm-backports seabios/bookworm-backports - -sudo apt -y install incus - -sudo usermod -a -G incus,incus-admin $USER - -incus admin init +sg incus-admin -c "incus admin init" # Install ollama container @@ -86,7 +16,7 @@ incus config device add ollama-container gpu gpu # Install nvidia -incus exec ollama-container -- bash -c 'echo "deb http://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware" >> /etc/apt/sources.list.d/backports.list' +incus exec ollama-container -- bash -c 'echo "deb http://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware" > /etc/apt/sources.list.d/backports.list' incus exec ollama-container -- curl -fsSL https://pkgs.zabbly.com/key.asc | gpg --show-keys --fingerprint @@ -144,10 +74,9 @@ incus exec ollama-container -- curl -fsSL https://ollama.com/install.sh | sh incus exec ollama-container -- ollama run gemma3:4b - echo "Done!!!" sleep 3 -echo "Please, you can enter to ollama container with incus exec ollama-container -- /bin/bash" +echo "You can enter to ollama container with incus exec ollama-container -- /bin/bash" echo "Use journalctl -u ollama.service command for check if ollama is working" diff --git a/install_nvidia.sh b/install_nvidia.sh new file mode 100644 index 0000000..1c3202c --- /dev/null +++ b/install_nvidia.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +# Script for create a simple ai system with LXC and Incus. + +## Install updated repos for debian 12 + +echo "Install new repos for debian..." + +sudo bash -c 'echo "deb http://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware" > /etc/apt/sources.list.d/backports.list' + +sudo curl -fsSL https://pkgs.zabbly.com/key.asc | gpg --show-keys --fingerprint + +sudo mkdir -p /etc/apt/keyrings/ + +sudo curl -fsSL https://pkgs.zabbly.com/key.asc -o /etc/apt/keyrings/zabbly.asc + +sudo sh -c 'cat < /etc/apt/sources.list.d/zabbly-incus-stable.sources +Enabled: yes +Types: deb +URIs: https://pkgs.zabbly.com/incus/stable +Suites: $(. /etc/os-release && echo ${VERSION_CODENAME}) +Components: main +Architectures: $(dpkg --print-architecture) +Signed-By: /etc/apt/keyrings/zabbly.asc + +EOF' + +sudo apt install -y software-properties-common + +sudo apt-add-repository -y contrib + +sudo apt-add-repository -y non-free + +sudo apt-add-repository -y non-free-firmware + +sudo apt-get update && sudo apt-get upgrade + +# Install new kernel. + +sudo apt-get -y install linux-image-6.11.10+bpo-amd64 linux-headers-6.11.10+bpo-amd64 + +# Install cuda nvidia drivers + +echo "Install nvidia drivers" + +sudo apt -y purge "*nvidia*" + +wget https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/cuda-keyring_1.1-1_all.deb +sudo dpkg -i cuda-keyring_1.1-1_all.deb +sudo apt-get -y -f install +sudo apt -y update + +sudo bash -c 'echo "deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/ /" \ + | tee /etc/apt/sources.list.d/cuda-debian12-x86_64.list' + +sudo apt -y update + +sudo apt -y install cuda-drivers + +sudo apt -y install curl +sudo curl -fsSL https://ollama.com/install.sh | sh + +sudo systemctl stop ollama && sudo systemctl disable ollama + +# Installing incus + +echo "Installing Incus" + +sudo apt -y install qemu-system-x86/bookworm-backports qemu-system-common/bookworm-backports qemu-system-data/bookworm-backports seabios/bookworm-backports + +sudo apt -y install incus + +sudo usermod -a -G incus,incus-admin $USER +