From Scratch Model part 1: Getting set up with a free cloud machine learning environment in six easy steps

paperspace gradient
cloud computing
beginner
Author

Mike Gallimore

Published

February 8, 2023

This is part 1 of Mike’s model from scratch presentation. This was a group coding session from no-code to a working model. This notebook walks through how to get set up with a free cloud computer capable of running machine learning code on a GPU.

Getting set up with Paperspace Gradient in six easy steps

Introduction

GPU vs. CPU

  • CPUs process information in series, and are very powerful. GPUs divide tasks across multiple processing units, and process them in parallel.
  • On a GPU, each processing unit is less powerful than a single processing unit of a typical CPU.
  • Some operations such as displaying pixels on a screen can run faster on a GPU if they are easily divided into a parallel process.

Why do we need a GPU to run deep learning models?

(Short answer: You don’t! but it’s much faster because of parallel processing on a GPU)
- Deep learning models are built using neural networks. Training of a neural network involves calculating parameters and activations at each node of the network. Since each of these operations is fairly small, they’re self similar,and there are many of them, it is more efficient to run these operations in parallel on the GPU.

Why process information on the cloud vs on local machine?

  • Your machine may or may not have a GPU.
  • If you do have a GPU, it is likely that the free GPUs offered by cloud computing platforms are more powerful.
  • Deep learning can require large amounts of data, and transferring this data across internet connections and storing locally can be problematic.
  • Cloud computing lets you get set up and running code more quickly. Personal computers with Linux, windows and Mac would all have different install requirements, which takes a while to work through.

Why paperspace gradient?

  • There are other options including Google Colab, Kagggle, and running locally on your machine. This is just one option. One of the advantages of Gradient is that it lets you run jupyter notebooks in their native form, whereas other platforms modify the user interface a little.

1. Set up an account at paperspace

http://www.paperspace.com

2. Sign in and click ‘Create A Project’


Choose any name

3. Create A Notebook

4. Choose a runtime and a GPU instance

  • We’ll be choosing Start From Scratch.

This will create a jupyter notebook with some machine learning specific libraries already installed. All of the other runtimes you can see can still be installed if we select ‘start from scratch’, and we’ll see how to do this for the fast.ai runtime which we’ll use to train our model.

  • Under select a machine choose Free-GPU

If this option isn’t available then choose free CPU - we can always change it later

screenshot

5. Switch over to Jupyter Lab by clicking the orange circle on the left.

6. Then choose a Python 3 Notebook

jupyter lab

Great! You’ve just set up a remote machine on a cloud server, with access to powerful GPU processors, for free!

IPython

  • You’re now in an interactive shell.
  • The file you’re in is called Untitled.ipynb.
  • ipynb means interactive python notebook.
  • Commands typed into the cell will be interpreted by a python interpreter if you press SHIFT + RETURN. Try it!
  • Try typing some of the following commands then executing them using shift + enter:
1 + 1
2
x = 4
x * 2
8

The above cells executed python code using a python interpreter.

We can also execute code on the computer’s bash terminal: try these

!ls

The ! sends the code to the computer’s bash shell interpreter instead of the python interpreter.

!ls ..
!ls ../..

Markdown

The type of cell can be changed from a code cell into a markdown cell where we can write notes, display images, links etc.

Try hitting esc, then pressing m. Cell contents will now be displayed as markdown.

To get back to code mode, hit esc, then press y

Explore the environment:

Try some of the following commands one by one to see what happens.

!ls
!ls ..
!python --version !pip install torch
!pip list

import numpy as np

np.random.randn(6)

Conclusion

Getting set up with cloud computing services can seem daunting at first, but it’s actually pretty straightforward.

You can run all the same code on your laptop or on any other notebook hosting service.

In the next section we’ll write code in python and take advantage of some libraries which will let us train a deep learning model using the GPU we now have access to.