Try   HackMD

Gosar's Ubuntu Installation Procedure

Contents

Before installing Ubuntu

Download Ubuntu

Make a bootable USB

  • For windows,
    • Download Rufus
    • Use Rufus to burn
  • For Linux,

Installing Ubuntu

Follow Tutorial

After installing Ubuntu

Installing CUDA 10

Steps

Cuda

  • Use deb (network) to Download.
  • Or run thefollowing commands,
    ​​​​wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin ​​​​sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600 ​​​​sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub ​​​​sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /" ​​​​sudo apt-get update ​​​​sudo apt-get -y install cuda
    • Reboot and then check nvidia-smi
Setting Cuda path on .bashrc
  • Open .bashrc

    ​​​​nano ~/.bashrc
    
  • Add these lines to .bashrc file

    ​​​​export CUDAHOME=/usr/local/cuda-11.1
    ​​​​export PATH=${CUDAHOME}/bin:${CUDAHOME}/NsightCompute-2019.3${PATH:+:${PATH}}
    ​​​​export LD_LIBRARY_PATH=${CUDAHOME}/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
    
    
  • Change 11.1 to the latest version

    ​​​​sudo sh ~/.bashrc
    
Installing CuDNN

CuDNN

  • Reference Document
  • Download cudNN
    • cuDNN Runtime Library for Ubuntu18.04 (Deb)
    • cuDNN Developer Library for Ubuntu18.04 (Deb)
    • cuDNN Code Samples and User Guide for Ubuntu18.04 (Deb)
  • Installing from a Debian File
    • Navigate to your <cudnnpath> directory containing cuDNN Debian file.
    • Install the runtime library, for example:
      sudo dpkg -i libcudnn8_8.0.4.30-1+cuda11.1_amd64.deb
    • Install the developer library, for example:
      sudo dpkg -i libcudnn8-dev_8.0.4.30-1+cuda11.1_amd64.deb
    • Install the code samples and the cuDNN Library User Guide, for example:
      sudo dpkg -i libcudnn8-samples_8.0.4.30-1+cuda11.1_amd64.deb
  • Verifying The cuDNN Install On Linux
    • To verify that cuDNN is installed and is running properly, compile the mnistCUDNN sample located in the /usr/src/cudnn_samples_v8 directory in the debian file.
      ​​​​​​​​cp -r /usr/src/cudnn_samples_v8/ $HOME
      ​​​​​​​​cd  $HOME/cudnn_samples_v8/mnistCUDNN
      ​​​​​​​​make clean && make
      ​​​​​​​​./mnistCUDNN
      
    • If cuDNN is properly installed and running on your Linux system, you will see a message similar to the following: Test passed!
    • Run sudo apt install nvidia-cuda-toolkit -y
    • Check nvcc --version

Setup

Install Pyenv Procedure

sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git

git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bashrc
exec "$SHELL"
pyenv install 3.7.3
pyenv global 3.7.3
python --version

Virtual Environment Setup

Install virtualenv

pip install virtualenv

Create a new virtual environment

In this example, the name of virtual environment is set as "venv" using the below command, you can use any other name.

virtualenv venv

Activate your virtual environment

source venv/bin/activate

Install packages as usual

pip install <dependencies go here>

Export your dependencies

pip freeze > requirements.txt

Import your dependencies

pip install -r requirements.txt

Check Cuda using torch

pip install torch torchvision
import torch torch.cuda.is_available() print(torch.cuda.get_device_name(0)) print('Allocated:', round(torch.cuda.memory_allocated(0)/1024**3,1), 'GB') print('Cached: ', round(torch.cuda.memory_cached(0)/1024**3,1), 'GB')

Pip install (My usual packages)

pip install torch torchvision Cython opencv-python

Important Sofwares

Creating Simulation environment - Unreal Engine and NDDS

Chrome

Teamviewer

typora

Slack

sudo snap install slack --classic

VLC

sudo snap install vlc

Pycharm

sudo snap install pycharm-community --classic

SimpleNote

sudo snap install simplenote

Blender

sudo snap install blender --classic

Pinta

sudo snap install pinta-james-carroll

VS Code

