Skip to article content

Neural Networks

Back to Article
Ways to run Python (Tutorial)
Download Article

Ways to run Python (Tutorial)

Four ways to run Python on Google servers through Colab, Your laptop or on briges2.psc.edu

Method 1: Directly on Windows on your machine

  1. Install Python 3.10 from python.org

  2. Install VSCode from app store

  3. Install Python extension in VSCode

Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.

ext install ms-python.python

Method 4: On Bridges2.PSC.EDU

  1. An ACCESS ID for you has been created. Look for an email from [email protected] with subject “ECE 490/590 Access ID created”

  2. Follow the new user instructions

  3. Login to allocations.access-ci.org and click on “My ACCESS” > “Edit Profile”

  1. Scroll down to the bottom to find “Resource Provider Site Usernames”, specifically the Username corresponding to Pittsburgh Supercomputing Cluster. Note down that username. We will be using that username going forward.

  1. Set your password using the PSC Password Change Utility

Running Jupyter on PSC with SLURM

  1. Follow next set of instructions to run jupyter on PSC with SLURM

Method 2: WSL (Windows subsystem for Linux) on Windows on your machine.

  1. Install PowerShell on Windows Installing PowerShell on Windows

  2. Install Windows Subsystem for Linux

wsl --install
  1. List the Ubuntu versions available to be installed

wsl --set-default-version 2
wsl --list --online
  1. Install Ubuntu 22.04

wsl --install -d Ubuntu-22.04
  1. Launch wsl: Press Windows, search wsl

Within WSL

In WSL>Ubuntu-22.04 python comes pre-installed.

  1. Launch WSL

  2. Type python3, press enter

  3. Enter any python code

print("hello world!")

Press enter.

Within WSL as a file

  1. Launch WSL

  2. Create a text file using notepad or your favorite editer. Enter any python code within the file.

print("hello world!")

Save the file as first.py

  1. From the terminal run the python script first.py

user@machine:~$ python3 first.py
hello world!

Install Jupyter lab

  1. Launch WSL

  2. Install pip

user@machine:~$  sudo apt install python3-pip
  1. Install Jupyter lab using pip

user@machine:~$  pip3 install --user jupyterlab
  1. Run Jupyter lab

user@machine:~$  jupyter lab --ip $(hostname -I)
  1. Open the URL printer on the screen with the token in a browser of your choice.

  2. Click on Notebook > Python 3 > ipykernel

  3. Enter any python code

print("hello world!")

Press Ctrl+Enter

Easiest: Method 3: Google colab

  1. Open https://colab.research.google.com/#create=true

  2. Enter any python code

print("hello world!")

Press Control+Enter to run

  1. The colab notebooks are saved in your Google drive > Colabs. You can organize them by clicking on File > Move

Terms

job
A unit of computational task that the cluster is asked to complete.
scheduler
A software framework that decides how to allocate jobs to available resources (computers/nodes). Examples include SLURM, PBS TORQUE, kube-scheduler.
nodes
Computers in a cluster setting.