Ditch your local laptop. Build a persistent Deep Learning lab on Bare Metal. Master Secure SSH Tunneling, avoid dependency hell, and connect directly via VSCode.
The End of Localhost AI
Running serious Deep Learning models or fine-tuning Large Language Models (LLMs) on a local Mac or standard desktop is no longer viable. The VRAM requirements for modern AI mandate deploying workloads on a Remote GPU Server.
However, transitioning to a headless Ubuntu server often results in "Dependency Hell" and security vulnerabilities. Modern SREs deploy JupyterLab to provide a full browser-based IDE.
Phase 1: NVIDIA Drivers & The Miniconda Architecture
Verify your server recognizes the NVIDIA hardware via nvidia-smi. (If drivers are missing, execute sudo ubuntu-drivers autoinstall and reboot).
⚠️ SRE WARNING: Anaconda Bloatware & Conda Crashes
Anaconda installs gigabytes of unnecessary libraries. Use Miniconda instead. Furthermore, runningconda activateimmediately afterconda inittriggers aCommandNotFoundError. You must refresh your shell context usingsource ~/.bashrc.
# 1. Verify NVIDIA Driver
nvidia-smi
# 2. Install Miniconda (Lightweight Environment Manager)
wget [https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh](https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh) -O miniconda.sh
bash miniconda.sh -b -p $HOME/miniconda
eval "$($HOME/miniconda/bin/conda shell.bash hook)"
conda init
# 3. SRE FIX: Refresh shell to prevent CommandNotFoundError
source ~/.bashrc
# 4. Create an isolated environment for Python 3.11
conda create -n ai_lab python=3.11 -y
conda activate ai_lab
Phase 2: Install PyTorch & JupyterLab
Modern PyTorch 2.x ships with pre-compiled CUDA binaries, eliminating the need to install system-level CUDA toolkits manually.
# 1. Install PyTorch with CUDA 12.1 Support
pip install torch torchvision torchaudio --index-url [https://download.pytorch.org/whl/cu121](https://download.pytorch.org/whl/cu121)
# 2. Install JupyterLab and IPykernel
pip install jupyterlab ipykernel
# 3. Register your environment as a Jupyter Kernel
python -m ipykernel install --user --name=ai_lab --display-name "PyTorch (GPU)"
Phase 3: Persistent Headless Execution
Avoid training job crashes caused by dropped SSH sessions by setting a persistent hashed password and running JupyterLab in tmux.
# 1. Generate config and set a persistent password
jupyter server --generate-config
jupyter server password
# 2. Start a persistent tmux session
tmux new -s jupyter_session
# 3. Launch JupyterLab bound strictly to localhost
jupyter lab --no-browser --port=8888 --ip=127.0.0.1
Detach from tmux: Press Ctrl+B, then D.
Phase 4: Browser Access via SSH Tunnel (Zero Open Ports)
🚨 SECURITY ALERT: The Exposed Port Vulnerability
Runningsudo ufw allow 8888exposes Jupyter directly to the internet. Automated botnets scan port 8888 to hijack GPUs for crypto-mining. Keep UFW closed and bridge connections securely via SSH Tunneling.
Run this command on your Local Laptop:
# Forward Local Port 8888 to Remote Port 8888
ssh -N -L 8888:127.0.0.1:8888 your_username@YOUR_REMOTE_SERVER_IP
Now navigate to http://localhost:8888 in your local browser and enter your password.
Phase 5: Modern IDE Approach (VSCode Remote-SSH)
For full local extension support (Pylance, GitHub Copilot) alongside remote execution:
- Install the official Remote - SSH extension in local VSCode.
- Press
F1->Remote-SSH: Connect to Host...-> Enterssh username@YOUR_SERVER_IP. - Open a
.ipynbnotebook file on the server. - Select Kernel -> Python Environments -> Select
ai_lab.
# Verify GPU availability in VSCode Notebook
import torch
print(f"PyTorch Version: {torch.__version__}")
print(f"CUDA Available: {torch.cuda.is_available()}")
if torch.cuda.is_available():
print(f"Hardware Detected: {torch.cuda.get_device_name(0)}")
print(f"VRAM Allocated: {torch.cuda.memory_allocated()/1e9:.1f} GB")
💬 JupyterLab & Remote GPU FAQ
JupyterLab vs Jupyter Notebook: Which is better?
JupyterLab is a complete browser-based IDE offering terminal access, file managers, and split views, making it superior to the legacy single-document Notebook interface for remote GPU workflows.
Why shouldn't I open Port 8888 on my Ubuntu Firewall?
Opening port 8888 exposes Jupyter to automated botnet scans that hijack GPU resources for crypto-mining. Access the server strictly via SSH Tunneling or VSCode Remote-SSH.
Why did my 'conda activate' command crash on Ubuntu 24.04?
Running conda init modifies .bashrc but does not reload your active shell context automatically. You must run source ~/.bashrc before running conda activate.
Read the full tutorial on ServerMO:
Setup JupyterLab & PyTorch on Ubuntu 24.04: Remote GPU Server | ServerMO
Top comments (0)