Added install_nvidia

This commit is contained in:
Antonio de la Rosa 2025-04-01 21:34:17 +02:00
parent ade19f0049
commit 765406ad79
2 changed files with 78 additions and 75 deletions

View file

@ -1,78 +1,8 @@
#!/bin/bash #!/bin/bash
# Script for create a simple ai system with LXC and Incus. newgrp incus-admin
## Install updated repos for debian 12 sg incus-admin -c "incus admin init"
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 <<EOF > /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
# Install ollama container # Install ollama container
@ -86,7 +16,7 @@ incus config device add ollama-container gpu gpu
# Install nvidia # 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 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 incus exec ollama-container -- ollama run gemma3:4b
echo "Done!!!" echo "Done!!!"
sleep 3 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" echo "Use journalctl -u ollama.service command for check if ollama is working"

74
install_nvidia.sh Normal file
View file

@ -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 <<EOF > /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