Gosar's Ubuntu Installation Procedure ===================================== Contents -------- [ToC] Before installing Ubuntu ========================= Download Ubuntu ------------------- * [Ubuntu 18.04.5 LTS (Bionic Beaver)](https://releases.ubuntu.com/18.04/) * [Latest Ubuntu](https://ubuntu.com/download/desktop) Make a bootable USB ------------------- - For windows, - Download [Rufus](https://rufus.ie/) - Use Rufus to burn - For Linux, - Follow this [Tutorial](https://ubuntu.com/tutorials/tutorial-create-a-usb-stick-on-ubuntu#1-overview) [Installing Ubuntu](https://ubuntu.com/tutorials/tutorial-install-ubuntu-desktop#1-overview) ========================= ## Follow [Tutorial](https://ubuntu.com/tutorials/tutorial-install-ubuntu-desktop#1-overview) [After installing Ubuntu](/3T-rcXg6Rny0cJAuPnJi6g) ========================= :::spoiler Installing CUDA 10 [Steps](https://medium.com/@stephengregory_69986/installing-cuda-10-1-on-ubuntu-20-04-e562a5e724a0) Cuda ---- - Use `deb (network)` to [Download](https://developer.nvidia.com/cuda-downloads). - Or run thefollowing commands, ```console= 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` <details> <summary>Setting Cuda path on .bashrc</summary> - Open .bashrc ```console nano ~/.bashrc ``` - Add these lines to .bashrc file ```console 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 ```console sudo sh ~/.bashrc ``` </details> ::: :::spoiler Installing CuDNN CuDNN ------ - Reference [Document](https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html) - Download [cudNN](https://developer.nvidia.com/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. ```console 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` </details> Setup ----- ### Install Pyenv Procedure ```console 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 ``` ```console 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 <!-- :::spoiler --> #### Install virtualenv ```console 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. ```console virtualenv venv ``` #### Activate your virtual environment ```console source venv/bin/activate ``` :::spoiler #### Install packages as usual ```console pip install <dependencies go here> ``` #### Export your dependencies ```console pip freeze > requirements.txt ``` #### Import your dependencies ```console pip install -r requirements.txt ``` ::: ### Check Cuda using torch ```console pip install torch torchvision ``` ```python$= 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) ```console pip install torch torchvision Cython opencv-python ``` Important Sofwares ------------------ ### [Creating Simulation environment](@jitesh/3d) - Unreal Engine and NDDS ### [Chrome](https://www.google.com/chrome/) ### [Teamviewer](https://www.teamviewer.com/en/download/linux/) ### [typora](https://typora.io/#linux) ### [Slack](https://slack.com/intl/ja-jp/downloads/linux) `sudo snap install slack --classic` ### VLC `sudo snap install vlc` ### [Pycharm](https://www.jetbrains.com/pycharm/download/#section=linux) `sudo snap install pycharm-community --classic` ### [SimpleNote](https://github.com/Automattic/simplenote-electron/releases/tag/v1.15.1) `sudo snap install simplenote` ### [Blender](https://www.blender.org/download/) `sudo snap install blender --classic` ### [Pinta](https://www.pinta-project.com/) `sudo snap install pinta-james-carroll` ### [VS Code](https://code.visualstudio.com/download) `sudo snap install code --classic` - Increase (max_user_watches) limit for VS Code :::spoiler [(ref)](https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc) - Check current limit `cat /proc/sys/fs/inotify/max_user_watches` - Edit `sudo nano /etc/sysctl.conf` In the end, add this line ```sh= fs.inotify.max_user_watches=524288 ``` - Save changes `sudo sysctl -p` ::: - [FiraCode](https://github.com/tonsky/FiraCode/wiki/VS-Code-Instructions) 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 :::spoiler - Add Terminator Repository: ```console 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 ```console sudo apt-get update ``` - Install Terminator ```console sudo apt-get install terminator ``` ::: ### Keyboard Language [(ref)](https://help.ubuntu.com/community/JapaneseInput) 1. Run the following command in the terminal and then **reboot** ``` sudo apt install -y ibus-mozc ``` 2. Open Region & Language ![](https://i.imgur.com/HvO3MBv.png) 3. Click on Manage Installed Languages ![](https://i.imgur.com/ClYOA7e.png) 4. Click on Install ![](https://i.imgur.com/sEvUEjL.png) 5. Close ![](https://i.imgur.com/2Ack16t.png) 6. Click on + sign ![](https://i.imgur.com/HvO3MBv.png) 7. Click on Japanese ![](https://i.imgur.com/4xoZayw.png) 8. Click on Japanese (Mozc) then add ![](https://i.imgur.com/DmOUBS5.png) ![](https://i.imgur.com/2ABoHhx.png)\ ![](https://i.imgur.com/YBAdK4U.png) 9. [Customise key bindings](https://askubuntu.com/questions/561486/how-do-i-switch-input-modes-in-mozc-without-going-to-the-ibus-menu) ### Detectron2 [pytorch](https://pytorch.org/get-started/locally/) ``` pip install opencv-python pip install torch==1.7.1 torchvision==0.8.2 pip install detectron2-0.5 ``` *** Bash ---- <details> <summary>How to update bash commands</summary> - Open .bashrc ```console nano ~/.bashrc ``` - Add this lines to .bashrc file ```console export dataset=/home/jitesh/detectron_tutorial/dataset export dl=/home/jitesh/Downloads ``` - Update bashrc ```console sudo sh ~/.bashrc ``` </details> ### [bashrc](/TRh_PAp_Qt2cadomJKqSFA) ### [bash_aliases](/rLZ7nua0T5yETALUIcXDqQ) ------------- ## Not Important ### Installing drivers #### Method 0 (uninstall) :::spoiler ```console yes| sudo apt-get purge nvidia* sudo apt-get autoremove ``` or ```console sudo apt-get remove --purge '^nvidia-.*' sudo apt-get install ubuntu-desktop ``` [purge nvidia](https://askubuntu.com/questions/206283/how-can-i-uninstall-a-nvidia-driver-completely) ::: #### Method 1 :::spoiler ```console 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. ![](https://i.imgur.com/LqrlWrU.png) 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` ![](https://i.imgur.com/h1cu5tl.png) 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) :::spoiler - [Video Tutorial](https://www.youtube.com/watch?v=GljujCLixzE) - [Document](https://gist.github.com/wangruohui/df039f0dc434d6486f5d4d098aa52d07#install-nvidia-graphics-driver-via-runfile) ::: #### Method 3 :::spoiler - Download [Nvidia Driver](https://www.nvidia.com/Download/index.aspx) - To install all dependencies ```console 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: ```console 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 ```console 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` <details> <summary>Links</summary> - https://medium.com/@antonioszeto/how-to-install-nvidia-driver-on-ubuntu-18-04-7b464bab43e6 - </details> ::: ### xserver :::spoiler 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](https://hackmd.io/GAilfq9MRfCHiepcBdQr2w?view#NVIDIA-CUDA-Installation-Runfile-Installation-Approach) <!-- {%hackmd theme-dark %} -->