Conveniently running and building sage on Win10

128 views
Skip to first unread message

Nils Bruin

unread,
May 31, 2021, 8:41:52 PM5/31/21
to sage-support
Asking for a friend ... or rather linux-challenged students:
What's the most convenient and workable way of running sage on Win10 if you want to do a moderate amount of sage development as well (so, things like `sage -b` or `make build` should probably work, as should `git track push` etc.) ?

I tried the WSL route and was for the most part pleasantly surprised with how well it worked:
 - activating wsl worked as advertised; required a reboot, though.
 - getting ubuntu in the "microsoft store" felt oxymoronic, but worked fine
 - sudo apt update; sudo apt upgrade got me a functional system
 (restarted for good measure)
 - sudo apt install <recommended packages in sage install documentation> worked fine
 - git clone .... got me the sage source tree
 - make configured the mirrors and downloaded a bunch of required spkgs, and then complained about configure
 - running ./configure worked well
 - export MAKE="make -j8"; make took a long while, but produced a working sage

However, it is rather slow! Starting up may be slow due to the underlying file system; however, I tested some CPU-bound computations as well and I found a factor 8 difference in performance!

Win 10: Surface Pro 7; Intel Core i5-1035G4
Linux: Dell XPS 13 Intel Core i5-8250U

Given that the Surface Pro is newer, I'd assume these processors are comparable. So it would seem Win10 is doing something to significantly hobble the performance of the Linux virtual machine.

It's nice that the WSL route is entirely based on "officially supported" solutions and that you end up running code in a genuine linux environment; the best supported environment for many of the sage components. However, the performance penalty makes me hesitate to recommend it to other people. Would Cygwin be better? Other solutions? I can offer my students remote access to a linux server to do their development on, but that requires the navigation of multiple hurdles too, so I'd imagine they'd be  happier and possibly more productive if they can do it all on their local machine.

Best,

Nils

William Stein

unread,
May 31, 2021, 8:57:34 PM5/31/21
to sage-s...@googlegroups.com
If I were you the first thing I would try is virtualbox with Ubuntu on the exact same computer, and do the same benchmarks. 

I also think there are some subtleties with WSL versus WSL2 - which were you actually using?  They are dramatically different technologies…

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/c3687314-1fdb-4ba1-a311-49c6ca9bca0cn%40googlegroups.com.
--
-- William Stein

Nils Bruin

unread,
May 31, 2021, 9:18:30 PM5/31/21
to sage-support
On Monday, 31 May 2021 at 17:57:34 UTC-7 wst wrote:
I also think there are some subtleties with WSL versus WSL2 - which were you actually using?  They are dramatically different technologies…
How do I tell which one I'm running as a user? I wasn't particularly planning on learning how to use Win10 for this experiment; I was really hoping that other people would be able to tell me where to point students to.

Nils Bruin

unread,
May 31, 2021, 9:25:55 PM5/31/21
to sage-support
Update:
wsl --help isn't particularly eager to divulge version information, but some of it inadvertently has slipped through: in the description of the "--shutdown" option there is a mention of "the WSL 2 lightweight utility virtual machine",
so unless wsl has a mysterious option that has a side-effect to kill any wsl2 virtual machines that happen to be running alongside it, I think there's a good chance I'm using WSL2 here.

Dima Pasechnik

unread,
Jun 1, 2021, 4:36:31 AM6/1/21
to sage-support
"From the WSL shell prompt, run uname. If the kernel version => 4.19,
it's WSL Version 2."

>
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/37ef0bb2-156e-429a-8a28-310a8629bbe6n%40googlegroups.com.

Nils Bruin

unread,
Jun 1, 2021, 1:36:42 PM6/1/21
to sage-support
Thank you! I'm still getting inconclusive results. I've googled "Ubuntu – WSL: Am I running version 1 or version 2":

* running "wsl -l -v" in a windows shell gives me:
NAME STATE VERSION
Ubuntu Running 1
Getting a version number at all is apparently an indication of running WSL2.

