about summary refs log tree commit diff
path: root/vagrant/Vagrantfile.gpu
diff options
context:
space:
mode:
authormakefunstuff <[email protected]>2024-06-30 17:58:04 +0200
committermakefunstuff <[email protected]>2024-06-30 17:58:04 +0200
commit78a3a7b751b5042b775dfbf3376362ce9729e5bb (patch)
tree802515693d3039df5f3f84729b3ec4ee61eea3af /vagrant/Vagrantfile.gpu
parentcbfab9c28fb56ba9c13a574b0e69c8adba5e61c8 (diff)
downloadk3s-lab-78a3a7b751b5042b775dfbf3376362ce9729e5bb.tar.gz
more todos
Diffstat (limited to 'vagrant/Vagrantfile.gpu')
-rw-r--r--vagrant/Vagrantfile.gpu59
1 files changed, 59 insertions, 0 deletions
diff --git a/vagrant/Vagrantfile.gpu b/vagrant/Vagrantfile.gpu
new file mode 100644
index 0000000..70c4e55
--- /dev/null
+++ b/vagrant/Vagrantfile.gpu
@@ -0,0 +1,59 @@
+Vagrant.configure("2") do |config|
+  config.vm.box = "ubuntu/bionic64" # Or any other preferred Linux distribution
+  
+  # Configure VM hardware
+  config.vm.provider "virtualbox" do |vb|
+    vb.memory = "32768"
+    vb.cpus = 4
+    vb.customize ["modifyvm", :id, "--ioapic", "on"]
+    vb.customize ["modifyvm", :id, "--vram", "10240"] # Set VRAM to 10GB
+    vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
+    vb.customize ["modifyvm", :id, "--accelerate3d", "on"]
+  end
+
+  # Provisioning script
+  config.vm.provision "shell", inline: <<-SHELL
+    # Update and install prerequisites
+    sudo apt-get update
+    sudo apt-get install -y curl gnupg build-essential
+
+    # Add NVIDIA package repositories
+    distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
+    sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/$distribution/x86_64/7fa2af80.pub
+    echo "deb https://developer.download.nvidia.com/compute/cuda/repos/$distribution/x86_64 /" | sudo tee /etc/apt/sources.list.d/cuda.list
+    echo "deb https://developer.download.nvidia.com/compute/machine-learning/repos/$distribution/x86_64 /" | sudo tee /etc/apt/sources.list.d/nvidia-ml.list
+
+    # Install NVIDIA drivers and CUDA toolkit
+    sudo apt-get update
+    sudo apt-get install -y cuda
+
+    # Add CUDA to the PATH
+    echo 'export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}' >> ~/.bashrc
+    echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}' >> ~/.bashrc
+    source ~/.bashrc
+
+    # Install Tailscale
+    curl -fsSL https://tailscale.com/install.sh | sh
+
+    # Install K3s
+    curl -sfL https://get.k3s.io | sh -
+
+    # Add your SSH public key (replace with your actual public key)
+    mkdir -p ~/.ssh
+    echo "" >> ~/.ssh/authorized_keys
+    chmod 600 ~/.ssh/authorized_keys
+
+    # Restart SSH service
+    sudo service ssh restart
+
+    # Install NVIDIA container toolkit
+    curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
+    distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
+    curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
+    sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
+
+    # Restart Docker to load the NVIDIA runtime
+    sudo systemctl restart docker
+  SHELL
+end
+