# For Nvidia Driver Installation Guides ###### tags: `Installation` ## Env. Ubuntu 20.04 or 18.04 GPU Nvidia Tesla c2070 ## Install Nvidia driver In Ubuntu systems, drivers for NVIDIA Graphics Cards are already provided in the official repository. But since we are using the Tesla module graphics cards, we should dowload the driver from [Nvidia driver](https://www.nvidia.com/download/index.aspx?lang=en-us). The latest supported driver version is ``390`` with cuda version ``9.1``. ### Install Dependencies Software required for the runfile are officially listed [here](http://us.download.nvidia.com/XFree86/Linux-x86_64/384.69/README/minimumrequirements.html). For Ubuntu we need: 1. **build-essential:** Include gcc, g++, cmake... and the other building tools. 2. **dkms:** For providing dkms support. :::info Since we don't need x-windows system, so we are not gonna install **xorg**. ::: ```bash $ sudo apt install build-essential dkms ``` ### Black Nouveau Driver Nouveau is the open-soure Nvidia driver. In usual it is the default kernel module loaded in your system. So edit the file at ``/etc/modprobe.d/blacklist.conf`` add the following contents: ``` blacklist nouveau options nouveau modeset=0 ``` then excute sudo ``update-initramfs -u`` and reboot the system. #### Verify Configuration To check if your changes were successful, you can use ``lspci -nnk`` and make sure the that the ``Kernel module in use:`` is not nouveau. ### Excuting the Runfile ```bash $ wget http://us.download.nvidia.com/tesla/390.116/NVIDIA-Linux-x86_64-390.116.run $ chmod +x NVIDIA-Linux-x86_64-390.116.run $ sudo ./NVIDIA-Linux-x86_64-390.116.run ``` With the following steps to finish installation. And reboot to apply change. ### Verify installation Using nvidia-smi ```bash kerwin@kerwin:~/cuda-driver$ nvidia-smi Wed Aug 5 19:15:17 2020 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 390.116 Driver Version: 390.116 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 Tesla C2070 Off | 00000000:01:00.0 Off | Off | | 30% 49C P12 N/A / N/A | 0MiB / 6067MiB | 0% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | No running processes found | +-----------------------------------------------------------------------------+ ``` ## Install CUDA :::warning 注意:CUDA 版本必須對應上Nvidia driver 的版本,像是這張卡最多就是上到390那對應的 cuda 版本就是9.1 ::: We can dowload the Linux version [here](https://developer.nvidia.com/cuda-91-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=runfilelocal) ```bash $ sudo apt install gcc-6 g++-6 ``` Dowload the four runfiles: ```bash $ wget https://developer.nvidia.com/compute/cuda/9.1/Prod/local_installers/cuda_9.1.85_387.26_linux $ wget https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/1/cuda_9.1.85.1_linux $ wget https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/2/cuda_9.1.85.2_linux $ wget https://developer.nvidia.com/compute/cuda/9.1/Prod/patches/3/cuda_9.1.85.3_linux ``` And excute these files in order :::warning 當問你要不要安裝nvidia driver 的時候選擇 no ,因為我們已經裝過了。 ::: ```bash sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 10 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 20 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 10 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 20 sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30 sudo update-alternatives --set cc /usr/bin/gcc sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30 sudo update-alternatives --set c++ /usr/bin/g++ ``` Add the following contain to ~/.bashrc ```bash PATH="/usr/local/cuda-9.1/bin:$HOME/bin:$HOME/.local/bin:$PATH" LD_LIBRARY_PATH=/usr/local/cuda-9.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} ```