herbie-fp / herbie

Optimize floating-point expressions for accuracy
https://herbie.uwplse.org
Other
766 stars 32 forks source link

Any way to install a specific Herbie version using Racket ? #535

Closed rebb closed 1 year ago

rebb commented 1 year ago

It seems that Racket 8.0 has, despite being advertised as "Windows 7 and up" problems on Windows 7, i'm getting unclear installation errors when trying to install Herbie with it.

I had used Racket 7.7 before, which does not show these errors, but instead Herbie now requires 8.0 Minimum.

Is there a way to specify a Herbie version before 1.6 for the package install ?

pavpanchekha commented 1 year ago

Uhh, Racket 8.0 is itself a little old—are you sure none of the newer Racket versions (current is 8.7) fix the problem?

I don't think you can specify prior versions with raco pkg but you are free to check out the source code locally, switch to the v1.5 or v1.4 tag, and use that.

rebb commented 1 year ago

I did try 8.7, 8.6, 8.0, all have the same problem. I'm getting the feeling that Racket 8.x might not actually support Windows7 despite the download page saying so. I asked on the Racket Github about this, but will have to wait for a reply.

pavpanchekha commented 1 year ago

Interesting, thanks for the heads up. What's the Racket issue number?

In any case, I think in that case the best bet is to do the Herbie source checkout I recommended above. I'll mark this issue as closed but feel free to reopen if that doesn't work or something comes up.

rebb commented 1 year ago

The issue on the Racket Repo is https://github.com/racket/racket/issues/4542

I had some almost-success but now i'm getting compile errors which i have no idea about, since i don't know Racket at all :) This one for example :

raco setup: error: during making for <pkgs>/herbie-main/src
raco setup:   t:\Download\herbie-main\src\core\egg-herbie.rkt:280:15: egraph_get
_simplest: unbound identifier
raco setup:     in: egraph_get_simplest
raco setup:     compiling: <pkgs>/herbie-main/src/core/egg-herbie.rkt

I'll try the tag switching approach next, thank you.

pavpanchekha commented 1 year ago

Oh, yeah. So what's going on here is this: Herbie isn't actually a single package, it's a couple. The one that's causing an issue is the one called egg-herbie, or actually it'll be called egg-herbie-windows for you. There's some issue with that—perhaps you have the wrong version of that package, or there's some other issue.

Just to clarify, what command did you run to get that output?

rebb commented 1 year ago

I installed egg-herbie a few minutes before this with "raco pkg install --auto egg-herbie". Along with fpbench and rival, else the attempt to "raco pkg install --auto" on the downloaded ZIP of this repository would complain about these missing.

G:\Progs\Racket>raco pkg show
Installation-wide:
 Package            Checksum             Source
 main-distribution  55d01c2191c15c85...  catalog...tribution
 racket-lib         66df921697a4480d...  catalog racket-lib
 [208 auto-installed packages not shown]
User-specific for installation "8.7":
 Package     Checksum               Source
 egg-herbie  6f0730c6a12571f04d...  catalog...-herbie.git
 fpbench     6feb1dd753e465ac8b...  catalog...FPBench.git
 rival       b7eb8579492350e0f4...  catalog...p/rival.git
 [2 auto-installed packages not shown]

G:\Progs\Racket>raco pkg install --auto "t:\Download\herbie-main"

After the above i get many instances of the mentioned compile error.

rebb commented 1 year ago

Ok, i got the 1.5 Tag to install now. Compared to 1.6, it does not "complain" about egg-herbie missing during the "raco pkg install".

So currently it looks like this for me :

Racket 8.7 and Herbie 1.6 : Wants "raco pkg" install of : rival, fpbench, egg-herbie - But then fails during compile as mentioned above

Racket 8.7 and Herbie 1.5 : Wants "raco pkg" install of : rival, fpbench - Compiles without errors

G:\Progs\Racket>raco pkg show
Installation-wide:
 Package            Checksum             Source
 main-distribution  55d01c2191c15c85...  catalog...tribution
 racket-lib         66df921697a4480d...  catalog racket-lib
 [208 auto-installed packages not shown]
User-specific for installation "8.7":
 Package  Checksum                Source
 fpbench  6feb1dd753e465ac8bc...  catalog.../FPBench.git
 rival    b7eb8579492350e0f44...  catalog...fp/rival.git
 [1 auto-installed package not shown]

G:\Progs\Racket>raco pkg install --auto h:\dev\Local\thirdparty\herbie

I'm happy now though since 1.5 installed fine :) Thanks for the help !

pavpanchekha commented 1 year ago

Does it run? A decent test would be running something like:

racket src/herbie.rkt report bench/tutorial.fpcore out/

