Compiling from Source for M1

Skip to first unread message

Scott Klum

Jan 16, 2021, 7:10:22 PMJan 16
to Swift for TensorFlow
Hi S4TF Team!

As a newcomer to S4TF, I've been poking around various parts of the project.  One of the things I'd like to do is compile S4TF from source natively for my M1 MBP.  I'm attempting to go off of these instructions from the README.

Unfortunately, I'm hitting a snag very early in the process: it seems like the `build-toolchain-tensorflow` (and `build-toolchain`) scripts expect that `ninja` is a submodule of the `swift` repo (or at least at some specific path), and doesn't work if it's on my $PATH.  The specific error is `ERROR: can't find source directory for ninja` and at the risk of being pedantic this is the first substantive issue I hit when running: 

`$ SKIP_XCODE_VERSION_CHECK=1 ./build-toolchain-tensorflow --dry-run.`

I see the `update-checkout` script, which resolves this particular issue, but the description in the Spot check dependencies section makes it sound like so long as `ninja` is installed and on the path, it should work.  I'm also seeing this commit which appears to confirm that assumption.  FWIW, the `update-checkout` script changes the branch back to `master` so you have to recheck out the `tensorflow` branch in order to use `build-toolchain-tensorflow`.  Also, it seems like the options listed in the referenced readme no longer exist?  That is, running:

`$ SKIP_XCODE_VERSION_CHECK=1 ./build-toolchain-tensorflow --dry-run --skip-build-benchmarks \
  --skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "x86_64" \
  --sccache --release-debuginfo --test`

Results in `Unrecognised argument "--skip-build-benchmarks"` (others fail as well).

Besides these, the next error I get is related to a miss `psutil` import in Python so I thought I'd stop here and make sure I'm not missing some other document that lays out the dependencies in more depth.

I also realize that this question is arguably more appropriate for the actual Swift forum, but I figured I'd post it here first as S4TF is more where I'm interested in participating / contributing.   I'm happy to crosspost if that's desired.

So T.L.D.R. / actually making my questions clear:
* Is it possible to build S4TF with a prebuilt version of ninja?
* Are the above errors expected / is the building from source readme up to date?
* Are there any known gotchas I should be aware of before even attempting to go down the building-S4TF-on-an-M1?

Regardless, I'll plan on posting what gotchas I run into here and am happy to merge those instructions... somewhere... once I get to that point.


P.S. Thanks for doing all this research / fun stuff in public.  I hope to meaningfully contribute ASAP.

Reply all
Reply to author
0 new messages