sudo snap install code --classic

  • Increase (max_user_watches) limit for VS Code

    (ref)

    • Check current limit
      cat /proc/sys/fs/inotify/max_user_watches
    • Edit
      sudo nano /etc/sysctl.conf
      In the end, add this line
      ​​​​​​​​fs.inotify.max_user_watches=524288
    • Save changes
      sudo sysctl -p
  • FiraCode

Better Ubuntu

Minimize on Click

Enable ‘Minimize on Click’ for the Ubuntu Dock
gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize'

gnome-tweaks

sudo apt-get install gnome-tweaks

Terminator

  • Add Terminator Repository:
sudo add-apt-repository ppa:gnome-terminator

Open Software & Updates, Other Software tab.
find the PPA definition that contains "gnome-terminator"
select it and click Edit
For ubuntu 18.xx: change the Distribution field from bionic to xenial
For ubuntu 20.xx: change the Distribution field from bionic to focal

  • Update sources.list
sudo apt-get update
  • Install Terminator
sudo apt-get install terminator

Keyboard Language

(ref)

  1. Run the following command in the terminal and then reboot
sudo apt install -y ibus-mozc
  1. Open Region & Language
  2. Click on Manage Installed Languages
  3. Click on Install
  4. Close
  5. Click on + sign
  6. Click on Japanese
  7. Click on Japanese (Mozc) then add


  8. Customise key bindings

Detectron2

pytorch

pip install opencv-python
pip install torch==1.7.1 torchvision==0.8.2
pip install detectron2-0.5

Bash

How to update bash commands
  • Open .bashrc

    ​​​​nano ~/.bashrc
    
  • Add this lines to .bashrc file

    ​​​​export dataset=/home/jitesh/detectron_tutorial/dataset
    ​​​​export dl=/home/jitesh/Downloads
    
  • Update bashrc

    ​​​​sudo sh ~/.bashrc
    

bashrc

bash_aliases


Not Important

Installing drivers

Method 0 (uninstall)

yes| sudo apt-get purge nvidia*
sudo apt-get autoremove

or

sudo apt-get remove --purge '^nvidia-.*'
sudo apt-get install ubuntu-desktop

purge nvidia

Method 1

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
ubuntu-drivers devices

Using the above command, check the recommended Nvidia-driver (in my case, it was nvidia-driver-440)
Open softare & updates program from you application menu. Click the additional drivers tab.
Select nvidia-driver that you want to install.


Then click on Apply Changes and then close.
Install from the popup window.
If you couldn't install from the popup window, then run the command, sudo apt install nvidia-440

If a window asking for bios password popsup, then create an 8 character password and use it after reboot when a blue screen comes. Choose the second option on the blue screen and enable the key. (I don' remeber exactly that what options are there.)

Method 2 (without GUI)

Method 3

  • Download Nvidia Driver
  • To install all dependencies
    ​​​​sudo apt-get install build-essential gcc-multilib dkms
    
  • Creat Blacklist for Nouveau Driver
    Create a file at /etc/modprobe.d/blacklist-nouveau.conf with the following contents:
    ​​​​blacklist nouveau
    ​​​​options nouveau modeset=0
    
    • for Ubuntu 14.04 LTS, reboot the computer;
    • for Ubuntu 16.04 LTS, excute sudo update-initramfs -u and reboot the computer
  • For Ubuntu / Fedora / CentOS, after computer restarts, excute
    ​​​​sudo systemctl stop lightdm
    
    (or use gdm or kdm instead of lightdm)
    ​​​​cd ~/Downloads
    ​​​​chmod +x NVIDIA-Linux-x86_64-440.64.run
    ​​​​sudo ./NVIDIA-Linux-x86_64-440.64.run --dkms -s
    
  • Check the installation by command, nvidia-smi
Links

xserver

It's apparently a better solution to run X11 as root. The one-line fix is to add this line to /etc/X11/Xwrapper.config:

needs_root_rights = yes

You can install xserver-xorg-core appropriate for your system by just typing

sudo apt-get install xserver-xorg-legacy
sudo apt-get install xserver-xorg-core

If you are still having the problem please add the output of :

apt-cache madison xserver-common

grub2

sudo gedit /etc/default/grub

Add nouveau.modeset=0 to the end of the linux line - press F10 to boot.

sudo update-grub2

Clayton's Ubuntu Installation Procedure