Setup Project 4

Deep Learning & GPU/Colab Environment Setup

Prepare a GPU-accelerated cloud environment inside your Linux VM browser using Google Colab, select active T4 hardware runtime wrappers, load TensorFlow & Keras packages, and compile a test neural network training loop.

Environment
Google Colab / Cloud GPU
Difficulty
Intermediate (2/5)
Course Module
Deep Learning & Neural Networks
Deliverables
GPU Detection & Test Epoch Logs
Hardware virtualization notice: Configuring local GPU acceleration (NVIDIA CUDA/cuDNN) inside a VirtualBox virtual machine is extremely difficult due to lack of direct hardware graphics card passthrough support. Therefore, this project guides you through setting up and utilizing Google Colab (a free cloud-based GPU environment) directly inside your Linux VM's browser, which provides instant access to powerful NVIDIA T4 or A100 GPUs without manual CUDA driver configurations. A local CPU-only fallback verification is also provided for reference.
1. System Architecture & Process Workflow

The diagram below displays the Google Colab cloud execution model. The user's VirtualBox guest Firefox browser establishes an HTTPS secure web socket connection to Google Cloud Servers, which instantiate a virtual machine container, mapping standard model instructions to physical NVIDIA T4 GPU accelerator cards.

GUEST LINUX VM (VIRTUALBOX) Firefox Web Browser colab.research.google.com Loads Jupyter Frontend UI Renders charts and logs HTTPS/WebSockets Secure Socket Tunnel GOOGLE CLOUD SERVER CONTAINER Cuda Kernel VM Driver TensorFlow Engine Physical Hardware: NVIDIA T4 GPU
2. Part 1: Step-by-Step Action Items & Key Execution Steps
STEP 1

Open Web Browser inside Ubuntu VM

Launch Firefox browser from the desktop taskbar dock inside your virtual system workspace.

Click orange Firefox Browser icon in left-side dock -> Wait for window to load
This boots the web application renderer inside the Linux desktop window.
STEP 2

Navigate to the Google Colaboratory Portal

Enter the direct URL link in the address bar to open the cloud development dashboard.

Click URL address bar -> Type: https://colab.research.google.com -> Press Enter
This connects the browser window to Google's cloud computing interface server files.
STEP 3

Log In with Google Credentials

Sign in using your Google credentials to authenticate permissions and initialize personal workspace sheets.

Click top-right "Sign in" button -> Enter your Google Email -> Click Next -> Enter Password -> Click Next
This grants you workspace access, linking cloud servers to your Google Drive account for saving notebooks.
STEP 4

Create a Fresh Jupyter Notebook

Instantiate an empty interactive notebook structure inside the Google Drive cloud container.

Wait for popup modal -> Click blue "New notebook" button at bottom right (or Click File -> New Notebook)
This action spins up a clean cloud sandbox instance running a Python 3 runtime backend.
STEP 5

Rename Notebook file name

Assign a descriptive name to the notebook document to keep your work organized.

Click file name text box "Untitled0.ipynb" in upper-left -> Delete default text -> Type: deep_learning_setup.ipynb -> Press Enter
This renames the file inside your Google Drive storage path.
STEP 6

Change Cloud VM Hardware Accelerator

Open the hardware selection menu to change the execution engine from CPU to GPU.

Click "Runtime" in top menu -> Click "Change runtime type" -> Select "T4 GPU" in Hardware Accelerator dropdown -> Click Save
This instructs Google Cloud to detach the CPU server instance and boot a VM container with an active NVIDIA T4 graphics card.
STEP 7

Connect to Cloud VM Runtime Session

Initialize the server session allocation to mount the file system and hardware stack.

Click "Connect" button in upper-right corner of screen -> Wait for green checkmark -> Verify RAM/Disk info displays
This allocates the remote memory limits, mounting the workspace folders in Google Cloud.
STEP 8

Load the Python Diagnostic Script

Enter the verification script block inside the first empty code cell.

Click inside Code Cell 1 -> Copy Python code from Part 2 below -> Paste into the Cell box
This loads the script checking library versions, GPU hardware links, and Keras model compiling.
STEP 9

Execute Code Cell and Verify Console Logs

Run the cell block to verify that the GPU is detected and that model training runs successfully.

Press Shift + Enter (or Click circular Play icon on left margin of cell) -> Review printed logs below cell
This executes the Python script. Ensure the console logs show `Num GPUs Available: 1` and print epoch training status.
STEP 10

Save and Download Notebook Document

Save the active notebook updates and download the file locally to submit.

Click File -> Click Save (Ctrl + S) -> Click File -> Click Download -> Select Download .ipynb
This commits changes to Google Drive and downloads a copy of the notebook file to your local VM system.
3. Operational Pipeline Architecture

