h8rt3rmin8r

install-cuda.sh

Oct 27th, 2020
236
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /usr/bin/env bash
  2. #
  3. # [ install-cuda ]
  4. #
  5. #    Install CUDA 11 on Ubuntu 20
  6. #    Modified from source on 20201027 by h8rt3rmin8r
  7. #    Source: https://bit.ly/31LNafq
  8. #
  9.  
  10. sudo apt update
  11. sudo add-apt-repository ppa:graphics-drivers
  12. sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
  13. sudo bash -c 'echo "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/cuda.list'
  14. sudo bash -c 'echo "deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/cuda_learn.list'
  15.  
  16. sudo apt update
  17. #sudo apt install cuda-10-1
  18. sudo apt install cuda-11-1
  19. #sudo apt install libcudnn7
  20. sudo apt install libcudnn8
  21.  
  22. #
  23. # Set PATH for cuda 11.1 installation in ~/.bashrc
  24. # Modified from source: https://bit.ly/31LNafq
  25. #
  26.  
  27. b_rc="/home/$(whoami)/.bashrc"
  28.  
  29. echo "" >> "${b_rc}"
  30. echo "# Set PATH for CUDA 11.1 (added on $(date '+%Y-%m-%d') by $(whoami))" >> "${b_rc}"
  31. echo "# Modified from source by h8rt3rmin8r: https://bit.ly/31LNafq" >> "${b_rc}"
  32. echo 'if [ -d "/usr/local/cuda-11.1/bin/" ]; then export PATH=/usr/local/cuda-11.1/bin${PATH:+:${PATH}}; export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}; fi' >> "${b_rc}"
  33.  
  34.  
RAW Paste Data