#!/bin/bash
printf  "================ Launch Cuda installation ==========================\n"
printf  " +++ installing cuda pre-requisites\n"
printf ""
sudo dnf install -y pciutils
sudo dnf install -y net-tools
sudo dnf install -y kernel-devel-$(uname -r) kernel-headers-$(uname -r)
sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf install -y epel-release
sudo dnf install -y systemd
sudo rpm --erase gpg-pubkey-7fa2af80*

sudo dnf -q update -y
#sudo dnf -q install -y kernel-headers-$(uname -r) gcc

sudo dnf -q install -y gcc

distro='rhel8'
arch='x86_64'

printf "\n +++ config-manager\n"
sudo dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/$distro/$arch/cuda-$distro.repo

printf "\n +++ driver install\n"
sudo dnf clean expire-cache 

#sudo dnf install -y nvidia-driver nvidia-settings cuda-driver
sudo dnf install -y nvidia-driver
sudo dnf install -y nvidia-settings
sudo dnf install -y cuda-toolkit 
sudo dnf install -y nvidia-driver-cuda
#gds not needed for base install
#sudo dnf install -y nvidia-gds

printf "\n========== end cuda install ===========\n"
