0% found this document useful (0 votes)
0 views10 pages

Ubuntu Setup Guide

This document is a comprehensive guide for setting up a machine learning development environment on Ubuntu 22.04 with NVIDIA GPU support, including installation, dual-boot partitioning, and configuring necessary tools like CUDA and compilers. It outlines step-by-step instructions for preparing the bootable USB, resizing partitions, installing Ubuntu, and troubleshooting common issues. The guide also covers the installation of development tools such as Conda and Git, along with verification of the setup for GPU-accelerated training.

Uploaded by

DVelocitieA
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views10 pages

Ubuntu Setup Guide

This document is a comprehensive guide for setting up a machine learning development environment on Ubuntu 22.04 with NVIDIA GPU support, including installation, dual-boot partitioning, and configuring necessary tools like CUDA and compilers. It outlines step-by-step instructions for preparing the bootable USB, resizing partitions, installing Ubuntu, and troubleshooting common issues. The guide also covers the installation of development tools such as Conda and Git, along with verification of the setup for GPU-accelerated training.

Uploaded by

DVelocitieA
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Ubuntu 22.

04 + GPU Dev Environment Setup 1

Setting Up Ubuntu 22.04 with NVIDIA GPU


Support
for Machine Learning Development
A Complete Guide: Installation, Dual-Boot Partitioning,
CUDA, and Development Tools

Contents
1 Overview 2

2 Preparing the Bootable USB and Booting into the Installer 2


2.1 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.2 Booting from the USB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

3 Shrinking the Windows Partition with GParted 2


3.1 Initial disk layout (example) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3.2 Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3.3 Recommended final layout (example) . . . . . . . . . . . . . . . . . . . . . . . . . 3

4 Installing Ubuntu 4

5 First Boot Issues 4

6 Installing Chrome (Optional) 5

7 Setting Up the NVIDIA GPU and CUDA Toolkit 5


7.1 Step 1: Install the NVIDIA driver . . . . . . . . . . . . . . . . . . . . . . . . . . 5
7.2 Step 2: Install the CUDA Toolkit . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

8 Installing Compilers (C, C++, Python) 7

9 Installing Conda (Miniconda) 7


9.1 Does (base) need to be activated every time? . . . . . . . . . . . . . . . . . . . . 8

10 Git Setup 8

11 Installing Antigravity (Google’s AI IDE) 9

12 Verifying the Full Setup 10

13 Testing GPU-Accelerated Training (PyTorch) 10

14 Summary Checklist 10
Ubuntu 22.04 + GPU Dev Environment Setup 2

1 Overview
This guide covers the complete process of installing Ubuntu 22.04 LTS alongside an existing
Windows installation on a dual-boot laptop (tested on an HP OMEN laptop with an NVIDIA
RTX 4060), resizing partitions to allocate space to Ubuntu, and setting up a full machine
learning development environment including NVIDIA drivers, CUDA, compilers, conda, git,
and the Antigravity IDE.
Each major step includes the commands used and, where relevant, real issues that came up
during setup along with how they were resolved.

2 Preparing the Bootable USB and Booting into the Installer


2.1 Requirements
ˆ A USB drive (8GB+) flashed with the Ubuntu 22.04 ISO (using Rufus, Balena Etcher, or
similar)
ˆ A Windows PC with free disk space to shrink
ˆ Back up any important data before proceeding – partition operations carry inherent risk

2.2 Booting from the USB


1. Plug in the bootable USB drive
2. Restart the PC
3. Immediately and repeatedly press the boot menu key during startup (commonly Esc, F9,
F10, F12, or Del depending on the manufacturer – on HP OMEN laptops, spamming Esc
opens the BIOS Startup Menu)
4. From the BIOS Startup Menu, select Boot Device Options
5. Select the USB drive from the list
6. At the Ubuntu boot screen, choose Try or Install Ubuntu

Issue: USB drive doesn’t appear in Boot Device Options

Fix
ˆ Ensure the USB is plugged directly into the laptop, not through a hub
ˆ Try a different USB port
ˆ Enter BIOS Setup and confirm Secure Boot is not blocking the drive, then return
to Boot Device Options

3 Shrinking the Windows Partition with GParted


Once inside the Ubuntu live session, avoid clicking “Install Ubuntu” immediately. Instead, use
GParted first to create free space for Ubuntu without erasing the entire disk.

3.1 Initial disk layout (example)


/dev/nvme0n1p1 EFI system partition fat32 260 MiB
/dev/nvme0n1p2 Microsoft reserved -- 16 MiB
/dev/nvme0n1p3 Windows (NTFS) ntfs 414.82 GiB
/dev/nvme0n1p4 HP recovery/diag ntfs 1 GiB
Ubuntu 22.04 + GPU Dev Environment Setup 3

