Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Configuring Windows 11 and Ubuntu 22.04 Dual Boot with Deep Learning Framework Deployment

Tech May 9 3

Removing an Existing Linux Partition

To completely remove a previous Ubuntu installation alongside Windows, access the UEFI/BIOS menu and set Windows Boot Manager as the primary boot option. Boot into Windows, launch a partition management tool like DiskGenius, and erase all Linux-related partitions (EFI, root, home, and swap). Save the partition table modifications, and finally, eliminate any residual Linux boot entries from the firmware.

Installing Ubuntu 22.04

Creating the Boot Media

Use Rufus to write the Ubuntu 22.04 ISO to a USB flash drive. Select the GPT partition scheme targeting UEFI mode, leaving the default filesystem settings intact. Before initiating the Ubuntu setup, disable BitLocker drive encryption within Windows and turn off Fast Startup in the power settings.

Installation and Partitioning Strategy

During the Ubuntu setup wizard, choose the minimal installation and select the manual partitioning option. For dual-drive configurations (Disk 0 housing Windows under GPT, Disk 1 designated for Linux under MBR), allocate a 400MB EFI System Partition on Disk 0 adjacent to the Windows data volume. On Disk 1, create a 50GB primary partition formatted as Ext4 mounted at /, and assign the remaining disk space to the /home partition, also formatted as Ext4. A dedicated swap partition is no longer necessary. To mitigate a known system freeze during the initial reboot, adjust the GRUB parameters prior to finalizing the installation.

Post-Installation System Tuning

Package Management and Synchronization

Change the software download mirror to Alibaba within the "Software & Updates" utility. Refresh the repositories and upgrade existing packages:

sudo apt update && sudo apt upgrade -y
sudo apt install -y vim git subversion gcc g++ cmake make

Rectify the hardware clock discrepancy that causes Windows to display incorrect timestamps:

sudo apt install ntpdate
sudo ntpdate time.windows.com
sudo hwclock --localtime --systohc

Bootloader and Desktop Applications

Configure the GRUB bootloader to prioritize Windows by default:

sudo nano /etc/default/grub
# Set: GRUB_DEFAULT=2
sudo update-grub

Essential desktop software such as Sogou Pinyin, Microsoft Edge, WeChat, WPS, and VSCode can be acquired via their official .deb packages and installed using sudo apt install ./package_name.deb.

Resolving Boot and Display Anomalies

If the system boots into a black screen with a blinking cursor, a graphics driver conflict is likely the cause. Switch to a TTY terminal (Ctrl+Alt+F3) and execute:

sudo apt purge 'nvidia-*'
sudo apt autoremove
# Identify active kernel: uname -r
# List installed kernels: dpkg --get-selections | grep linux-image
sudo apt purge linux-image-<inactive_version>
sudo update-grub

For absent boot entries, utilize the Boot-Repair utility. If an external monitor remains unpowered, reinstalling the proprietary Nvidia driver usually resolves the kernel-mode setting conflict. To restore missing brightness slider controls, append acpi_backlight=native to the GRUB_CMDLINE_LINUX_DEFAULT parameter inside /etc/default/grub, followed by sudo update-grub.

Configuring the Deep Learning Stack

Nvidia Driver, CUDA 12.2, and cuDNN 8.9

Download and execute the CUDA toolkit runfile, explicitly deselecting the bundled driver since the standalone driver is already present:

wget https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda_12.2.2_535.104.05_linux.run
sudo sh cuda_12.2.2_535.104.05_linux.run

Append environment variables to ~/.bashrc:

export CUDA_HOME=/usr/local/cuda
export PATH=${CUDA_HOME}/bin:$PATH
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH

Validate via nvcc -V. For cuDNN, extract the archive and copy the headers and libraries directly into the CUDA directory:

tar -xvf cudnn-linux-x86_64-8.9.7.29_cuda12-archive.tar.xz
sudo cp cudnn-*-archive/include/cudnn*.h ${CUDA_HOME}/include
sudo cp -P cudnn-*-archive/lib/libcudnn* ${CUDA_HOME}/lib64
sudo chmod a+r ${CUDA_HOME}/include/cudnn*.h ${CUDA_HOME}/lib64/libcudnn*

TensorRT 10

Extract the TensorRT tarball to a local directory (e.g., ~/Libs/TensorRT-10), and append its paths to ~/.bashrc:

export TRT_HOME=~/Libs/TensorRT-10
export PATH=${TRT_HOME}/bin:$PATH
export LD_LIBRARY_PATH=${TRT_HOME}/lib:$LD_LIBRARY_PATH

Source the profile and verify by compiling and executing the sampleOnnxMNIST example, or by running trtexec.

Anaconda and PyTorch

Execute the Anaconda installer, approving the PATH initialization:

bash Anaconda3-2023.09-0-Linux-x86_64.sh
source ~/.bashrc
conda update conda

Deploy PyTorch 2.1.0 with CUDA 12.1 support inside a dedicated environment:

conda create -n dl_env python=3.8
conda activate dl_env
conda install pytorch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 pytorch-cuda=12.1 -c pytorch -c nvidia

Verify GPU availability in Python via torch.cuda.is_available().

Building OpenCV 4.9 and Protobuf 3.20

Install development dependencies and compile OpenCV from source:

sudo apt install -y build-essential cmake libgtk-3-dev libavcodec-dev libavformat-dev libswscale-dev
unzip opencv-4.9.0.zip && cd opencv-4.9.0
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=YES ..
make -j$(nproc)
sudo make install

Update shared library bindings and PKG_CONFIG_PATH. For Protobuf, configure with a custom prefix, build, and export its paths to /etc/profile.

YOLOv5 and YOLOv8

Set up distinct conda environments for both frameworks. Install their respective requirements via pip and execute detection scripts assigning the processing load to the GPU.

OpenPCDet and MMDetection3d

For 3D object detection frameworks, establish isolated environments. Install spconv-cu120 for OpenPCDet, then build via python setup.py develop. Integrate Open3D for 3D data visualization. For MMDet3d, sequentially install mmengine, mmcv, mmdet, and mmsegmentation using mim or pip, ensuring strict version compatibility, and finalize by executing pip install -e . within the cloned repository.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.