Last active
April 2, 2023 14:16
-
-
Save 3dsf/b3ed0cef08ff31b5c93bd1ccdec8180d to your computer and use it in GitHub Desktop.
F36 install nvidia-driver/cuda with nvcc and matching gcc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Install Nvidia drivers with nvcc and build GCC 11 for nvcc | |
# Uses nvidia fedora repo 35 as the fedora 36 does not have a compatible gcc | |
# This should not hinder the install, until nvidia fedora repo is no longer supported EOL F35? | |
# This script is written for fresh installs | |
work_dir=/tmp/gcc/build | |
install_dir=/opt/gcc-11 | |
sudo dnf update -y | |
sudo dnf install gmp-devel mpfr-devel libmpc-devel make kernel-headers kernel-devel-matched wget -y | |
sudo dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/fedora35/x86_64/cuda-fedora35.repo | |
sudo dnf clean expire-cache && sudo dnf module install nvidia-driver:latest-dkms -y | |
sudo dnf install cuda -y | |
# Download GCC from git source and select branch | |
cd /tmp | |
git clone --branch releases/gcc-11 git://gcc.gnu.org/git/gcc.git gcc | |
# Build host GCC | |
mkdir -p $work_dir | |
cd $work_dir | |
/tmp/gcc/configure \ | |
--enable-shared \ | |
--enable-threads=posix \ | |
--enable-__cxa_atexit \ | |
--disable-multilib \ | |
--enable-languages="c,c++" \ | |
--enable-clocale=gnu \ | |
--with-system-zlib \ | |
--prefix=$install_dir | |
make -j`nproc` || exit 1 | |
sudo make install || exit 1 | |
#Allows nvcc to find g++ and gcc by adding symbolic links to /usr/local/cuda/bin | |
sudo ln -s /opt/gcc-11/bin/g++ /usr/local/cuda/bin/g++ | |
sudo ln -s /opt/gcc-11/bin/gcc /usr/local/cuda/bin/gcc | |
#Adds cuda bin to PATH and set LD_LIBRARY_PATH | |
echo 'PATH=$PATH:/usr/local/cuda/bin' | sudo tee -a /etc/profile.d/cuda.PATH.sh | |
echo 'LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' | sudo tee -a /etc/profile.d/cuda.LD_LIBRARY_PATH.sh | |
#This adds 'nvidia-drm.modeset=1' to the default file | |
sudo grubby --update-kernel=ALL --args='nvidia-drm.modeset=1' | |
sudo grub2-mkconfig -o /boot/grub2/grub.cfg | |
#Disable capability checks that may disable wayland | |
#In my case, not being able to properly suspend/sleep was blocking wayland | |
sudo ln -s /dev/null /etc/udev/rules.d/61-gdm.rules |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment