#!/bin/bash
# Remove old versions of CUDA and NVIDIA tools
sudo apt-get --purge remove -y "cublas*" "cuda*" "nvidia*"
sudo rm -rf /usr/local/cuda*
sudo apt-get autoremove -y && sudo apt-get autoclean -y
# Install necessary utilities and libraries
sudo apt-get update
sudo apt-get install -y g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev
# Install new CUDA, version 12.0 (amd, Ubuntu 22.04)
sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo dpkg -i cuda-repo-ubuntu2204-12-0-local_12.0.0-525.60.13-1_amd64.deb
sudo cp /var/cuda-repo-ubuntu2204-12-0-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get install -y cuda-12.0
# Update environment variables
echo 'export PATH=/usr/local/cuda-12.0/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-12.0/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
# Install Miniconda
bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda
# Initialize Conda for the shell
$HOME/miniconda/bin/conda init
echo 'export PATH="$HOME/miniconda/bin:$PATH"' >> ~/.bashrc
# Activate conda environment
source $HOME/miniconda/bin/activate
# Install conda environment and tools
conda create -y -n pyDEME python=3.11
conda activate pyDEME
conda install -y cmake
pip3 install DEME
# OPTIONAL: few tools I use
conda config --add channels conda-forge
conda install -y seaborn matplotlib numpy scipy trimesh paraview shapely gmsh PyArrow
pip install gmsh
echo "Installation completed. Please reboot your system to apply all changes and for the CUDA installation to be fully operational."