VOOZH about

URL: https://thenewstack.io/configure-a-kubeflow-jupyter-notebook-server-for-data-preparation/

⇱ Configure a Kubeflow Jupyter Notebook Server for Data Preparation - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2021-07-23 11:11:01
Configure a Kubeflow Jupyter Notebook Server for Data Preparation
tutorial,
Kubernetes

Configure a Kubeflow Jupyter Notebook Server for Data Preparation

The current installment of this Kubeflow tutorial series focuses on building a Notebook Server for the data scientists to convert a set of images into a dataset ready to be used by the ML engineers to build and train a model.
Jul 23rd, 2021 11:11am by Janakiram MSV
👁 Featued image for: Configure a Kubeflow Jupyter Notebook Server for Data Preparation
This tutorial is the latest installment in an explanatory series on Kubeflow, Google’s popular open source machine learning platform for Kubernetes. Check back each Friday for future installments.

In the last part of this series, we created the shared PVCs to enable collaboration among data scientists, machine learning engineers, and the DevOps team. Before that, we also built CPU and GPU-based container images for launching Jupyter Notebook Servers in Kubeflow.

Next, we will leverage the storage volumes and container images to build a simple machine learning pipeline based on three independent Notebook Servers. Each environment focuses on a specific task of data preparation, training, and inference.

👁 Image

This series aims not to build an extremely complex neural network but to demonstrate how Kubeflow helps organizations with machine learning operations (MLOps).

The current installment of this tutorial series focuses on building a Notebook Server for the data scientists to convert a set of images into a dataset ready to be used by the ML engineers to build and train a model.

We will start by uploading the ZIP file containing the images of cats and dogs from the popular Kaggle competition dataset. By the end of this tutorial, we will have two CSV files containing the train and test datasets path.

Make sure you have the shared PVCs created and visible in the Kubeflow dashboard. These PVCs will be mounted in the Notebook Server pods to write shared artifacts such as the dataset and models.

👁 Image

Let’s create a Notebook Server based on the Jupyter environment from the CPU-based container image created in the previous part of this tutorial. The custom container image has all the required Python modules to prepare and process the dataset.

From the Notebooks section of the navigation bar, click on the new server.

Give a name of your choice to the Notebook Server and choose the custom image option to provide the name of the Docker image built for data preparation. Depending on the available resources, allocate the number of CPUs and RAM. We don’t need a GPU for this environment.

👁 Image

Add a volume needed to create the personal workspace for the Notebook Server. This becomes the home directory of the user. For the data volumes, we will mount the existing shared volume, datasets created earlier. Processed data would be stored in the directory backed by this volume.

👁 Image

When you are ready, click the launch button to provision the Notebook Server. It may take a few minutes for the environment to become ready.

👁 Image

Behind the scenes, Kubeflow launched a Kubernetes statefulset based on the custom container image in the kubeflow-user-example-com namespace.

👁 Image

Let’s inspect the volumes section of the pod to verify if the volumes are mounted correctly.

👁 Image

Switch back to the Kubeflow dashboard and click on connect to access the Notebook Server. You should see the datasets directory in the environment.

Let’s get the raw dataset into the environment. Download train.zip file from Kaggle’s Dogs vs. Cats competition.

👁 Image

Create a directory called raw under the datasets directory, and upload the downloaded train.zip into it. Since the file is above 500MB, it may take a while to upload it.

👁 Image

We are now ready to process the raw data and turn it into a dataset.

Download the Jupyter Notebook from GitHub repository and upload it to the root directory of the Notebook Server.

👁 Image

Launch the Jupyter Notebook and run each cell to start processing the dataset.

We import the required Python modules already installed in the custom container image.

import pandas as pd
import matplotlib.pyplot as plt
import random
import os

from matplotlib import pyplot
from matplotlib.image import imread

Next, we will unzip the raw dataset and inspect it.

!mkdir -p datasets/dogs_vs_cats
!unzip -j -o datasets/raw/train.zip -d datasets/dogs_vs_cats/

👁 Image

Let’s inspect the dataset by accessing the first few images from each class — dogs and cats.

folder = 'datasets/dogs_vs_cats/'

for i in range(9):
 pyplot.subplot(330 + 1 + i)
 filename = folder + 'dog.' + str(i) + '.jpg'
 image = imread(filename)
 pyplot.imshow(image)
pyplot.show()

👁 Image

We will now parse the files in the directory and generate a list for each category.

from os import makedirs
from os import listdir
from shutil import copyfile
from shutil import move
from random import seed
from random import random

train=[]
val=[]

dataset_home = 'datasets/dogs_vs_cats/'
seed(1)
val_ratio = 0.25

src_directory = 'datasets/dogs_vs_cats/'
for file in listdir(src_directory):
 category='cat' if file[0:3]=='cat' else 'dog'
 if random() < val_ratio:
 val.append([src_directory+file,category])
 else:
 train.append([src_directory+file,category])

We now have two lists – train and val – containing the path to the files from each category. Let’s take the help of Pandas library to turn them into CSV files.

import pandas as pd
train_df = pd.DataFrame(train, columns=['filename','category'])
train_df.to_csv('datasets/dogs_vs_cats-train.csv')

val_df = pd.DataFrame(val, columns=['filename','category'])
val_df.to_csv('datasets/dogs_vs_cats-val.csv')

At this point, the datasets directory has two CSV files that act as the training and validation dataset for the model we build in the next section.

With the dataset in place, we are all set to launch the training environment to build and train a convolutional neural network to classify the images. Stay tuned for the next part, which focuses on training.

TRENDING STORIES
Janakiram MSV (Jani) is a practicing architect, research analyst, and advisor to Silicon Valley startups. He focuses on the convergence of modern infrastructure powered by cloud-native technology and machine intelligence driven by generative AI. Before becoming an entrepreneur, he spent...
Read more from Janakiram MSV
SHARE THIS STORY
TRENDING STORIES
TNS owner Insight Partners is an investor in: Docker.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.