Difference between revisions of "Install Nvidia graphics card driver on Ubuntu along with cuda libraries"

From Notes_Wiki
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Main Page|Home]] > [[Ubuntu]] > [[Install Nvidia P100 graphics card driver on Ubuntu 16.04]]
[[Main Page|Home]] > [[Ubuntu]] > [[Ubuntu Server or Desktop administration|Server or Desktop administration]]  > [[Install Nvidia graphics card driver on Ubuntu along with cuda libraries]]


# Download drivers from nvidia site ( http://www.nvidia.com/download/driverResults.aspx/118962/en-us )  Example driver download link http://us.download.nvidia.com/tesla/375.66/nvidia-diag-driver-local-repo-ubuntu1604_375.66-1_amd64.deb
# First determine the version of Ubuntu using:
# dpkg -i <driver>.deb
#:<pre>
# apt-get update
#:: cat /etc/*release
# apt-get upgrade
#:</pre>
# apt-get install cuda-drivers
# Then determine the Nvidia card installed on machine using one of the below methods:
## Using lspci
##:<pre>
##:: sudo  lspci | grep -i --color 'vga\|3d\|2d'
##:</pre>
## To to System > Preferences > Hardware information and check card information
## Install and use hardinfo to get information about card
##:<pre>
##:: sudo apt-get install hardinfo
##:: hardinfo
##:</pre>
#: Refer https://www.cyberciti.biz/faq/linux-tell-which-graphics-vga-card-installed/
# Download drivers from nvidia site ( http://www.nvidia.com/download/driverResults.aspx/118962/en-us )   
#: Example driver download link http://us.download.nvidia.com/tesla/375.66/nvidia-diag-driver-local-repo-ubuntu1604_375.66-1_amd64.deb
# Install the downloaded driver, update and upgrade OS, Install cuda drivers using:
#:<pre>
#:: dpkg -i <driver>.deb
#:: apt-get update
#:: apt-get upgrade
#:: apt-get install cuda-drivers
#:</pre>
# In some cases before installing cuda drivers we may have to setup cuda-keyring using:
## Install required kernel headers:
##:<pre>
##:: sudo apt-get install linux-headers-$(uname -r)
##:</pre>
## Download required keyring deb file and install using:
##:<pre>
##:: distribution=$(. /etc/os-release;echo $ID$VERSION_ID | sed -e 's/\.//g')
##:: wget https://developer.download.nvidia.com/compute/cuda/repos/$distribution/x86_64/cuda-keyring_1.0-1_all.deb
##:: sudo dpkg -i cuda-keyring_1.0-1_all.deb
##:</pre>
#: Refer https://docs.nvidia.com/datacenter/tesla/tesla-installation-notes/index.html.
# Reboot the machine and test
# After reboot if screen is blank edit /etc/default/grub and append nomodeset option to GRUB_CMDLINE_LINUX_DEFAULT.  Do not remove existing options append with space bar.
# After reboot if screen is blank edit /etc/default/grub and append nomodeset option to GRUB_CMDLINE_LINUX_DEFAULT.  Do not remove existing options append with space bar.
#:<pre>
#:<pre>
#::      GRUB_CMDLINE_LINUX_DEFAULT="nomodeset"
#::      GRUB_CMDLINE_LINUX_DEFAULT="nomodeset"
#:</pre>
#:</pre>
# Run "nvidia-smi" and verify that output contains information about installed graphics card.
# Run below and verify that output contains information about installed graphics card.
 
#:<pre>
 
#:: /usr/local/cuda/bin/nvcc --version
 
#:: nvidia-smi
Refer:
#:</pre>
* https://www.quantstart.com/articles/installing-tensorflow-on-ubuntu-1604-with-an-nvidia-gpu
#: Refer https://stackoverflow.com/questions/9727688/how-to-get-the-cuda-version
 
# If setup is not working then as per https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html there is combination of OS, GCC, nvidia drivers, etc. that is tested for particular OS.  We can validate those via
 
#:<pre>
 
#:: uname -a
#:: gcc --version
#:: ldd --version
#:: nvidia-smi
#:: /usr/local/cuda/bin/nvcc --version
#:</pre>
# If required perform following additional steps
#:<pre>
#:: sudo apt-get install nvidia-gds
#:: sudo apt-get install cuda-drivers-515
#:: conda install cuda -c nvidia
#:: cat /proc/driver/nvidia/version
#:</pre>
# Execute below in current shell to set PATH and LD_LIBRARY_PATH properly for current shell
#:<pre>
#:: export PATH=/usr/local/cuda-11.7/bin${PATH:+:${PATH}}
#:: export LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
#:</pre>
#: Ideally we should use "module load", "module available" etc. to set appropriate environment for required cuda version based on the programs being compiled / executed.
# Edit /etc/ld.so.conf and append a new line:
#:<pre>
#:: /usr/local/cuda-11.7/lib64
#:</pre>
# Update ldconfig using
#:<pre>
#:: sudo ldconfig
#:</pre>
# We can further test the installation with cuda samples from https://github.com/nvidia/cuda-samples. For that use
#:<pre>
#:: sudo apt-get -y install git
#:: git clone https://github.com/NVIDIA/cuda-samples.git
#:: cd cuda-samples
#:: make
#:</pre>
#: All tests and compilations succeed except for 0_Introduction/simpleMPI perhaps due to missing MPI libaries.  We did '<tt>rm -rf 0_Introduction/simpleMPI</tt>' to delete that sample and compile all others using make
# Especially, we ran Samples/1_Utilities/deviceQuery from below path
#:<pre>
#:: ./bin/x86_64/linux/release/deviceQuery
#:</pre>
# Note after this we tried to run python based code from https://www.geeksforgeeks.org/running-python-script-on-gpu/  It did not work.  Perhaps we have not installed python-cuda libraries to make the code work