3.2 Steps
1. Open GParted from the live desktop (install with sudo apt install gparted if not
preinstalled and internet is available)
2. Identify the Windows NTFS partition (largest partition, typically labelled Windows)
3. If there is a small recovery/diagnostics partition (e.g. p4) sitting between Windows and
the free space, it must be relocated to the end of the disk first, since GParted can only
grow a partition into adjacent free space
4. Right-click the target partition(s) to shrink → Resize/Move → drag the boundary or
type an exact size in MiB → Resize/Move
5. Queue up all needed operations, then click the green checkmark (Apply) to execute them

Issue: Windows can’t be extended into freed space even after shrinking Linux
partitions

Fix
GParted only merges a partition with free space that is directly adjacent to it. If a small
system partition (like an HP recovery partition) sits between Windows and the space you
freed up, move that partition to the very end of the disk first:
Right-click the small partition -> Resize/Move
Set "Free space preceding" to the maximum available value
Apply

Then delete/shrink the Linux partitions, and finally extend Windows into the now-
contiguous free space.

Issue: “Free space preceding” rejects a large value / partition move fails

Fix
This happens when the space you’re trying to move into is still occupied by another partition
(not yet freed). Delete or shrink the occupying partition first, then retry the move – the
correct order is: shrink/delete the partitions taking up the space → move the small system
partition into the resulting free block → extend Windows.

Issue: Partition move requires moving real data and appears slow

Fix
Moving a partition with data on it (not just an empty/reserved one) involves physically
copying data on disk, which can take significant time depending on size and drive speed.
This is expected – do not interrupt the operation once started, and ensure the laptop is
plugged into power throughout.

3.3 Recommended final layout (example)


/dev/nvme0n1p1 EFI system fat32 260 MiB
/dev/nvme0n1p2 Microsoft reserved -- 16 MiB
/dev/nvme0n1p3 Windows (NTFS) ntfs ~700+ GiB (extended)
/dev/nvme0n1p4 HP recovery/diag ntfs 1 GiB (moved to end)
/dev/nvme0n1p6 Ubuntu root ext4 250 GiB (new, for install)
Ubuntu 22.04 + GPU Dev Environment Setup 4

4 Installing Ubuntu
1. From the live desktop, open Activities (or the app grid icon) and search “Install” if the
desktop icon isn’t visible, then launch Install Ubuntu
2. Welcome: choose language, click Continue
3. Keyboard layout: select layout, Continue
4. Updates and other software: choose Normal installation; optionally check “Down-
load updates while installing” and “Install third-party software for graphics and Wi-Fi
hardware”
5. Installation type: select Something else (manual partitioning) – do not choose “Erase
disk” or rely on automatic dual-boot, to keep full control over which partition is touched
6. On the partition table screen, select the newly created ext4 partition (e.g. p6), click
Change..., set:
ˆ Use as: Ext4 journaling file system
ˆ Check Format the partition
ˆ Mount point: /
7. Confirm Device for boot loader installation is set to the whole disk (e.g. /dev/nvme0n1),
not a specific partition
8. Click Install Now and carefully review the confirmation summary – it should only men-
tion formatting the target Ubuntu partition, never the Windows partition
9. Continue through timezone and user account setup, let the install finish, then Restart
Now and remove the USB drive when prompted

Issue: Unsure which partition is safe to select in “Something else”

Fix
Cross-check the partition list against GParted’s earlier output (size and filesystem type).
Before clicking Install Now, always read the confirmation dialog listing exactly which par-
titions will be formatted – if the Windows/NTFS partition is listed, stop and go back.

5 First Boot Issues

Issue: Black screen for several minutes after install, or after reboot

Fix
ˆ Tap Caps Lock – if the indicator LED toggles, the system is alive but not displaying
anything (often an NVIDIA/GPU driver handshake issue), rather than fully frozen
ˆ Try pressing a key or moving the trackpad in case it’s a display sleep state, not a hang
ˆ If unresponsive, force shut down by holding the power button for ˜10 seconds, then
power back on

Issue: Caps Lock LED blinks in a repeating long/short pattern with a black
screen
Ubuntu 22.04 + GPU Dev Environment Setup 5

Fix
This is an HP embedded-controller blink code. A 5-long, 4-short (or similar 5.x) pattern
typically indicates the embedded controller could not reach the BIOS in time – often resolved
with a full power drain rather than a hardware fault:
1. Disconnect the charger and any peripherals
2. Hold the power button for 15–30 seconds to drain residual power
3. Reconnect the charger and power on again
If the same code recurs consistently even after this, it may point to a deeper motherboard-
/RAM issue and is worth checking against HP’s official blink-code documentation.

