Data scientist setting up JupyterLab and PyTorch on an Ubuntu 24.04 Remote GPU Server hosted on ServerMO Bare Metal.

Setup JupyterLab & PyTorch on Ubuntu 24.04: Remote GPU Server

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 absolutely mandate deploying workloads on a Remote GPU Server.

However, transitioning from a comfortable local environment to a headless Ubuntu server often results in "Dependency Hell" and catastrophic security vulnerabilities. When comparing jupyterlab vs jupyter notebook, modern SREs exclusively deploy JupyterLab to provide a full browser-based IDE. This tutorial will show you exactly how to setup jupyter notebook remote server infrastructure securely.

[Important thing] Hardware Supremacy

If you are fine-tuning massive models, you need serious VRAM. Deploy this setup on ServerMO's NVIDIA H100 or NVIDIA A100 Dedicated GPU Servers to completely eradicate hardware bottlenecks and cloud egress taxes.

Phase 1: NVIDIA Drivers & The Miniconda Architecture

Before installing AI frameworks, you must ensure your server recognizes the underlying NVIDIA hardware. If you haven't installed the drivers, execute sudo ubuntu-drivers autoinstall and reboot.

[Warning] The Anaconda Bloatware & Conda Crash

Many tutorials advise downloading the massive "Anaconda" distribution. It installs gigabytes of unnecessary libraries that pollute your system path. Use Miniconda instead.

Furthermore, a common Linux trap is running conda activate immediately after conda init, which results in a CommandNotFoundError. You must refresh your shell context using source ~/.bashrc to prevent this crash.

# 1. Verify NVIDIA Driver and GPU presence
nvidia-smi

# 2. Download and install Miniconda (Lightweight Environment Manager)
wget 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 the shell to prevent CommandNotFoundError
source ~/.bashrc

# 4. Create an isolated environment for Python 3.11 (Highly stable for ML)
conda create -n ai_lab python=3.11 -y

# 5. Activate the environment
conda activate ai_lab

Phase 2: Install PyTorch & JupyterLab

With our environment isolated, we must install PyTorch with the correct CUDA bindings. Modern PyTorch 2.x ships with pre-compiled CUDA binaries, meaning you do not need to install the massive system-level CUDA toolkit manually.

# 1. Install PyTorch with CUDA 12.1 Support (Optimal for Ubuntu 24.04)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121

# 2. Install JupyterLab and the IPykernel package
pip install jupyterlab ipykernel

# 3. Register your virtual environment as a dedicated Jupyter Kernel
python -m ipykernel install --user --name=ai_lab --display-name "PyTorch (GPU)"

Phase 3: The Persistent Headless Execution

A common disaster occurs when a Data Scientist starts training a model, their Wi-Fi drops, the SSH session dies, and the Jupyter server crashes instantly. You must run JupyterLab persistently.

[Important thing] Defeating the Ephemeral Token Trap

By default, Jupyter generates a dynamic URL token (?token=abc...). Relying on this means your access breaks every time the server reboots or tmux restarts. You must set a persistent hashed password before starting the daemon.

# 1. Generate config and set a persistent password (It will prompt you to type one)
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 (Headless Mode)
jupyter lab --no-browser --port=8888 --ip=127.0.0.1

You can now detach from the tmux session by pressing Ctrl+B, then D. Jupyter will remain running forever in the background.

Phase 4: Browser Access via SSH Tunnel (Zero Open Ports)

If you prefer using a web browser instead of an IDE, how do you access the Jupyter interface safely?

[Security Alert] The Exposed Port Vulnerability

Amateur tutorials will tell you to run sudo ufw allow 8888 so you can access the server via its public IP. Never do this! The moment you open port 8888, automated botnets will brute-force your server to hijack the GPU for cryptocurrency mining. You must keep the UFW firewall closed and use a secure jupyter notebook ssh tunnel.

Open a new terminal on your Local Laptop (Mac/Windows) and run the following command to securely bridge the connection:

