Setup Jupyter server in Ubuntu2404 in Alibaba Cloud ECS

ECS

This is a Jupyter server setting that support 100 concurrent students for a light machine learning class like the Titanic dataset project

  • Setup a ECS with 16 CPU and 64G RAM.
  • Ubuntu 24.04
  • Need public IP
  • Create ecs-user, do NOT use root.

For a cost-effective yet capable server, a good starting configuration is:

ComponentRecommendationNote
RAM64 GBEssential for preventing out-of-memory errors for concurrent users.
vCPUs16 – 32 vCPUs16 vCPUs is the minimum for a smooth, oversubscribed experience; 32 vCPUs is safer for guaranteed peak performance.
Disk128 GB SSDTotal storage for all user home directories and OS. Use an SSD for fast data access.
PlatformJupyterHubRequired to manage individual user environments and resource limits.

Server environment

It’s highly recommended to use a Python virtual environment (venv) to install packages like Pandas, Scikit-learn (sklearn), and Jupyter, to avoid conflicts with your system’s Python installation on Ubuntu 24.04.

1. Update Packages and Install Prerequisites

First, ensure your system is up-to-date and that you have Python 3, pip (the Python package installer), and the venv module installed in shell.

sudo apt update
sudo apt install python3 python3-pip python3-venv -y

(Ubuntu 24.04 usually comes with Python 3, but this command ensures all necessary tools are present.)


2. Create and Activate a Virtual Environment

A virtual environment isolates your project dependencies.

Run as root

sudo su

Create the environment (e.g., named ds_env) and Activate the environment

python3 -m venv ds_env
source ds_env/bin/activate

You’ll notice your terminal prompt changes to include (ds_env), indicating you are inside the virtual environment.


3. Install Pandas, Scikit-learn, matplotlib and Jupyter

With the virtual environment active, use pip to install the required libraries. This command installs all three libraries in one go, along with their dependencies.

pip install pandas scikit-learn matplotlib jupyter seaborn

Note: Scikit-learn is installed using the package name scikit-learn.


4. Verify Installation

You can quickly check the installation by starting a Python interpreter and attempting to import the libraries:

Create a Python file (vi test.py) and type the following.

import pandas as pd
import sklearn
import jupyter # This will check if the jupyter command is available
print(pd.__version__)
print(sklearn.__version__)

Then run the file by Python.

python test.py

5. Run Jupyter Notebook

You can now launch the Jupyter Notebook from your activated virtual environment:

jupyter notebook --ip=0.0.0.0 --port=80 --allow-root

This command will usually open a browser window to your notebook interface (or provide a URL to paste into your browser).

6. Titanic Homework

please refer to this link. Pandas titanic homework

Leave a Reply