Hacker News new | ask | show | jobs
by rozim 1833 days ago
I have found the M1 air fine for web browsing but kind of hard to install software on.

Following the instructions: -----

  python -m pip install tensorflow-macos 

  ...

  ERROR: Failed building wheel for numpy

  Failed to build numpy

  ERROR: Could not build wheels for numpy which use PEP 517 and 

  cannot be installed directly
-----

(base) dave@daves-air ~ % uname -a

  Darwin daves-air.lan 20.5.0 Darwin Kernel Version 20.5.0: Sat May  8 05:10:31 PDT 2021; root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 arm64
5 comments

`pip install --upgrade pip` fixed this for me. (not in tensorflow directly, but while installing something else on my M1 last week which required numpy)
OK, so we’re in mid-2021, why is installing Python THAT HARD? I think the only reason Node is so popular is because it JUST WORKS. Windows, Mac, doesn’t matter. One-click installer and you got NPM as well and access to thousands of packages.
As someone using nvm for work, I disagree. NPM can't be installed from normal package repositories, because it's outdated the moment any long-term support distribution accepts it. Then there's yarn, which is fighting for command line dependency management supremacy, with the exact same problem. I'm still not sure what npx does but I think it comes with NPM, unlike nvm which you use to manage NPM installs. I'm hoping I don't need to learn it because I expect some new javascript tool to replace NPM and yarn any day now, as those did bower and grunt before them.

I've also had to use nvm to install an old version of NPM for a specific project because otherwise one of the NPM dependencies couldn't compile a certain C++ executable that I apparently needed? There was also an incompatibility with some binary that another dependency downloaded that required me to mess with soft links to libraries in specific places.

I don't think either NPM or PIP are inherently hard to use as long as you keep them updated (which is exactly what the parent comment is suggesting to do) and as long as you don't need binary dependencies. When you end up in binary territory, which this type of software eventually will, you'll run head-first into stuff that requires arcane commands to get stuff to run.

Respectfully disagree. Being an experienced Python dev, and a total JavaScript noob, I feel exactly the same with npm.

It's ultimately just a matter of experience I guess

While I don't think the problem is as bad as you describe, we should note that Node's initial release was in 2009, while python's was 1991. They pioneered a lot and Node was thus able to spring from quite hefty shoulders.
I consider myself a novice but competent python programmer (not particularly skilled or expert) and everytime i have to use something made in python i cringe because i know it will require 30 minutes of futzing with things to even run it.

Python’s ecosystem is the worst for get-up-and-go usage.

Nvm or nodenv make managing node environments trivial compared to virtualenv, pip, and co. Same with rustup or rbenv… in fact python is the only language i have the problem with.

For real. I enjoy the language but I avoid it like the plague due to...everything else.
i think the comparison with node is good, because my policy for both of them is the same - if i want to use either, i do it inside docker.

i can't be arsed to deal with all the various version dependencies and incompatabilities and system install vs local install nonsense that comes with installing it on my actual computer.

I use asdf (cloned after rbenv) for version management and building versions. Never have a problem.
In case it doesn't fix it for anyone else, here's what worked for me.

First, I ran:

  pip3 install virtualenv
  cd ~
  python3 -m virtualenv tfenv -p python3 --system-site-packages
Now you can activate your tensorflow env at any time by running this:

  source ~/tfenv/bin/activate
I alias this to `tf2` in my ~/.zprofile file:

  alias tf2='source ~/tfenv/bin/activate'
Open up a new terminal and run `tf2`. Now you're in a clean virtualenv, with none of the conda BS. The nice thing about this venv is that if you already have some libraries installed, you can just `import` them. No need to reinstall them for every venv, which I quite like.

So, the goal is to install tensorflow-macos and tensorflow-metal, but the problem is that their pip3 command is failing with some obscure numpy error.

Here's the command that works:

  pip3 install --no-dependencies tensorflow-macos tensorflow-metal absl-py wrapt opt-einsum gast astunparse termcolor flatbuffers
The way I arrived at that command was to run `pip3 install --no-dependencies tensorflow-macos tensorflow-metal`, open a python repl, and try 'import tensorflow as tf'. If it threw an error about package_foo, I added `package-foo` to the end of the command.

That method worked for tracking down every library except absl (unknown library name). But googling pip3 install absl showed that it was named absl-py, not absl.

Now I can run python3, then this code:

  import tensorflow as tf2; tf = tf2.compat.v1; sess = tf.InteractiveSession(); sess.list_devices()
and it shows I have both a CPU and GPU device! I'm really hyped about that. I've wanted tensorflow GPU on my laptop for... about two years? more?