# Execute this ON YOUR LOCAL LAPTOP
# -N: Do not execute remote commands
# -L: Forward Local Port 8888 to Remote Port 8888
ssh -N -L 8888:127.0.0.1:8888 your_username@YOUR_REMOTE_SERVER_IP

Now, open your local web browser and go to http://localhost:8888. Type the password you created in Phase 3. You are now securely accessing the Remote GPU!

Phase 5: The Modern IDE Approach (VSCode Remote-SSH)

While the JupyterLab web interface is excellent, the ultimate "Dream Setup" is to run jupyter notebook in vscode. This gives you local themes, Pylance type-checking, and GitHub Copilot, while all the heavy math executes on your Bare Metal Server.

[Important thing] The Legacy VSCode Blindspot

Many developers still connect VSCode by pasting a `localhost:8888` URL into the "Existing Jupyter Server" prompt. This is a legacy method! It blinds your IDE to the remote file system, preventing you from viewing folders or editing native `.py` files. The modern MLOps standard is using the Remote - SSH extension.

  • Open Visual Studio Code on your local machine and install the official Remote - SSH extension by Microsoft.
  • Press F1 and type Remote-SSH: Connect to Host.... Enter your server's SSH details (e.g., ssh username@YOUR_SERVER_IP).
  • VSCode will install a tiny server agent on your remote machine and open its file system natively. (Note: This entirely bypasses the need for the manual SSH tunnel in Phase 4!)
  • Create a new file named training.ipynb on the server.
  • In the top right corner, click Select Kernel ->Python Environments, and select the ai_lab conda environment you created in Phase 1.
# Run this in your VSCode Notebook Cell to verify GPU supremacy!
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")

Congratulations! You have successfully established a highly secure, persistent, and developer-friendly Deep Learning laboratory. By hosting this architecture natively on ServerMO, you achieve maximum hardware utilization without paying the hidden cloud taxes of AWS or GCP.

JupyterLab & Remote GPU FAQ

JupyterLab vs Jupyter Notebook: Which is better for a Remote Server?

JupyterLab is the modern, superior choice. While Jupyter Notebook is just a single-document interface, JupyterLab is a full IDE running in your browser, featuring terminal access, file explorers, and split-screen views, making it ideal for managing complex Deep Learning projects on a remote Bare Metal server.

Why shouldn't I open Port 8888 on my Ubuntu Firewall?

Opening port 8888 exposes your Jupyter instance directly to the public internet. Hackers actively scan for this port to inject malicious code and hijack GPU servers for crypto-mining. You must keep the port closed and access the server securely via an SSH Tunnel.

How do I run a remote Jupyter Notebook in VSCode?

Use the official 'Remote - SSH' extension in VSCode. It connects directly to your remote Linux file system and automatically handles port forwarding. This entirely replaces the legacy method of manually pasting a Jupyter URL into the IDE.

Why did my 'conda activate' command crash on Ubuntu 24.04?

After running 'conda init', your shell environment is not automatically reloaded. If you immediately run 'conda activate', it results in a CommandNotFoundError. You must run 'source ~/.bashrc' first to refresh your shell before creating environments.

Ready to Launch with Unmatched Power?

Ready to Launch with Unmatched Power? Deploy blazing-fast 1–100Gbps unmetered servers, high-performance GPU rigs, or game-optimized hosting custom-built for speed, reliability, and scale. Whether it’s colocation, compute-intensive tasks, or latency-critical applications, ServerMO delivers. Order now and get online in minutes, fully secured, fully optimized.

Red and white text reads '24x7' above bold purple 'SERVICES' on a white background, all set against a black backdrop. Energetic and modern feel.

Power. Performance. Precision.

99.99% Uptime Guarantee
24/7 Expert Support
Blazing-Fast NVMe SSD

Christmas Mega Sale!

Unwrap the ultimate power! Get massive holiday discounts on all Dedicated Servers. Offer ends soon grab yours before the snow melts!

London UK (15% OFF)
Tokyo Japan (10% OFF)
00Days
00Hrs
00Min
00Sec
Explore Grand Offers