# How to use a remote windows laptop for NetTrain?

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?

• You can ssh into the remote machine? – Jason B. Mar 30 '18 at 18:02
• I'm doing it with remote kernel launching through ssh. – swish Mar 30 '18 at 20:55
• This may help you? mathematica.stackexchange.com/questions/67767/… – chris Apr 1 '18 at 16:58
• @halirutan Actually, I think this question could be easily answered. Just use channels or any syncing service + some kind of daemon. – M.R. Apr 19 '18 at 20:02
• 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. – halirutan Apr 19 '18 at 20:20

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.
• This works awesomely! I don’t know how to award the bounty I think it expired – user5601 Apr 29 '18 at 23:22
• Nice and simple. You got my vote for this. – halirutan Apr 29 '18 at 23:49
• Can you make this work for Linux? So I can train in AWS? – user5601 Apr 30 '18 at 17:56
• @user5601 Maybe halirutan can think of something, but I'm not sure of Dropbox works on linux shell. – M.R. May 1 '18 at 2:15