* running "uname -r" (without options, uname only given back "Linux" which I don't think is distinguishing information) I get
4.4.0-19041-Microsoft

I guess 4<19. On the other hand, 4.4 > 4.19, so I'm not sure what that is telling me.

In any case: do people get "fair" performance under WSL or WSL2? Does Cygwin give better performance? Is development even possible/convenient under Cygwin?

My impression (with both my laptop and the Surface Pro 7 having an intel core i5) was that I should be getting similar performance. On the other hand, the Surface doesn't seem to show any fan action at any point whereas the laptop is quite happy whirring away whenever some load comes its way, so it could just be that the Surface is passively cooled and therefore throttled into computational mediocrity (the surface is really just a tablet to write on and as a tablet OS, win10 seems to be performing just fine). I think the students who'd be using Win10 for development would have beefier machines.

Nathan Dunfield

unread,
Jun 1, 2021, 1:47:56 PM6/1/21
to sage-support
An option worth considering is Docker.  I have had some success with students on Windows or macOS using 

https://github.com/3-manifolds/sagedocker

to develop Sage-dependent code for SnapPy.  One advantage of Docker is that you can have everyone working from an initially uniform image, which helps with debugging technical glitches.  I've even had students connect via their web browser to a JupyterLab instance on the container, giving them a perfectly serviceable development environment right off the bat.  Of course, at that point one could also look into a Cocalc subscription, we've used that for Sage-based classes here.

Best,

Nathan

Dima Pasechnik

unread,
Jun 1, 2021, 2:00:34 PM6/1/21
to sage-support
On Tue, Jun 1, 2021 at 6:36 PM Nils Bruin <nbr...@sfu.ca> wrote:
>
> Thank you! I'm still getting inconclusive results. I've googled "Ubuntu – WSL: Am I running version 1 or version 2":
>
> * running "wsl -l -v" in a windows shell gives me:
> NAME STATE VERSION
> Ubuntu Running 1
> Getting a version number at all is apparently an indication of running WSL2.

for some reason, https://codefellows.github.io/setup-guide/windows/
says that if version is 1 you might want to do something like

wsl --set-version Ubuntu-20.04 2


>
> * running "uname -r" (without options, uname only given back "Linux" which I don't think is distinguishing information) I get
> 4.4.0-19041-Microsoft
>
> I guess 4<19. On the other hand, 4.4 > 4.19, so I'm not sure what that is telling me.
>
> In any case: do people get "fair" performance under WSL or WSL2? Does Cygwin give better performance? Is development even possible/convenient under Cygwin?
>
> My impression (with both my laptop and the Surface Pro 7 having an intel core i5) was that I should be getting similar performance. On the other hand, the Surface doesn't seem to show any fan action at any point whereas the laptop is quite happy whirring away whenever some load comes its way, so it could just be that the Surface is passively cooled and therefore throttled into computational mediocrity (the surface is really just a tablet to write on and as a tablet OS, win10 seems to be performing just fine). I think the students who'd be using Win10 for development would have beefier machines.
>
>
> On Tuesday, 1 June 2021 at 01:36:31 UTC-7 dim...@gmail.com wrote:
>>
>> On Tue, Jun 1, 2021 at 2:25 AM Nils Bruin <nbr...@sfu.ca> wrote:
>> >
>> > Update:
>> > wsl --help isn't particularly eager to divulge version information, but some of it inadvertently has slipped through: in the description of the "--shutdown" option there is a mention of "the WSL 2 lightweight utility virtual machine",
>> > so unless wsl has a mysterious option that has a side-effect to kill any wsl2 virtual machines that happen to be running alongside it, I think there's a good chance I'm using WSL2 here.
>>
>> "From the WSL shell prompt, run uname. If the kernel version => 4.19,
>> it's WSL Version 2."
>>
>> >
>> > --
>> > You received this message because you are subscribed to the Google Groups "sage-support" group.
>> > To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
>> > To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/37ef0bb2-156e-429a-8a28-310a8629bbe6n%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/b137a925-b60a-4022-8a55-5de6a62e5d54n%40googlegroups.com.

Nathan Dunfield

unread,
Jun 1, 2021, 2:00:59 PM6/1/21
to sage-support
* running "uname -r" (without options, uname only given back "Linux" which I don't think is distinguishing information) I get
4.4.0-19041-Microsoft

I guess 4<19. On the other hand, 4.4 > 4.19, so I'm not sure what that is telling me.

Based on this, I think you have WSL1:  https://github.com/microsoft/WSL/issues/5428

In any case: do people get "fair" performance under WSL or WSL2? Does Cygwin give better performance? Is development even possible/convenient under Cygwin?

No direct experience, other than I have used Docker on a Surface Pro 5 and Docker itself uses WSL(2?) these days.  It's been fine, but I didn't do anything like compile all of Sage; as you say, it's passively cooled.

--------------

With WSL2, I think there are two different file systems "Linux side" and "Windows side" and access to the Windows side is super slow by comparison.   But I may be misremembering.

Best,

Nathan

Nils Bruin

unread,
Jun 1, 2021, 4:18:38 PM6/1/21
to sage-support
Thank you all! I needed a few steps here that were mentioned on aka.ms/wsl2-install :

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

(restart)

wsl --set-default-version 2
wsl --set-version Ubuntu 2

(the last bit took a while to convert an existing install to WSL2)

It's now a lot more in line with the performance I'd expect:

sage: P2.<X,Y,Z>=ProjectiveSpace(QQ,2)
sage: C=Curve(X^4+Y^4+Z^4)
sage: S=C.riemann_surface()
sage: %time S.riemann_matrix()

On my linux laptop:

CPU times: user 532 ms, sys: 68.9 ms, total: 601 ms
Wall time: 678 ms

On the Surface:

CPU times: user 967 ms, sys: 0 ns, total: 967 ms
Wall time: 1.18 s

That performance is al least comparable, and could easily be because the CPU on the Surface is throttled or somehow a much less capable "core i5" than my laptop has (Intel really has made it impossible to tell from their serial numbers nowadays).

So with this in place, I'd say: running sage on WSL2 on Windows is quite a reasonable solution; WSL1 is not.
Reply all
Reply to author
Forward
0 new messages