Issue: “Perform MOK management” blue screen appears at boot

Fix
This is the standard Secure Boot / Machine Owner Key (MOK) prompt related to signed
third-party kernel modules (e.g. NVIDIA drivers). Simply select Continue boot and press
Enter. If this screen reappears on every boot, MOK enrollment may need to be completed
properly through the Enroll MOK option using the on-screen password prompt.

Issue: GRUB menu appears with Ubuntu, Advanced options, and Windows
Boot Manager

Fix
This is expected and confirms both operating systems were detected correctly. Select
Ubuntu (or Windows Boot Manager to boot into Windows) and press Enter.

6 Installing Chrome (Optional)


cd ~/Downloads
sudo apt install ./google-chrome-stable_current_amd64.deb

Alternatively, double-click the downloaded .deb file and install via the Software Center GUI.

7 Setting Up the NVIDIA GPU and CUDA Toolkit


7.1 Step 1: Install the NVIDIA driver
sudo ubuntu-drivers autoinstall
sudo reboot

After reboot, verify:


nvidia-smi

This should list the GPU (e.g. NVIDIA GeForce RTX 4060), driver version, and CUDA version
supported by that driver.
Ubuntu 22.04 + GPU Dev Environment Setup 6

7.2 Step 2: Install the CUDA Toolkit


The Ubuntu-repo package nvidia-cuda-toolkit was unreliable in testing due to a regional
mirror serving an incomplete package index. NVIDIA’s own APT repository is the more robust
route:
wget [Link]
-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt update
sudo apt install cuda-toolkit

Add CUDA to the shell PATH:


echo ’export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}’ >> ~/.bashrc
echo ’export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${
LD_LIBRARY_PATH}}’ >> ~/.bashrc
source ~/.bashrc

Verify:
nvcc --version
nvidia-smi

Issue: E: Unable to locate package nvidia-cuda-toolkit

Fix
First ensure the universe repository component is enabled:
sudo add-apt-repository universe
sudo apt update

If the package is still missing (or even a base package like build-essential cannot be
located), the regional package mirror in /etc/apt/[Link] may be serving stale or
broken indexes. Switch to the global archive mirror:
sudo cp /etc/apt/[Link] /etc/apt/[Link]
sudo sed -i ’s/[Link]/[Link]/g’ /etc/apt/[Link]
sudo apt update

(Replace [Link] with whatever regional mirror appears in your own


sources file.) Then retry the install.

Issue: sudo: add-apt-repository: command not found or “must run as root”

Fix
Confirm sudo itself is functioning correctly:
sudo whoami

This should print root. If the add-apt-repository command is missing entirely, install
the helper package first:
sudo apt install software-properties-common
Ubuntu 22.04 + GPU Dev Environment Setup 7

Issue: cuda-toolkit install fails with unmet dependencies (e.g. build-essential,


libxcb-xinerama0 not installable)

Fix
This is the same underlying mirror problem described above – fix the mirror first (switch
away from a broken regional mirror to [Link]), run sudo apt update again,
and the dependency packages should resolve correctly:
sudo apt install build-essential libxcb-xinerama0 libxcb-xinput0 libxcb-cursor0
sudo apt install cuda-toolkit

Issue: nvcc: command not found after installing cuda-toolkit

Fix
The toolkit installed but its bin directory is not yet on $PATH. Confirm the install location
and add it manually:
ls /usr/local/ | grep cuda
echo ’export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}’ >> ~/.bashrc
echo ’export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${
LD_LIBRARY_PATH}}’ >> ~/.bashrc
source ~/.bashrc
nvcc --version

8 Installing Compilers (C, C++, Python)


sudo apt update
sudo apt install build-essential python3 python3-pip python3-venv gdb

Verify:
gcc --version
g++ --version
python3 --version
pip3 --version

9 Installing Conda (Miniconda)


cd ~/Downloads
wget [Link]
bash Miniconda3-latest-Linux-x86_64.sh

During installation: press Enter to review the license, type yes to accept, press Enter to accept
the default install path, and type yes when asked whether to initialize conda in the shell profile.
source ~/.bashrc
conda --version
Ubuntu 22.04 + GPU Dev Environment Setup 8

Issue: 404 Not Found when downloading Miniconda

Fix
The correct download path uses /miniconda/, not /miniconda3/:
wget [Link]

Issue: conda: command not found after installation finishes

Fix
This happens if the installer’s shell-initialization prompt was answered “no” (the default).
Initialize conda manually:
~/miniconda3/bin/conda init bash
source ~/.bashrc
conda --version

