1. Set up a simple Clojush project using Clooj and Leiningen on a mac:
In Clooj: create a project called clusterdemo with namespace clusterdemo.core
Edit the project’s project.clj to include a dependency for [local-file “0.0.4”]. The one that I’m doing this with right now is a Clojure 1.2 project and my edited project.clj file looks like this:
(defproject clusterdemo "1.0.0-SNAPSHOT" :description "FIXME: write" :dependencies [[org.clojure/clojure "1.2.1"] [org.clojure/clojure-contrib "1.2.0"] [local-file "0.0.4"]])
In Terminal: cd into the project directory and run “lein deps”
In Finder or Terminal: put a copy of clojush.clj into the project’s src directory
Relaunch Clooj (necessary for Clooj to see all of the files added above).
Open core.clj and add code for a pushgp run; here’s a very simple thing to get things going:
(ns clusterdemo.core (:use [clojush])) (pushgp :error-function (fn [program] (let [top-int (top-item :integer (run-push program (make-push-state)))] (if (number? top-int) [(Math/abs (- top-int 10))] ))) :atom-generators (list 1 'integer_add))
In Clooj: do REPL > “Evaluate entire file” to make sure that it works.
2. Set up a directory on the cluster for your run:
Lees-MacBook-Pro:clusterdemo leespector$ ssh -l lspector fly.hampshire.edu firstname.lastname@example.org's password: Last login: Sun Mar 11 19:11:45 2012 from c-71-192-29-61.hsd1.ma.comcast.net [etc]
We’re going to ssh to compute-1-1 and use it as a single computer.
[lspector@fly ~]$ ssh compute-1-1 Rocks Compute Node [etc] [lspector@compute-1-1 ~]$ mkdir clusterdemo [lspector@compute-1-1 ~]$ logout Connection to compute-1-1 closed. [lspector@fly ~]$ logout Connection to fly.hampshire.edu closed.
We’ve now set up a folder for our runs (which is still empty). Note that the folder is actually on all nodes — your user directory is cross-mounted on all nodes. So you didn’t really have to ssh to to compute-1-1 before making the directory, because whether you’re on the head node or sshed to any node you’ll still be (initially, on login) in the same directory. But I sshed to compute-1-1 to make it feel more like I was going to that computer. Note that if I wanted to have another run going at the same time on another node that I should make a separate directory for that (e.g. clusterdemo2 for a run on compute-1-2) and repeat everything here for populating that other directory and starting that other run.
Here’s what’s in my project directory on my mac now:
Lees-MacBook-Pro:clusterdemo leespector$ ls classes lib project.clj src Lees-MacBook-Pro:clusterdemo leespector$ ls lib clojure-1.2.1.jar local-file-0.0.4.jar clojure-contrib-1.2.0.jar Lees-MacBook-Pro:clusterdemo leespector$ ls src clojush.clj clusterdemo Lees-MacBook-Pro:clusterdemo leespector$ ls src/clusterdemo/ core.clj
Let’s move all of that to the clusterdemo directory on the cluster, but we’ll just put all of the files in the same top-level directory and not worry about recreating the subdirectories there:
Lees-MacBook-Pro:clusterdemo leespector$ scp lib/* email@example.com:clusterdemo/ firstname.lastname@example.org's password: clojure-1.2.1.jar 100% 3165KB 1.0MB/s 00:03 clojure-contrib-1.2.0.jar 100% 466KB 465.9KB/s 00:00 local-file-0.0.4.jar 100% 2290 2.2KB/s 00:00 Lees-MacBook-Pro:clusterdemo leespector$ scp src/clojush.clj email@example.com:clusterdemo/ firstname.lastname@example.org's password: clojush.clj 100% 93KB 92.6KB/s 00:00 Lees-MacBook-Pro:clusterdemo leespector$ scp src/clusterdemo/core.clj email@example.com:clusterdemo/ firstname.lastname@example.org's password: core.clj 100% 390 0.4KB/s 00:00
3. Connect to compute-1-1 again and conduct a run:
Lees-MacBook-Pro:clusterdemo leespector$ ssh -l lspector fly.hampshire.edu email@example.com's password: Last login: Sun Mar 18 20:29:43 2012 from c-71-192-29-61.hsd1.ma.comcast.net [etc.] [lspector@fly ~]$ ssh compute-1-1 Last login: Sun Mar 18 20:30:31 2012 from fly.local [etc.] [lspector@compute-1-1 ~]$ cd clusterdemo [lspector@compute-1-1 clusterdemo]$ ls clojure-1.2.1.jar clojush.clj local-file-0.0.4.jar clojure-contrib-1.2.0.jar core.clj
Let’s make a “command” run script that sets up the java classpath correctly (which is hard to remember), starts a run, and sends output both to the screen and to a file called “out”:
[lspector@compute-1-1 clusterdemo]$ echo "java -cp $PWD:./*: clojure.main -i core.clj | tee out" > command [lspector@compute-1-1 clusterdemo]$ chmod +x command
[lspector@compute-1-1 clusterdemo]$ ./command
That should spew all of the output from a run, which should succeed quickly and leave you hanging after the program has been simplified.
Use Cntrl-C to exit.
Check the “out” file to see that it contains the output.
4. Conduct long and/or multiple simultaneous runs:
If you can keep your terminal session open for an entire run then you don’t need to do any more than what has been described above (but with a different problem file, etc.). If you want to conduct multiple runs on multiple nodes simultaneously then just open a new Terminal window for each, make a directory on your fly account for each, ssh to a different node for launching each, and cd into the node-appropriate directory before launching each run.
If you can’t keep your terminal session open (e.g. because you have to move your computer) then conduct your runs within “screen”. To do this, when you are connected to the node type “screen” and return to enter a screen session; then start your run and while it’s running type Cntrl-A-D to disconnect from the screen. You will stop seeing the output but process will keep running within screen. Then you can logout or whatever, and when you come back you can type “screen -r” to resume your screen session. When you’re totally done and you want to terminate your screen session you can do that with Cntrl-D.