Note that it spits out a warning like this:

  WARNING:root:Limited tf.compat.v2.summary API due to missing TensorBoard installation.
I'm going to leave it as-is, until problems pop up for me. But if you want to try to address it, try adding tensorboard to that pip3 install command above, and repeat the process I described to install any other dependencies.
Alas, this isn't working for me.

    ERROR: Could not find a version that satisfies the requirement tensorflow-macos (from versions: none)
    ERROR: No matching distribution found for tensorflow-macos
But it turns out that was using an x86_64 version of Python3 - setting up an arm64 version (under /opt/homebrew) worked.
Presumably actually:

  python -m pip install --upgrade pip
just:

  pip install --upgrade pip
Is “break pip if there is a newer version available”, at least last I checked. (It uninstalls the existing pip but can’t complete the install of the new one.)
I’ve used the latter several times a month over the last year or so, but only since about pip 19.x, didn’t use Python much before a couple of years ago.
It may only be older pip, or windows, or a combination. I've broken pip in quite a few venvs that way in the past though.
I skipped the tensorflow-deps and the tensorflow-macos dependencies since it was trying to downgrade a bunch of stuff:

$ pip install -U tensorflow-macos --no-deps

That seemed to work for me at least.

Thank you.

The first time I did 'import tensorflow', the import line ran for a long time and then complained about flatbuffers being missing.

Then I ran several commands to install flatbuffers - all of which I could have sworn claimed it was already there, but then I tried the import again and it worked.

'import numpy' works too so the env feels complete enough.

My python binaries are coming from ~/miniforge3/bin

So all is well now, thx.

I would love to hear more from other devs regarding where we're at with M1 for development.

How is Node/React development, for example. Last I heard, Postgres was good to go on native M1. I know Node 14 is good natively. Are there commonly encountered problems? I hate my 2017 MBP and am desperate to upgrade.

Everything webdev works great, Docker is the only thing in my workflow that is still a bit of a hassle but that is quickly improving.
I run everything on miniforge. Makes everything so much better. If you have the arm version of brew, just run "brew install --cask miniforge"
I run everything python under Rosetta. Easiest way is to install home brew for Intel processors then make an alias to that version for managing rosetta stuff
You’re missing out on a gigantic speed boost. If you haven’t checked lately check again, most of the big libraries have been recompiled over the last few months (tensorflow excluded apparently).
Kinda silly to use Rosetta when the whole point of this is native support for TensorFlow on M1.
Maybe, but lots and lots of software applications are not even close to being hardware constrained or in this specific case Rosetta constrained. If you're trying to get work done and you have the computational overhead available, this absolutely sounds like the right solution. Even if it's less efficient, I can easily imagine situations where "I need this to work without thinking about it" could win out.
Yeah I am not running code which is hardware constrained and numpy was a real doozy tto get working because of pep517. I found Rosetta pretty fast anyway. Certainly faster than my Ryzen 2600 on arch Linux at running the same code.
I'm not saying "don't use Rosetta", I'm saying using Rosetta is totally pointless in this case, where literally the whole point is native M1 support.
> I run everything python under Rosetta.

So basically the software that you require to run and do your work is still not available for Apple Silicon? In this case, Apple Silicon support for Python libraries.

The whole point of Apple Silicon is to supersede its Intel Mac counterparts and to run software natively with a noticeable performance increase, especially with software with high performance requirements.

In the case of python users and the ecosystem around it, it is still not ready.

Glad I sat that one out.

There's no need to be so angry about a hypothetical situation in which you by a laptop that you never wanted. I just prefer simplicity right now. I'm a PhD student and I don't need the code to be super fastz just need it to work right now. As it stands j just got it all to run under native so I guess my slight modicum of patience you don't have lags dividends :)
> There's no need to be so angry about a hypothetical situation in which you by a laptop that you never wanted.

Nothing hypothetical about being an early adopter and then complaining and wasting months since the November 2020 release day chaos that several software is still unavailable or unstable, the very basic software doesn't even run on the system and the excessive disk writes on the M1 quickly wears the SSD on the machine. All completely real and happened to many people since launch day.

So, what's the point of buying a laptop that doesn't even run your software in the first place? Might as well stay on your existing laptop. You would rather wait N amount of months for the software to mature and use the laptop reliably for your work than to skip all of that, use your existing laptop and get a better one? (M2 Mac).

Why would I want to wait for months for the developers to port their software and its library ecosystem to Apple Silicon or waste time with broken workarounds when I can use my existing laptop that already 'just works' with everything.

Mind you, I actually bought the M1 MBA recently to try it out and returned it at full price due to the software ecosystem not being ready. Not only I saved my money, I >5x'd that money it in a recent investment anyway and now I'm glad I did that.