The shell prompt should now show (base) at the start of each line.

Issue: CondaToSNonInteractiveError: Terms of Service not accepted for default


channels

Fix
Recent conda versions require explicitly accepting the Terms of Service for the default
channels before creating environments:
conda tos accept --override-channels --channel [Link]
main
conda tos accept --override-channels --channel [Link]

9.1 Does (base) need to be activated every time?


No – once conda init has run, the base environment activates automatically in every new
terminal session. Manual activation is only needed to switch to a different environment:
conda activate ml # switch to a named environment
conda activate base # switch back to base

To disable auto-activation of base on shell startup (optional):


conda config --set auto_activate_base false

10 Git Setup
sudo apt install git
git config --global [Link] "Your Name"
git config --global [Link] "[Link]@[Link]"

For SSH-based GitHub access:


Ubuntu 22.04 + GPU Dev Environment Setup 9

ssh-keygen -t ed25519 -C "[Link]@[Link]"


cat ~/.ssh/id_ed25519.pub

Add the printed public key under GitHub → Settings → SSH and GPG keys.

11 Installing Antigravity (Google’s AI IDE)


sudo mkdir -p /etc/apt/keyrings
curl -fsSL [Link] | \
sudo gpg --dearmor --yes -o /etc/apt/keyrings/[Link]
echo "deb [signed-by=/etc/apt/keyrings/[Link]] [Link]
-[Link]/projects/antigravity-auto-updater-dev/ antigravity-debian main" | \
sudo tee /etc/apt/[Link].d/[Link] > /dev/null
sudo apt update
sudo apt install antigravity

Launch with:
antigravity

Issue: curl: command not found

Fix
Install curl first, and let it finish completely before re-running the Antigravity commands:
sudo apt install curl

Issue: NO PUBKEY / GPG signature error, “repository is not signed”

Fix
This occurs when the GPG key file failed to download (commonly because curl wasn’t
installed yet when the key-download command originally ran, silently producing an emp-
ty/invalid key file). Recreate the key cleanly, one command at a time:
sudo rm -f /etc/apt/keyrings/[Link]
sudo mkdir -p /etc/apt/keyrings
curl -fsSL [Link] | \
sudo gpg --dearmor --yes -o /etc/apt/keyrings/[Link]
ls -la /etc/apt/keyrings/[Link] # confirm non-zero file size
sudo apt update
sudo apt install antigravity

If the error persists, also remove and re-add the repository list file:
sudo rm -f /etc/apt/[Link].d/[Link]
echo "deb [signed-by=/etc/apt/keyrings/[Link]] [Link]
[Link]/projects/antigravity-auto-updater-dev/ antigravity-
debian main" | \
sudo tee /etc/apt/[Link].d/[Link] > /dev/null
sudo apt update
sudo apt install antigravity
Ubuntu 22.04 + GPU Dev Environment Setup 10

12 Verifying the Full Setup


A single combined command to check every component at once:
echo "=== GPU / NVIDIA ===" && nvidia-smi --query-gpu=name,driver_version,memory.
total --format=csv,noheader && \
echo "=== CUDA ===" && nvcc --version | grep release && \
echo "=== GCC ===" && gcc --version | head -1 && \
echo "=== G++ ===" && g++ --version | head -1 && \
echo "=== Python ===" && python3 --version && \
echo "=== Pip ===" && pip3 --version && \
echo "=== Conda ===" && conda --version && \
echo "=== Git ===" && git --version && \
echo "=== Git config ===" && git config --global [Link] && git config --global
[Link] && \
echo "=== Antigravity ===" && (command -v antigravity &> /dev/null && echo "
installed" || echo "NOT installed")

13 Testing GPU-Accelerated Training (PyTorch)


conda create -n ml python=3.11 -y
conda activate ml
pip install torch torchvision --index-url [Link]
python -c "import torch; print([Link].is_available()); print([Link].
get_device_name(0))"

A successful setup prints:


True
NVIDIA GeForce RTX 4060 Laptop GPU

confirming PyTorch can see and use the GPU for model training.

14 Summary Checklist
□ Bootable USB created and booted
□ Windows partition shrunk and free space allocated via GParted
□ Ubuntu 22.04 installed onto the new partition (Windows untouched)
□ System boots correctly (GRUB shows both OSes)
□ NVIDIA driver installed and nvidia-smi recognizes the GPU
□ CUDA Toolkit installed and nvcc --version works
□ GCC / G++ compilers installed
□ Python 3 and pip installed
□ Conda (Miniconda) installed and initialized
□ Git installed and configured
□ Antigravity IDE installed
□ PyTorch installed with CUDA and GPU access confirmed

You might also like