The diagram below outlines the deep learning environment initialization pipeline. It traces the steps from browser launch and cloud connection to runtime allocation, GPU selection, verification script run, and saving the final notebook.

1. Open Browser Navigate to Colab and authenticate colab.research.google 2. New Notebook Rename file and initialize sandbox File -> New Notebook 3. Choose GPU Select T4 accelerator and start runtime Runtime -> Change type 4. Run Check Paste diagnostics and execute cell block Shift + Enter 5. Save Report Download ipynb sheet to local system Save & Download
4. Part 2: Complete Deliverable Assets & Production Templates

To verify the TensorFlow and GPU runtime connection, we will build a Python validation script. Below is a line-by-line explanation of the code, followed by the combined script.

Step-by-Step Code Construction

Lines 1 - 3

Import Framework Modules

Include TensorFlow and NumPy packages to construct the diagnostic models.

import tensorflow as tf import numpy as np
These imports check system paths and load the numerical libraries and neural network structures.
Lines 4 - 8

Detect Active GPU Devices

Query the active device hardware configurations to see if the GPU is available.

print(f"TensorFlow Version: {tf.__version__}") gpu_devices = tf.config.list_physical_devices('GPU') print(f"Num GPUs Available: {len(gpu_devices)}") for device in gpu_devices: print(f" - Device name details: {device}")
This checks the CUDA runtime link, verifying that TensorFlow is connected to the cloud GPU accelerator.
Lines 9 - 11

Create Mock Arrays

Generate random arrays using NumPy to simulate a training dataset.

input_features = np.random.random((1000, 32)) target_labels = np.random.randint(2, size=(1000, 1))
This generates 1000 records of 32 float inputs and matching binary target labels (0 or 1) in memory.
Lines 12 - 16

Compile a Neural Network Model

Assemble neural network layers sequence using Keras.

model = tf.keras.Sequential([ tf.keras.layers.Dense(64, activation='relu', input_shape=(32,)), tf.keras.layers.Dropout(0.2), tf.keras.layers.Dense(1, activation='sigmoid') ])
This defines a multilayer network. A hidden layer (64 units, ReLU) feeds into a 20% Dropout regularization block, ending with a Sigmoid output node.
Lines 17 - 22

Train and Verify Network

Run the training loop to verify that model training compiles successfully.

model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy']) print("\nRunning test training loop (5 epochs):") history = model.fit(input_features, target_labels, epochs=5, batch_size=32, verbose=1) print("\nDeep Learning environment verification completed successfully!")
This configures parameters (Adam optimizer, cross-entropy loss), executes training for 5 epochs, and prints the accuracy status of the model.

Combined Colab Diagnostic Script

Copy this code block, paste it inside your first Google Colab notebook cell, and press Shift + Enter to run the diagnostics:

# colab_verify.py - Deep Learning Environment Verification Engine import tensorflow as tf import numpy as np def run_verification(): print("=== Google Colab GPU Diagnostics ===") print(f"TensorFlow Version: {tf.__version__}") # Hardware detection checks gpu_devices = tf.config.list_physical_devices('GPU') print(f"Num GPUs Available: {len(gpu_devices)}") if len(gpu_devices) > 0: for idx, device in enumerate(gpu_devices): print(f" - GPU {idx}: {device.name}") else: print("WARNING: No GPU detected. Check Runtime -> Change runtime type settings.") # Generate mock training dataset arrays input_features = np.random.random((1000, 32)) target_labels = np.random.randint(2, size=(1000, 1)) # Define simple neural structure model = tf.keras.Sequential([ tf.keras.layers.Dense(64, activation='relu', input_shape=(32,)), tf.keras.layers.Dropout(0.2), tf.keras.layers.Dense(1, activation='sigmoid') ]) # Model optimizer compilation model.compile( optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'] ) print("\nRunning test training loop (5 epochs):") history = model.fit( input_features, target_labels, epochs=5, batch_size=32, verbose=1 ) print("\n=== Deep Learning Environment Verification Completed! ===") if __name__ == "__main__": run_verification()
5. Deliverables Summary

Verify that the following configurations and outputs exist inside your project workspace.

Created Files / Templates

  • ~/Downloads/deep_learning_setup.ipynb - Downloaded diagnostic notebook file.

Verification Artifacts / Execution Proof

  • Jupyter notebook console log showing Num GPUs Available: 1.
  • Successful execution curves showing loss reduction during the 5 epochs.
  • Colab page status bar showing "Connected to T4 GPU" runtime backend.
6. Closing Explanation: Why We Did This & What It Accomplishes

Architectural Intent & Operational Impact

Why We Did This

What This Accomplishes