This runs Herbie on the three FPCore files in bench/tutorial.fpcore and writes the results to a new directory called out/.

I just want to make sure you don't hit runtime errors due to anything.

rebb commented 1 year ago

I'll have to revert some things i said. It seems i previously tried to install the current state of the repository, and not the 1.6 Tag. If i use the 1.6 Tag Commit, it compiles without errors ( if egg-herbie is installed beforehand ). BUT : It does not actually start when i do "herbie web" - Then i get this DLL Error :

The procedure entry point ScriptIsComplex could not be located in the dynamic link library GDI32.dll

Sounds like a Windows 7 problem potentially.

I will try with 1.5 now and report back ..

rebb commented 1 year ago

Yep same with 1.5 - I think this error is coming from Racket though, seen it pop up before when trying to run Racket 8.x DrRacket.exe ..

Next try : Racket 7.7 and an earlier Herbie Tag :)

pavpanchekha commented 1 year ago

Oof. Hmm. Are you running racket or gracket? Does DRRacket or a similar Racket program start up? Does the racket REPL start up? I'm asking because it seems to be having an issue in GDI32, which is the Windows 2D graphics API. We do use some graphics code in Herbie (to draw plots), so I'm trying to figure out if it's that.

rebb commented 1 year ago

I was running just racket, not the GUI one. DrRacket only starts on Racket 7.7, on 8.x it throws GDI32 Errors as well. So i assume it does not actually support Win7, and their website is just outdated.

It seems i'm just out of luck with this, since even with 7.7 i can't get the install to work, because now the "rival" package requires 8.0 .. sigh.

Oh well, i'll just stay with the Herbie Website for now.

pavpanchekha commented 1 year ago

Rival is also one of our packages. I bet if you install from source it'll work fine. I don't think that had any real 8.0 dependencies.

pavpanchekha commented 1 year ago

Of course, feel free to use the website, just trying to help how I can!

rebb commented 1 year ago

Oh i see, i'll try that later then - i'm a bit spent on this whole thing for now :)

Thanks a lot for your help, much appreciated !

pavpanchekha commented 1 year ago

No problem. As before, I'll close to keep it tidy but if you post again I'll see it.

rebb commented 1 year ago

Ok, it seems to work now, maybe :) ( Racket 7.7 with Tag 1.5 and an edited Rival package )

Changing the requirements for Rival was enough to get it to install.

I ran the line you mentioned earler, but there are some Crashes.

H:\Dev\Local\thirdparty\herbie>g:\progs\racket\racket src/herbie.rkt report bench/tutorial.fpcore out/
Starting Herbie on 3 problems (seed: 314292098)...
Error when evaluating ((? (x) (pow.f64 (*.f64 x (+.f64 x 2)) 1)) (? (x) (exp.f64
 (+.f64 (log.f64 x) (log.f64 (+.f64 x 2))))) (? (x) (log.f64 (exp.f64 (*.f64 x (
+.f64 x 2))))) (? (x) (exp.f64 (log.f64 (*.f64 x (+.f64 x 2))))) (? (x) (cbrt.f6
4 (*.f64 (*.f64 (*.f64 x (+.f64 x 2)) (*.f64 x (+.f64 x 2))) (*.f64 x (+.f64 x 2
))))) (? (x) (*.f64 (*.f64 (cbrt.f64 (*.f64 x (+.f64 x 2))) (cbrt.f64 (*.f64 x (
+.f64 x 2)))) (cbrt.f64 (*.f64 x (+.f64 x 2))))) (? (x) (cbrt.f64 (*.f64 (*.f64
(*.f64 x x) x) (*.f64 (*.f64 (+.f64 x 2) (+.f64 x 2)) (+.f64 x 2))))) (? (x) (*.
f64 (sqrt.f64 (*.f64 x (+.f64 x 2))) (sqrt.f64 (*.f64 x (+.f64 x 2))))) (? (x) (
*.f64 1 (*.f64 x (+.f64 x 2)))) (? (x) (*.f64 (*.f64 (sqrt.f64 x) (sqrt.f64 (+.f
64 x 2))) (*.f64 (sqrt.f64 x) (sqrt.f64 (+.f64 x 2))))) (? (x) (+.f64 (*.f64 x x
) (*.f64 2 x))) (? (x) (+.f64 (*.f64 x x) (*.f64 x 2))) (? (x) (/.f64 (*.f64 x (
+.f64 (pow.f64 x 3) (pow.f64 2 3))) (+.f64 (*.f64 x x) (-.f64 (*.f64 2 2) (*.f64
 x 2))))) (? (x) (/.f64 (*.f64 x (-.f64 (*.f64 x x) (*.f64 2 2))) (-.f64 x 2)))
(? (x) (*.f64 (*.f64 (cbrt.f64 x) (cbrt.f64 x)) (*.f64 (cbrt.f64 x) (+.f64 x 2))
)) (? (x) (*.f64 (sqrt.f64 x) (*.f64 (sqrt.f64 x) (+.f64 x 2)))) (? (x) (*.f64 (
*.f64 x (*.f64 (cbrt.f64 (+.f64 x 2)) (cbrt.f64 (+.f64 x 2)))) (cbrt.f64 (+.f64
x 2)))) (? (x) (*.f64 (*.f64 x (sqrt.f64 (+.f64 x 2))) (sqrt.f64 (+.f64 x 2))))
(? (x) (*.f64 (*.f64 x 1) (+.f64 x 2))) (? (x) (*.f64 (+.f64 x 2) x))) on (1.624
3876234903961e-237)
  1/3   [  CRASH  ]             Expanding a square
  2/3   [   7.103s]    0→ 0     Commute and associate
  3/3   [   7.090s]   29→ 0     Cancel like terms

