8
$\begingroup$

I have a windows 10 laptop (with a gpu) at home and a macbook at my office, both with v11.3.

What are steps to use the windows machine remotely for training? That is, I want to launch and run kernels on the windows machine using my macbook's front-end.

I've done this with ubuntu boxes on AWS, but perhaps this is easier/harder?

$\endgroup$
9
  • 1
    $\begingroup$ You can ssh into the remote machine? $\endgroup$
    – Jason B.
    Mar 30, 2018 at 18:02
  • 1
    $\begingroup$ I'm doing it with remote kernel launching through ssh. $\endgroup$
    – swish
    Mar 30, 2018 at 20:55
  • 1
    $\begingroup$ This may help you? mathematica.stackexchange.com/questions/67767/… $\endgroup$
    – chris
    Apr 1, 2018 at 16:58
  • 1
    $\begingroup$ @halirutan Actually, I think this question could be easily answered. Just use channels or any syncing service + some kind of daemon. $\endgroup$
    – M.R.
    Apr 19, 2018 at 20:02
  • 1
    $\begingroup$ Additionally, I'm not on Windows 10. But if you like to post an answer, go ahead. If it works, be sure you get my upvote. $\endgroup$
    – halirutan
    Apr 19, 2018 at 20:20

1 Answer 1

2
$\begingroup$

Ok, here's a file syncing service solution:

Step 1: Get a Dropbox account and make two folders in your dropbox: 'to_run/' and 'finished/'.

Step 2: Paste and run this in a notebook on your Windows box:

Options[run] = {"Print"->False};
(* runs a notebook f and saves its result *)
run[f_, opts:OptionsPattern[]] := Module[
     {nb, pdfName, doneName, tmpName, t, msg},
        tmpName = StringInsert[f, "_IN_PROGRESS",-4]; CopyFile[f, tmpName];
        doneName = StringReplace[tmpName, "_IN_PROGRESS" -> "_DONE"]; t = Now;
        nb = NotebookOpen[tmpName]; NotebookEvaluate[nb, InsertResults->True];
        NotebookSave[nb];
        If[OptionValue[opts,"Print"],
            pdfName = StringTake[doneName,;;-4]<>".pdf";
            NotebookPrint[nb, pdfName];
        ];
        NotebookClose[nb]; CopyFile[tmpName, doneName]; DeleteFile[tmpName];
        msg = StringForm["``: Evaluted `` in ``", Now, FileBaseName@f, Now-t];
        Print[msg]; ChannelSend["example", msg]; (* e.g. monitor things *)
        doneName
    ]

runner[indir_, outdir_] := Module[
    {fns = {}, done = {}, ran, to},
      Print[StringForm["Listening for files in ``", indir]];
      While[True,
        Pause[3]; done = {};
        fns = FileNames["*.nb", indir];
        Do[
            If[!MemberQ[done,f],
                Print[StringForm["Working on ``",f]];
                to = FileNameJoin[{outdir, FileNameTake[f,-1]}];
                CopyFile[f, to]; ran = run[to];
                If[FileExistsQ[to], DeleteFile[f]; DeleteFile[to]];
                AppendTo[done, f];
            ]
        ,{f, fns}]
     ]
]

runner["C:\\Users\\Dropbox\\to_run" , "C:\\Users\\Dropbox\\finished"]

Step 3: Drag a notebook you want to remotely evaluate into the 'to_run/' folder and wait for the notebook result to appear.

Notes:

  • This is just a 5-min prototype, you should re-write this to make it robust to notebooks that crash the kernel and handle other issues like name collisions.
  • Make sure both laptops have persistant internet access and a dropbox daemon running.
  • You can add monitoring easily through a channel with ChannelListener and ChannelSend
  • To easily save things that you need in the resulting notebook use DumpSave, PersistantSymbol, or just throw in some Iconize calls.
$\endgroup$
4
  • $\begingroup$ This works awesomely! I don’t know how to award the bounty I think it expired $\endgroup$
    – user5601
    Apr 29, 2018 at 23:22
  • $\begingroup$ Nice and simple. You got my vote for this. $\endgroup$
    – halirutan
    Apr 29, 2018 at 23:49
  • $\begingroup$ Can you make this work for Linux? So I can train in AWS? $\endgroup$
    – user5601
    Apr 30, 2018 at 17:56
  • $\begingroup$ @user5601 Maybe halirutan can think of something, but I'm not sure of Dropbox works on linux shell. $\endgroup$
    – M.R.
    May 1, 2018 at 2:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.