Getting MPI4py and MPI tutorial- Supercomputing and Parallel Programming in Python and MPI 1

sentdex · Beginner ·🛠️ AI Tools & Apps ·12y ago

Key Takeaways

This video tutorial covers the installation and testing of MPI4py, a Python implementation of the Message Passing Interface (MPI) for supercomputing and parallel programming, using tools such as Putty, SCP, and MPIRUN on a Raspberry Pi and other nodes.

Full Transcript

hello and welcome to the next step in supercomputing SLP parallel programming slh high performance Computing uh in the previous videos I showed you all how you could build your own extremely cheap supercomputer out of raspberry pies to do these videos you won't have to have built that same supercomputer so this is just going to be super Computing with python uh and NPI 4 Pi it just so happens I'm going to be doing it on my Raspberry Pi two node superc computer you can do it on anything you actually don't even need more than one node you can kind of do it pseudo with one node but just reference it multiple times um so yeah so anybody can go through this we won't be doing calculations uh at least at the beginning that are so large that uh there's any necessity to use a supercomputer for them so if you did follow along with the how to build a supercomputer of Raspberry Pi's tutorial series you've got an extremely simple example of MPI and supercomputing at work but chances are you're feeling rather fuzzy since we really just did some setting up some installing of things uh and you're probably longing for a better understanding of what's going on if you didn't follow the previous series basically all we did was we just used raspberry pies uh and used a simple message passing interface uh script that calculated Pi but we didn't do any of the program in in there uh so it's a lot more enjoyable if you do it yourself so in order to continue along we're going to require a programming language to do it ourselves most often you're going to see people use like C++ or Fortran being used for super Computing and I'm going to mix it up a bit I I personally enjoy python so that's what we're going to be using for it Python's also very Noob friendly it's what you call an upper level language um so you don't really need to know too much about inner work works and also uh the terminology syntax and all of that it's just so simple to use C is not and Fortran is really limited to uh numbers basically um definitely limited compared to what you can do with python so python it is so next up we're going to need to decide on what NPI implementation that with python that we want to use so for that we're going to use NPI for pi so what we're going to do is we're going to go ahead and install and test NPI for pi in this video uh it's going to be eerily similar to the installation of npic and testing npic so if you did do that uh you will still want to follow along because basically what we're doing now is instead of using npic and for Tran all that we're going to be using uh python so uh let's go ahead and get started so if you're if you have a Raspberry Pi you've got python already installed there might there's some Linux in instances you're not going to have python pre-installed I'm assuming everyone here has python 27 pre-installed on the raspber berry pie uh I'm also going to be opening up everything in putty but then I'll also probably just use SCP to move files over um as I edit them so I'm going to edit them instead of using the editor in um you know in Nano let's say instead of using that I'm going to use the editor on my main computer so we get uh colored text and all of that you can do it however you want if you want to edit it straight into your Pi uh that is fine too so I'm going to open up my uh putty instances here extra putty and for me uh my one my my main node is this your main node address might be different but whatever your uh local address is if you don't know what your local address is you'll have to um I have config it but um I know what mine is you could also have yours hooked up to a monitor or something but I'm going to use putty um so I'm going to go in now I'm going to log in all right I'm in on my master node now I'm going to log in on my uh worker and again 192 1680 and this one was [Music] 21 okay so now I'm logged in on both of them and so now what we're going to want to do is we're going to want to uh install the uh MPI for pi on here um and we need to install it on both of the machines so and every node that's going to run NPI for pi it obviously has to be installed there so the first thing that we're going to want to grab is we're going to want to do pseudo app get install python MPI 4 Pi run that and I'm going to do the same thing over here AP get install python np4 pi and so we'll be installing these do want to do that yes and yes and so we'll wait for all this uh to install this one's pretty quick you won't have to wait for how long uh doing the whole NPI on the other if anybody came from the other tutorials where we were doing it it took a really long time and basically after we're done with this we're going to want to we're still kind of following uh this would be like the last part where we kind of follow the same structure as that uh University of Southampton paper went through uh so the next thing that we are going to do though is we're going to CD um we're just going to put this in home slpy and we're just going to make a directory there um for NPI for pi that's interesting this one finished before the other one it started first anyway so we are already in that directory but just to make sure yes uh so then we're going to do makeer MPS 4 Pi enter and now we want to CD into NPI 4p and now what we want to do is do uh get HTTP colon slmi 4. gooogle code.com filmi 4 pi- 1.3 tar.gz and in fact I'm going to copy this for myself you son of a let's see oh my goodness anyway there we go all right so we'll get that I'll do the same thing here uh cool so now we have it now the next thing we want to do is tar xfz MPI 4 Pi Dash uhoh oh I downloaded I make the directory whoops well I'll just delete that later we'll do makor MPI 4 Pi CD MPI 4 Pi uh now we want to do the W get there done and now we want to run tar xfz MPI 4i- 1.3 tar.gz and then we want to do the same thing here I we didn't do it I don't think no so we want to do tar xfz MPI 4 pi- 1.3 tar.gz same thing again this Pi is like significantly faster than the other one okay so now back on to the master node LS there is our MPI 4- or MPI you get what I'm trying to say MPI 4 pi- 1.3 so let's LS MPI 4i- 1.3 and in here you should see that there's a demo so we need to CD um CD MPI 4 Pi 1.3 LS CD into demo and in here you should see LS this where is you hello.py that's just a very simple script that we're going to run to just make sure it works uh but don't worry I know like I said this feels like the same thing we just did before we just want to test the installation uh and then from there we'll actually uh start writing our own scripts and explaining why this works and all that so to run this what we're going to do is we're going to use mpir run. openmpi and then number uh I think it's number of processors uh we're going to say two and then this is machine file and now you're going to specify the path to the machine file now if you followed us before we already made a machine file and our machine file is located in slome SLP SL mpor testing SL machine file then we're going to use Python to run hello world. hit enter and here we have hello world I'm process Z of two on Master 001 hello world I am process of two on node 002 so uh if you didn't have if you never made your machine file I'm just going to show you what a machine file looks like it's quite simple uh so that was where ours is located so hold on here let me go back here and I'm going to [Music] CD son Beach okay I don't know why it's not letting me do that anyway uh NPI testing slash actually let's just and name machine file so this is the machine file basically the machine file is just a file uh with listed out local IP addresses so you know the M Master node is you know2 the worker node is21 and so on that's all the machine file is just a list of uh IPS so if you don't oh man so if you don't have one uh what you're going to want to do is just make one real quick you can put put it wherever you want uh it might be useful to put it in the same path just in case down the road you're kind of confused on a path or something but for the most part uh what we're going to be doing now is scripting so you know what you put in this line will be the same pretty much every time you're just using the same line to run the script right at the end right uh this is the script here so you might as well just copy and paste whatever line you use so uh as long as you've got it spitting out that information then you've got it going right so if you have any questions or comments leave them Below in the next video what we're going to be doing now is learning how to use MPI for pi so we're going to start scripting our own Python scripts uh basically to do what this one just did here and so we're going to uh start like that and then we'll continue getting into it so um if you're new to you know supercomputing and all of that you know the MPI is just message passing passing interface that's literally all we want to do here is just pass messages uh so it turns out that it's actually pretty easy to do that with NPI for pi um and from there you can do a whole lot of really cool stuff so hopefully that sounds interesting to you guys as always thanks for watching thanks for all the support and the subscriptions and until next time

Original Description

Supercomputer Playlist: http://www.youtube.com/watch?v=13x90STvKnQ&list=PLQVvvaa0QuDf9IW-fe6No8SCw-aVnCfRi&feature=share In this video, we download and testing MPI4Py, which is an implementation of MPI (Message Passing Interface) for use with Python. Once we're certain that the installation works, the fun can begin. download link: $ wget http://mpi4py.googlecode.com/files/mpi4py-1.3.tar.gz http://seaofbtc.com http://sentdex.com http://hkinsley.com https://twitter.com/sentdex Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from sentdex · sentdex · 0 of 60

← Previous Next →
1 Matplotlib Python Tutorial Part 1: Basics and your first Graph!
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
2 Python Encryption Tutorial with PyCrypto
Python Encryption Tutorial with PyCrypto
sentdex
3 Python's Logging Function
Python's Logging Function
sentdex
4 wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
5 wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
6 wxPython Programming Tutorial 3: Menu Bar and Menu Button
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
7 wxPython Programming Tutorial 4: Panels
wxPython Programming Tutorial 4: Panels
sentdex
8 wxPython Programming Tutorial 5: User Input Saved To Variables
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
9 wxPython Programming Tutorial 6: Multiple Choice Input
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
10 wxPython Programming Tutorial 7: Adding Static Text and Colors
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
11 wxPython Programming Tutorial 8: Custom Button Images
wxPython Programming Tutorial 8: Custom Button Images
sentdex
12 wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
13 Basic PHP Tutorial 13: Multi-dimensional Array
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
14 Basic PHP Tutorial 15: Functions and Global Variables
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
15 Basic PHP Tutorial 12: Associative Array
Basic PHP Tutorial 12: Associative Array
sentdex
16 Basic PHP Tutorial 14: Foreach loop
Basic PHP Tutorial 14: Foreach loop
sentdex
17 Basic PHP Tutorial 16: Include and Require
Basic PHP Tutorial 16: Include and Require
sentdex
18 Basic PHP Tutorial 7: Assignment, comparison and Logical operators
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
19 Basic PHP Tutorial 4: Variables and Comments
Basic PHP Tutorial 4: Variables and Comments
sentdex
20 Basic PHP Tutorial 11: Arrays part 1, basic array
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
21 Basic PHP Tutorial 6: If else and else if conditionals cont'd
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
22 Basic PHP Tutorial 1: Intro to PHP
Basic PHP Tutorial 1: Intro to PHP
sentdex
23 Basic PHP Tutorial 3: HTML with PHP
Basic PHP Tutorial 3: HTML with PHP
sentdex
24 Basic PHP Tutorial 9: While Loop
Basic PHP Tutorial 9: While Loop
sentdex
25 Basic PHP Tutorial 10: Switch Statement
Basic PHP Tutorial 10: Switch Statement
sentdex
26 Basic PHP Tutorial 2: Print and Echo
Basic PHP Tutorial 2: Print and Echo
sentdex
27 Basic PHP Tutorial 5: If else and else if conditional statements
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
28 Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
29 Basic PHP Tutorial 17: User Input Form Example / String Manipulation
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
30 Basic PHP Tutorial 18: HTML Entities and forms cont'd
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
31 Basic PHP Tutorial 19: Finding words in strings
Basic PHP Tutorial 19: Finding words in strings
sentdex
32 Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
33 Basic PHP Programming Tutorial 22: Hashing part 2: salting
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
34 Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
35 Basic PHP Programming Tutorial 21: MD5 Hashing For Security
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
36 Basic PHP Programming Tutorial 24: String similarity
Basic PHP Programming Tutorial 24: String similarity
sentdex
37 Basic PHP Programming Tutorial 25: Time and Time stamps
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
38 Basic PHP Programming Tutorial 26: Die and Exit
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
39 Basic PHP Programming Tutorial 27: MySQL Databases Part 1
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
40 Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
41 Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
42 Basic PHP Programming Tutorial 30: MySQL database in Use
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
43 Django Tutorial Web Development with Python Part 1: Installing Django
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
44 Python Tutorial: File Deletion and Folder Deletion / directory deletion
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
45 Python Tutorial: How to Rename Files and Move Files with Python
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
46 3D Graphs in Matplotlib for Python: Basic 3D Line
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
47 3D Plotting in Matplotlib for Python: 3D Scatter Plot
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
48 3D Charts in Matplotlib for Python: Multiple datasets scatter plot
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
49 Sikuli Tutorial 1: Visually programming in python!
Sikuli Tutorial 1: Visually programming in python!
sentdex
50 Sikuli Tutorial 2: Program visually in python!
Sikuli Tutorial 2: Program visually in python!
sentdex
51 Sikuli Tutorial 3: Program visually in python!
Sikuli Tutorial 3: Program visually in python!
sentdex
52 3D Bar Charts in Python and Matplotlib
3D Bar Charts in Python and Matplotlib
sentdex
53 3D Plane wire frame Graph Chart in Python
3D Plane wire frame Graph Chart in Python
sentdex
54 Raspberry Pi Part 1 Introduction
Raspberry Pi Part 1 Introduction
sentdex
55 Raspberry Pi Part 8: First Download and Update! (Firmware)
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
56 Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
57 Raspberry Pi Part 11: Remote Desktop
Raspberry Pi Part 11: Remote Desktop
sentdex
58 Twitter Analysis: How to rank a user's influence
Twitter Analysis: How to rank a user's influence
sentdex
59 GPIO Tutorial for Pi Part 2 - Programming the GPIO
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
60 GPIO Tutorial for Raspberry Pi Part 1 - Setting up
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex

This video teaches how to install and test MPI4py, a Python implementation of MPI, for supercomputing and parallel programming, and how to use it to create a cluster with multiple nodes. It covers the use of various tools such as Putty, SCP, and MPIRUN, and provides a practical example of running a simple script to test the installation.

Key Takeaways
  1. Install MPI4py on a Raspberry Pi
  2. Test MPI4py on a Raspberry Pi
  3. Log in to a master node and a worker node using Putty
  4. Use SCP to transfer files between nodes
  5. Install Python MPI4Py on master and worker nodes
  6. Create a directory for MPI4Py
  7. Make a machine file
  8. Configure MPI4Py using MPIRUN
  9. Run a simple script to test the installation
💡 The machine file is used to specify the nodes in a cluster, and MPI is a message passing interface used for supercomputing and parallel programming in Python.

Related AI Lessons

Up next
I Asked ChatGPT to Apply to 500 Jobs (8 Interviews in 48 Hours)
Sabrina Ramonov 🍄
Watch →