The error mentioned in the graph.html of the Expanding Square is match: no matching clause for #<syntax:src\syntax\syntax.rkt:337:119 double> But maybe 1.6 is required for this ?

rebb commented 1 year ago

Hm no, it seems this error also pops up for some simple inputs when using "herbie web". Oh well, it was worth a try :)

pavpanchekha commented 1 year ago

Oh man, hmm. That sounds like a Herbie bug, but I'm not sure whether that's a version issue or which package. I don't think that happens in current Herbie.

pavpanchekha commented 1 year ago

Sadly this is probably the end of the line. Thanks for trying things out, and I hope the Racket folk are able to fix the underlying Win7 bug.

rebb commented 1 year ago

Small update. I've had some success now, by using Racket 8.5 ( had only tried 8.7, 8.6, 8.0 before ), as someone mentioned in related Racket issue that this version started up fine on Win7. So it appears to be a Racket regression of some kind.

I still have to use the local repository version of Herbie to get it to install though, the "raco pkg install --auto herbie" approach still gives me an error for some reason.

But other than that, it appears to work fine now :)

pavpanchekha commented 1 year ago

Glad it works! If you send along the error it might be useful, though who knows.

rebb commented 1 year ago

The error ( which does not seem to happen in Racket 7.7 for some reason, but that has other issues as mentioned ) :

G:\Progs\Racket>raco pkg install --auto herbie
Resolving "herbie" via https://download.racket-lang.org/releases/8.5/catalog/
Resolving "herbie" via https://pkgs.racket-lang.org
Downloading repository https://github.com/uwplse/herbie.git?path=src#v1.6 commit
 600fd02dd9057ff758c4c73f806e323470f72a02
make-file-or-directory-link: cannot make link
  path: e:\Temp\UserTemp\SYSTEM\16740479231674047923476-uwplse_herbie_git_v1_6\w
ww\doc\latest
  system error: The parameter is incorrect.; win_err=87
  context...:
   G:\Progs\Racket\collects\net\git-checkout.rkt:776:3
   [repeats 2 more times]
   G:\Progs\Racket\collects\net\git-checkout.rkt:167:11
   G:\Progs\Racket\collects\net\git-checkout.rkt:55:2: retry-loop
   G:\Progs\Racket\collects\pkg\private\download.rkt:102:2: download!
   G:\Progs\Racket\collects\file\cache.rkt:63:2: fetch-and-continue
   G:\Progs\Racket\collects\racket\contract\private\arrow-val-first.rkt:555:3
   G:\Progs\Racket\collects\pkg\private\download.rkt:94:0: download-repo!
   G:\Progs\Racket\collects\pkg\private\stage.rkt:319:11
   G:\Progs\Racket\collects\pkg\private\stage.rkt:115:0: stage-package/info
   [repeats 1 more time]
   G:\Progs\Racket\collects\pkg\private\install.rkt:141:0: install-packages
   G:\Progs\Racket\collects\pkg\private\install.rkt:925:4
   G:\Progs\Racket\collects\racket\contract\private\arrow-val-first.rkt:555:3
   G:\Progs\Racket\collects\racket\file.rkt:763:8
   G:\Progs\Racket\collects\racket\file.rkt:752:0: call-with-file-lock
   ...

According to someone else, it's possibly related to symlinks - but all involved drives are NTFS so symlinks should work ? This is also done through an Administrator-enabled prompt.

Doing the install from a local repository copy works without this error.

pavpanchekha commented 1 year ago

Interesting. I'm not surprised symlinks break on Windows, I think I heard that they're tricky (not a Windows guy, don't know the details). That symlink is unimportant (it's what we use to make herbie.uwplse.org/doc/latest/ point to, say, /doc/1.6/) so maybe if I think of a different way to do it I'll change it up.