Skip to content

Instantly share code, notes, and snippets.

@jeffshee
Last active April 30, 2021 05:27
Show Gist options
  • Save jeffshee/a06e5e224ee611f1734bd16a0ae01d38 to your computer and use it in GitHub Desktop.
Save jeffshee/a06e5e224ee611f1734bd16a0ae01d38 to your computer and use it in GitHub Desktop.
Ubuntu 20.04 dualboot setup + ML
# Resources
https://phoenixnap.com/kb/install-ubuntu-20-04
https://rufus.ie
# Steps
0. In Windows, shrink the disk partition to create free space for dual boot.
(Refer: https://www.linuxtechi.com/dual-boot-ubuntu-20-04-lts-along-with-windows-10/)
1. Restart. In BIOS, disable Secure Boot.
2. (Optional) Check if Windows boot successfully after Secure Boot is disabled. (It should!)
3. Restart. Boot the Ubuntu installer by either changing or overridding the boot order in BIOS.
NOTE: If the installer freeze, it might because of the NVIDIA GPU. Choose "Ubuntu (Safe Graphic)" option.
(Refer: https://kledgeb.blogspot.com/2020/04/ubuntu-2004-25-ubuntu-2004-lts.html)
4. Follow the installation prompt. Remember to check "Install third party software ... " option.
5. Choose "Install Ubuntu alongside Windows Boot Manager" and continue.
NOTE: If the installer crashed because of bug #187168, see # Workaround below. Orz.
6. Done. Check if both Ubuntu and Windows can boot successfully.
# Workaround
For bug 187168, it seems Ubuntu itself is installed successfully, except the NVIDIA drivers. Therefore the driver have to be installed manually in Ubuntu. Because of the lack of driver, Ubuntu might not be able to boot normally. If so, boot into the recovery mode.
(Refer: https://askubuntu.com/questions/901326/how-to-start-a-fail-safe-graphics-session-with-mouse-web-browser)
To install NVIDIA driver manually, refer https://qiita.com/kenji-miyake/items/06b8c3807bef0ba5c451
After this, Ubuntu should be able to boot normally without the need of recovery mode.
# Assume that you already have a working Ubuntu environment and NVIDIA driver.
# CUDA
```
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda-repo-ubuntu2004-11-1-local_11.1.1-455.32.00-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2004-11-1-local_11.1.1-455.32.00-1_amd64.deb
sudo apt-key add /var/cuda-repo-ubuntu2004-11-1-local/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda
```
# CUDA Toolkit
```
sudo apt install nvidia-cuda-toolkit
```
Add below lines to the `/etc/bash.bashrc`
```
export PATH="/usr/local/cuda/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"
```
# cuDNN
https://developer.nvidia.com/rdp/cudnn-download
Download and install both Runtime and Developer Library.
# Testing (Expected output)
nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Mon_Oct_12_20:09:46_PDT_2020
Cuda compilation tools, release 11.1, V11.1.105
Build cuda_11.1.TC455_06.29190527_0
nvidia-smi
Wed Nov 11 16:10:29 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 455.38 Driver Version: 455.38 CUDA Version: 11.1 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 GeForce RTX 208... Off | 00000000:3B:00.0 Off | N/A |
| 27% 29C P8 1W / 250W | 10MiB / 11019MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 1 GeForce RTX 208... Off | 00000000:5E:00.0 Off | N/A |
| 27% 28C P8 17W / 250W | 10MiB / 11019MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 2 GeForce RTX 208... Off | 00000000:AF:00.0 On | N/A |
| 27% 37C P5 31W / 250W | 611MiB / 10985MiB | 1% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1527 G /usr/lib/xorg/Xorg 4MiB |
| 0 N/A N/A 2140 G /usr/lib/xorg/Xorg 4MiB |
| 0 N/A N/A 2278 G /usr/bin/gnome-shell 0MiB |
| 1 N/A N/A 1527 G /usr/lib/xorg/Xorg 4MiB |
| 1 N/A N/A 2140 G /usr/lib/xorg/Xorg 4MiB |
| 1 N/A N/A 2278 G /usr/bin/gnome-shell 0MiB |
| 2 N/A N/A 1527 G /usr/lib/xorg/Xorg 102MiB |
| 2 N/A N/A 2140 G /usr/lib/xorg/Xorg 385MiB |
| 2 N/A N/A 2278 G /usr/bin/gnome-shell 110MiB |
+-----------------------------------------------------------------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment