{"id":695,"date":"2024-07-12T10:41:33","date_gmt":"2024-07-12T10:41:33","guid":{"rendered":"https:\/\/doctor-dark.co.uk\/blog\/?p=695"},"modified":"2024-07-15T10:40:21","modified_gmt":"2024-07-15T10:40:21","slug":"fear-and-loathing-with-mpirun","status":"publish","type":"post","link":"https:\/\/doctor-dark.co.uk\/blog\/fear-and-loathing-with-mpirun\/","title":{"rendered":"Fear and Loathing with mpirun"},"content":{"rendered":"\n<p>My Raspberry Pi cluster, named &#8220;Oyster&#8221; because of something to do with the Walrus and the Carpenter, had been out of commission for months, so I eventually got to work and tried to set it up from scratch, as an alternative to checking everything over and over again, and failing to find anything wrong. Oyster used to look like this, but the Pi 3s in Lego compatible cases ran too hot. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1536\" height=\"2048\" src=\"https:\/\/doctor-dark.co.uk\/blog\/wp-content\/uploads\/2024\/07\/oyster-1-1536x2048.jpg\" alt=\"\" class=\"wp-image-701\" srcset=\"https:\/\/doctor-dark.co.uk\/blog\/wp-content\/uploads\/2024\/07\/oyster-1-1536x2048.jpg 1536w, https:\/\/doctor-dark.co.uk\/blog\/wp-content\/uploads\/2024\/07\/oyster-1-750x1000.jpg 750w, https:\/\/doctor-dark.co.uk\/blog\/wp-content\/uploads\/2024\/07\/oyster-1-768x1024.jpg 768w, https:\/\/doctor-dark.co.uk\/blog\/wp-content\/uploads\/2024\/07\/oyster-1-1152x1536.jpg 1152w, https:\/\/doctor-dark.co.uk\/blog\/wp-content\/uploads\/2024\/07\/oyster-1-1200x1600.jpg 1200w, https:\/\/doctor-dark.co.uk\/blog\/wp-content\/uploads\/2024\/07\/oyster-1-scaled.jpg 1920w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>At first, I attempted to use my only Pi 4, &#8220;Marvin&#8221;, as the control machine for the four Pi 3s in Oyster, but I got something wrong in the setup, and it didn&#8217;t work. I had been thinking 20 cores would obviously be better than 16, but suspected the two different user names in use might be causing the problem. It probably wasn&#8217;t, as I now think the ssh communication for the cluster is done anonymously. Possibly. Anyway, I changed my mind about 20 cores, when I thought about the other tasks Marvin runs, and how I didn&#8217;t want them slowed down. Sixteen will do. Unless I get some more Pi 3s and add them to the cluster&#8230;<\/p>\n\n\n\n<p>Anyway, I went through all the setup described in Ashwin Pajankar&#8217;s e-book* about Raspberry Pi &#8220;supercomputers&#8221;, again. Twice. I found some online guides, and checked the setup with those, too. I could run programs on the four cores of oyster0, but not on the other three Pis. Eventually, I spotted that I had forgotten to create the file &#8220;known-hosts&#8221; on the controlling Pi. The message passing software, python3-mpi4py, would probably have told me this, if I had run it in verbose mode, but I didn&#8217;t. Still, it now works, and I have a sixteen core Pi cluster running.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"1112\" src=\"https:\/\/doctor-dark.co.uk\/blog\/wp-content\/uploads\/2024\/07\/Screenshot-from-2024-07-12-10-10-29.png\" alt=\"\" class=\"wp-image-697\" srcset=\"https:\/\/doctor-dark.co.uk\/blog\/wp-content\/uploads\/2024\/07\/Screenshot-from-2024-07-12-10-10-29.png 1920w, https:\/\/doctor-dark.co.uk\/blog\/wp-content\/uploads\/2024\/07\/Screenshot-from-2024-07-12-10-10-29-1000x579.png 1000w, https:\/\/doctor-dark.co.uk\/blog\/wp-content\/uploads\/2024\/07\/Screenshot-from-2024-07-12-10-10-29-768x445.png 768w, https:\/\/doctor-dark.co.uk\/blog\/wp-content\/uploads\/2024\/07\/Screenshot-from-2024-07-12-10-10-29-1536x890.png 1536w, https:\/\/doctor-dark.co.uk\/blog\/wp-content\/uploads\/2024\/07\/Screenshot-from-2024-07-12-10-10-29-1200x695.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>I have added a program, running on Marvin, that lights up LEDs to show the state of the Pis in the cluster, and intend to add further blinkenlights to show the activity of each of the sixteen cores.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Program to monitor status of Oyster cluster, displaying up\/down indication.\n#import os\nimport time\nimport subprocess as sp\n\nmachines = &#91;\"oyster0\", \"oyster1\", \"oyster2\", \"oyster3\"]\n\nwhile True:\n    for i in range(len(machines)):\n        machine = machines&#91;i]\n        state  = sp.call(&#91;'ping', '-c', '1', machine], stdout=sp.DEVNULL)\n        \n        if state == 0:\n            colour = \"0 200 0\" # Green means UP\n        else:\n            colour = \"200 0 0\" # Red means DOWN \n            \n        row = \"12 \"\n        if machine == \"oyster0\":\n            column = \"0 \"\n        elif machine == \"oyster1\":\n            column = \"4 \"\n        elif machine == \"oyster2\":\n            column = \"8 \"\n        elif machine == \"oyster3\":\n            column = \"12 \"\n    \n        message = \"set_pixel \" + row + column + colour\n        \n        fp = open(\"\/home\/chris\/ftp\/files\/blinkenlights\" + machine, 'w')\n        fp.write(message)\n        fp.close()\n        \n        time.sleep(1)<\/code><\/pre>\n\n\n\n<p>This code sends a text file to my Unicorn HD server program, which enables more than one program to write to its 256 LEDs, without messing up each other&#8217;s displays.<\/p>\n\n\n\n<p>My plans for further development include improving my set of framework code for running parallel programs on the cluster, and more (or possibly less) importantly, to send messages to Marvin for the blinkenlights.<\/p>\n\n\n\n<p>[* I haven&#8217;t included a link to AP&#8217;s e-book, because it&#8217;s easy to find online, and he is charging far too much for it, while others are giving us the same information free.]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My Raspberry Pi cluster, named &#8220;Oyster&#8221; because of something to do with the Walrus and the Carpenter, had been out of commission for months, so I eventually got to work and tried to set it up from scratch, as an alternative to checking everything over and over again, and failing to find anything wrong. Oyster &hellip; <a href=\"https:\/\/doctor-dark.co.uk\/blog\/fear-and-loathing-with-mpirun\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Fear and Loathing with mpirun&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,7],"tags":[15,13],"class_list":["post-695","post","type-post","status-publish","format-standard","hentry","category-computing","category-raspberry-pi","tag-led","tag-raspberrypi"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/doctor-dark.co.uk\/blog\/wp-json\/wp\/v2\/posts\/695","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/doctor-dark.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/doctor-dark.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/doctor-dark.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/doctor-dark.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=695"}],"version-history":[{"count":6,"href":"https:\/\/doctor-dark.co.uk\/blog\/wp-json\/wp\/v2\/posts\/695\/revisions"}],"predecessor-version":[{"id":704,"href":"https:\/\/doctor-dark.co.uk\/blog\/wp-json\/wp\/v2\/posts\/695\/revisions\/704"}],"wp:attachment":[{"href":"https:\/\/doctor-dark.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=695"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/doctor-dark.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=695"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/doctor-dark.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}