Gradient Community Notebooks allow users to create, run, and share Jupyter notebooks on free GPUs. In this post Gradient Community Notebooks will be introduced and the steps to get started will be closely discussed, so you can easily create a free Jupyter notebook on a GPU or CPU and share it with the public.
- Getting started with Gradient
- Gradient Community Notebooks
- Choosing a container
- Choosing a machine
- Notebook options
- Managing notebooks
- Opening your notebook for the first time
- The left-side toolbar
- File explorer
- Sharing files and folders
- Sharing notebooks
- Uploading and downloading files
- Reading and writing files
- Exporting notebooks
Let's get started.
Bring this project to life
Getting Started with Gradient
Gradient is Paperspace's platform for building machine learning (ML) and deep learning (DL) projects. It helps you through the entire pipeline of building and deploying ML/DL models. Notebooks come with a pre-configured environment to eliminate any tooling headaches. In a few clicks you can get up and running with popular libraries like Keras, TensorFlow, PyTorch, and Scikit-Learn.
- Your Google account
- Your GitHub account
- Regular e-mail registration
After logging in you'll come to the Console page. There are two main products to get started with: Gradient and Core. In this post we're focusing on Gradient. This product offers tools for building ML/DL projects, from exploration to model deployment.
Before getting started with Gradient and its free services, let's check out your profile. At the top-right of the console page you can find your profile logo (which is initially set to a default icon). Just hover over the icon and click the
Profile option. There you can see basic information about your account. The next figure shows my profile page.
At the bottom-left of the page there is an
EDIT PROFILE button, which you can click to enter your details. You can also click the profile photo to change it. Your
User Handle will be used in your account page URL. I used
ahmed, and thus my Paperspace profile URL is https://www.paperspace.com/ahmed. Finally, click the
SAVE button to save your details.
Now let's go back to the console page. There's a link at the top-right corner of the page to forward you to the console. You can always find the console page at https://www.paperspace.com/console.
This post will closely discuss using Gradient Community Notebooks, which are introduced in the next section.
Gradient Community Notebooks
In October 2019 Paperspace introduced the beta version of Gradient Community Notebooks. These allow you to create Jupyter notebooks that run on free CPU and GPU instances. After you created an account (according to the instructions in the previous section), you can log in and start creating notebooks for free.
- Run: Create and run a
- Train: Create a
Gradient Projectto train your model.
- Deploy: Push a model to production using
According to the documentation, a Gradient Project is defined as follows:
A Gradient Project is a workspace for you or your team to run Experiments and Jobs, store Artifacts such as Models, and manage Deployments (deployed models).
Because we are interested in creating a Jupyter notebook, we'll click on the Run A Jupyter Notebook option which will redirect you to this page. You could also just click on Notebooks when you hover over Gradient on the toolbar on the left.
On the notebook page we find three steps for creating a Jupyter Notebook:
- Choose Container
- Choose Machine
- Notebook Options
We are going to discuss each of these 3 steps in the next 3 sections.
Paperspace Gradient runs Jupyter notebooks inside a "container", which is an environment prepared with all of the required dependencies for running the notebook. There are a total of 18 pre-configured containers available, and you can also use a custom one. Visit this page for more information about the supported containers.
Out of these 18 containers there are 7 recommended due to their popularity. These are:
If you're interesting in using or building a custom container, check out this guide for more information.
After you select the container, we'll need to choose a machine.
The next figure shows the list from which you can choose a machine for running your notebook. There are a total of 16 instances to choose from that vary in power and cost. For more information about the available instances, check out this page.
Out of these 16 machines, there are 3 FREE instances available. These are:
- Free-CPU, offering 2 vCPU with 2 GB of RAM
- Free-GPU+, offering an NVIDIA M4000 GPU with 8 vCPUs and 30 GB of RAM
- Free-P5000, offering an NVIDIA P5000 GPU with 8 vCPUs and 30 GB of RAM
The free instances also include 5 GB of persistent storage. The free instances share three limitations:
- Notebooks will automatically shut down after 6 hours per session
- Only 1 notebook can run at a time
- The notebook will be set to public
Despite the fact that the notebook will shut down after 6 hours, there is no limit to the number of sessions you can start. You can simply start a new session after the 6 hours expire. To prevent losing progress made from processes that are running when the 6 hour limit is reached, you can split processes (if possible) across different sessions. You might also save your progress to the persistent storage before the 6 hours session ends, and then load it again in the next session to continue where you left off.
If your process must be executed for more than 6 hours without interruption, then you should probably upgrade your subscription.
For now, select whichever free instance appeals to you (for more information about the free instances, check this page). Now we'll look at the third and last step to creating a Gradient Community Notebook: setting the notebook options.
The last step to creating a notebook is to specify some options about it according to the next figure. The two options are:
- Auto-shutdown limit
- Whether the notebook is public or private
These 2 options are not editable for the free instances, as you can see in the next figure. The notebook running on a free instance will always be
public and shuts down automatically after
6 hours. For a paid instance, you can freely change both.
Now just click on the
CREATE NOTEBOOK button at the bottom-left corner of the page to create your notebook. The next section discusses how you can use it.
After clicking the
CREATE NOTEBOOK button, you will be directed to this page https://www.paperspace.com/console/notebooks where you can manage your notebooks. The notebook will take a few seconds in the
Pending state and then the state changes to
Running indicating it is working properly according to the next figure. You can find the following details about the notebook:
- Notebook owner name.
- Notebook name. A default name is assigned to the notebook which is
My Notebookbut you can click on it and change it to another name. It just takes a few seconds for the name to be changed successfully.
- Container name. In this case, the selected container is the
- The machine type selected in the
Choose Machinestep. In this case, I selected the Free-GPU+ machine that offers an NVIDIA M4000 GPU.
- Notebook ID which is available directly behind the machine type. In this case, the ID is nlc7r4dn.
- Creation date of the notebook and the running time.
- Status which should be
Runningto indicate the notebook is running properly.
- A number of actions.
When the Status of the notebook is Running, you can find the link copy notebook token. Clicking it copies a token associated with the notebook. Here is an example of a token
2ac47522e520429189b9ba572cbd5e1582b4b3942e138c02. This token is used to get a shareable link of the files and folders of the associated storage to the notebook. So, it is important to not make it publicly available.
Within the actions, you can click the
SHARE button to share the notebook. The window resulting from clicking such a button is shown below. At the end of the window, you can click the link to copy the public URL of the notebook which in this case is https://www.paperspace.com/ahmed/notebook/pr1qzg6wz. Being public, anyone with the link can view the notebook without even creating a Paperspace account. Just visit its link and enjoy it! For more information about viewing a notebook, visit this page.
From the Actions, you can click the STOP button to stop the notebook. The notebook state will be changed from Running to Stopped according to the next figure. After being stopped, some additional actions will appear which are START, FORK, and DELETE. Thus, you cannot fork or delete a notebook while its state is Running. Note that the notebook name is changed to TestGradientNotebook.
You can click the START button to run the notebook. By clicking such a button, a new window appears in which you can change the following:
- Notebook Name
- Instance Type
- Auto-Shutdown Limit which you cannot change while selecting a free instance.
At the end of such a window, just click the START NOTEBOOK button to start the notebook. After the notebook's state changes to Running, you can open it either in the classic or the beta versions. The next section discusses the next steps after the notebook is opened for the first time.
Opening the Notebook for the First Time
The next figure shows the result after opening the notebook in the beta version for the first time. Because it is the first time to open the notebook, a launcher will be opened asking to select wither you want to open a notebook, console, terminal, and so on. In this case, we are interested in creating a Python notebook and thus the first option is selected. Note that only Python 3 is supported.
The next figure shows the result after the notebook is created. It is given the name
Untitled.ipynb by default.
There is a toolbar at the left side of the previous window which is discussed in the next section.
Left Side Toolbar
On the left side of the main window, there is a toolbar in which the following 5 icons exist. The icons in order from up to down are as follows:
- File Explorer: View the storage files and folders.
- Running Terminals & Kernels: View and shutdown the Python notebooks and terminals.
- Commands: A list of commands for creating and managing notebooks. For example, exporting the notebook into PDF or markdown, shutdown the notebook, change font size, clearing outputs, and more.
- Notebook Tools: This icon appears when a notebook is opened.
- Open Tabs: View the list of the currently open notebooks.
You can easily hover over an icon to see its name.
By clicking on any of such icons, its associated window will change state from hidden to unhidden and vice versa. The next section discusses the File Explorer.
For the File Browser icon, it could be used for navigating through the associated storage to the notebook. There are 2 folders and the Jupyter notebook file. The first folder named datasets has a number of ML/DL datasets. The folder's content is listed in the next figure. You can navigate through the folders easily and open the files.
At the top of the File Explorer, there are 4 icons at the top of the window according to the next figure. The 4 icons in order from left to right are:
- New Launcher: Opens the launcher that was found the first time the notebook is opened for creating a new document.
- New Folder: Create a new folder in the current directory.
- Upload Files: Upload files in the current directory.
- Refresh File List: Refresh the file list to see the latest changes.
We can open the launcher again and open a console. The next figure shows that there are 2 currently active tabs. The first one for the notebook and the second one for the console.
You can also right-click a file for opening a list of additional options. The next figure shows the result after right-clicking the notebook file. You can find many options including open, delete, copy, cut, download, and rename. You can also right-click a folder for more options like that.
In the previous list, there is an option named Copy Shareable Link to be discussed in the next section.
Sharing Files and Folders
It is possible to get a shareable link for a file by clicking the Copy Shareable Link option. Here is the shareable link of the notebook file: https://newq9nu0.gradient.paperspace.com/lab/tree/Untitled.ipynb. Note that the file name appears in the link and thus the link changes according to the current name.
The next figure shows the result if someone with the link opens it. if you already have the token, just paste it and click the
Log in button. After that, you can view the file or the folder associated with that link. This is super cool as it makes sharing files to others very easy!
The next section discusses sharing the notebooks with their public URL.
By giving the public URL of the notebook to others, they will not be able to either edit or run the notebook but they will just be able to see the last stopped version of the notebook as an HTML page. The next figure shows the result after the notebook URL https://www.paperspace.com/ahmed/notebook/pr1qzg6wz is visited publicly.
According to Paperspace documentation, here is how things work for viewing a notebook that is currently running.
When you visit a Community Notebook, you'll always see the last Stopped version of that notebook. So if the notebook owner is currently running it, you'll see a message that says:
Note: You are viewing the static version of this notebook. Run the notebook to see the interactive live version.
The next section discusses uploading files to the notebook
Uploading and Downloading Files
Clicking the Upload Files icon in the File Explorer window allows the user to select files from the local storage and upload it to the notebook storage. The next figure shows that an image is uploaded to the current directory and opened in a new tab.
Note that the file is uploaded at the root directory of the notebook storage. According to Paperspace documentation, here is a note about the
Anything you store in the
/storagedirectory will be accessible across multiple runs of Experiments, Jobs, and Notebooks in a given storage region.
Thus, we can move the files to this directory for taking advantage of sharing it across different notebooks. You can simply move it to the
/storage directory by either cutting the file and pasting or by simply dragging and dropping the file within the
You can also download files easily. Just right-click the file and click the Download option as explained in the next figure.
In the next section, we will discuss reading and writing files.
Reading and Writing Files
In this section, we are going to write code into a notebook cell and see how to run it. Simply, open the notebook file and write a Python code. In the next figure, a print statement is entered into a cell. To run it, just click the Run button icon marked with a red circle.
To access a file within the code, firstly you need to get its path. To do so, just right-click the file and click on the Copy Path option. For the previously uploaded image file named
image.png, after being moved into the
/storage directory, its path is
/storage/image.png. Using this path, we can read and display the image according to the next code.
import matplotlib.image import matplotlib.pyplot im = matplotlib.image.imread("/storage/image.png") matplotlib.pyplot.imshow(im) matplotlib.pyplot.show()
The next figure shows the result of executing the previous code.
Similarly to reading files, you can also write files by specifying a path. The next code divides the read image by 2 and writes it to the
import matplotlib.image import matplotlib.pyplot im = matplotlib.image.imread("/storage/image.png") im = im / 2 matplotlib.pyplot.imshow(im) matplotlib.pyplot.show() matplotlib.pyplot.imsave("/storage/new_image.png", im)
The next figure shows that the image is successfully saved to the
The next section discusses exporting the notebook as a document.
After you finish working, you might be interested in saving a static version of the notebook. You can do that simply in Gradient notebooks. According to the next figure, go to the File menu and click on the Export Notebook As where you can find different options to export the notebook including Markdown, PDF, LaTex, and HTML.
This post discussed how to get started with Paperspace's free Gradient Community Notebooks. We started by introducing Gradient, which is Paperspace's platform for building effortless machine learning and deep learning products and pipelines. It offers different instances and containers packaged with a variety of tools so that users don't get bogged down battling dependencies or tooling issues.
In October 2019, Paperspace added free GPU and CPU instances for launching and sharing Jupyter notebooks for free. This post covered the steps for creating, running, and sharing a free notebook. Some additional features are also discussed, such as sharing files and folders, uploading and downloading files, and reading and writing files to the
By the end of this post, you can easily get started with a free Jupyter notebook running on a GPU or CPU.