[[Main Page|Home]] > [[Ubuntu]] > [[Install Nvidia P100 graphics card driver on Ubuntu 16.04]]
[[Main Page|Home]] > [[Ubuntu]] > [[Ubuntu Server or Desktop administration|Server or Desktop administration]]  > [[Install Nvidia graphics card driver on Ubuntu along with cuda libraries]]

Latest revision as of 06:13, 24 February 2023

Home > Ubuntu > Server or Desktop administration > Install Nvidia graphics card driver on Ubuntu along with cuda libraries

  1. First determine the version of Ubuntu using:
    cat /etc/*release
  2. Then determine the Nvidia card installed on machine using one of the below methods:
    1. Using lspci
      sudo lspci | grep -i --color 'vga\|3d\|2d'
    2. To to System > Preferences > Hardware information and check card information
    3. Install and use hardinfo to get information about card
      sudo apt-get install hardinfo
      hardinfo
    Refer https://www.cyberciti.biz/faq/linux-tell-which-graphics-vga-card-installed/
  3. Download drivers from nvidia site ( http://www.nvidia.com/download/driverResults.aspx/118962/en-us )
    Example driver download link http://us.download.nvidia.com/tesla/375.66/nvidia-diag-driver-local-repo-ubuntu1604_375.66-1_amd64.deb
  4. Install the downloaded driver, update and upgrade OS, Install cuda drivers using:
    dpkg -i <driver>.deb
    apt-get update
    apt-get upgrade
    apt-get install cuda-drivers
  5. In some cases before installing cuda drivers we may have to setup cuda-keyring using:
    1. Install required kernel headers:
      sudo apt-get install linux-headers-$(uname -r)
    2. Download required keyring deb file and install using:
      distribution=$(. /etc/os-release;echo $ID$VERSION_ID | sed -e 's/\.//g')
      wget https://developer.download.nvidia.com/compute/cuda/repos/$distribution/x86_64/cuda-keyring_1.0-1_all.deb
      sudo dpkg -i cuda-keyring_1.0-1_all.deb
    Refer https://docs.nvidia.com/datacenter/tesla/tesla-installation-notes/index.html.
  6. Reboot the machine and test
  7. After reboot if screen is blank edit /etc/default/grub and append nomodeset option to GRUB_CMDLINE_LINUX_DEFAULT. Do not remove existing options append with space bar.
    GRUB_CMDLINE_LINUX_DEFAULT="nomodeset"
  8. Run below and verify that output contains information about installed graphics card.
    /usr/local/cuda/bin/nvcc --version
    nvidia-smi
    Refer https://stackoverflow.com/questions/9727688/how-to-get-the-cuda-version
  9. If setup is not working then as per https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html there is combination of OS, GCC, nvidia drivers, etc. that is tested for particular OS. We can validate those via
    uname -a
    gcc --version
    ldd --version
    nvidia-smi
    /usr/local/cuda/bin/nvcc --version
  10. If required perform following additional steps
    sudo apt-get install nvidia-gds
    sudo apt-get install cuda-drivers-515
    conda install cuda -c nvidia
    cat /proc/driver/nvidia/version
  11. Execute below in current shell to set PATH and LD_LIBRARY_PATH properly for current shell
    export PATH=/usr/local/cuda-11.7/bin${PATH:+:${PATH}}
    export LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
    Ideally we should use "module load", "module available" etc. to set appropriate environment for required cuda version based on the programs being compiled / executed.
  12. Edit /etc/ld.so.conf and append a new line:
    /usr/local/cuda-11.7/lib64
  13. Update ldconfig using
    sudo ldconfig
  14. We can further test the installation with cuda samples from https://github.com/nvidia/cuda-samples. For that use
    sudo apt-get -y install git
    git clone https://github.com/NVIDIA/cuda-samples.git
    cd cuda-samples
    make
    All tests and compilations succeed except for 0_Introduction/simpleMPI perhaps due to missing MPI libaries. We did 'rm -rf 0_Introduction/simpleMPI' to delete that sample and compile all others using make
  15. Especially, we ran Samples/1_Utilities/deviceQuery from below path
    ./bin/x86_64/linux/release/deviceQuery
  16. Note after this we tried to run python based code from https://www.geeksforgeeks.org/running-python-script-on-gpu/ It did not work. Perhaps we have not installed python-cuda libraries to make the code work


Home > Ubuntu > Server or Desktop administration > Install Nvidia graphics card driver on Ubuntu along with cuda libraries