Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

How to install if I use conda environments? #3

Open
giordan12 opened this issue Nov 18, 2020 · 46 comments
Open

How to install if I use conda environments? #3

giordan12 opened this issue Nov 18, 2020 · 46 comments

Comments

@giordan12
Copy link

I do not have virtualenvs installed but I do use conda environments. Is there a way to install in a conda environment? Thanks!

@grwche
Copy link

grwche commented Nov 18, 2020

need to change:

  • tf_2_4 == your (conda) virtual environment name
  • /Users/grwche/Downloads/ == path to your download file (from the releases section on this repo)

pip install --upgrade pip wheel setuptools cached-property six

pip install --upgrade -t "tf_2_4/lib/python3.8/site-packages/" --no-dependencies --force "/Users/grwche/Downloads/tensorflow_macos/x86_64/grpcio-1.33.2-cp38-cp38-macosx_11_0_x86_64.whl"

pip install --upgrade -t "tf_2_4/lib/python3.8/site-packages/" --no-dependencies --force "/Users/grwche/Downloads/tensorflow_macos/x86_64/h5py-2.10.0-cp38-cp38-macosx_11_0_x86_64.whl"

pip install --upgrade -t "tf_2_4/lib/python3.8/site-packages/" --no-dependencies --force "/Users/grwche/Downloads/tensorflow_macos/x86_64/numpy-1.18.5-cp38-cp38-macosx_11_0_x86_64.whl"

pip install --upgrade -t "tf_2_4/lib/python3.8/site-packages/" --no-dependencies --force "/Users/grwche/Downloads/tensorflow_macos/x86_64/scipy-1.5.4-cp38-cp38-macosx_11_0_x86_64.whl"

pip install --upgrade -t "tf_2_4/lib/python3.8/site-packages/" --no-dependencies --force "/Users/grwche/Downloads/tensorflow_macos/x86_64/tensorflow_addons-0.11.2+mlcompute-cp38-cp38-macosx_11_0_x86_64.whl"

pip install absl-py astunparse flatbuffers gast google_pasta keras_preprocessing opt_einsum protobuf tensorflow_estimator termcolor typing_extensions wrapt wheel tensorboard typeguard

pip install --upgrade -t "tf_2_4/lib/python3.8/site-packages/" --no-dependencies --force "/Users/grwche/Downloads/tensorflow_macos/x86_64/tensorflow_macos-0.1a0-cp38-cp38-macosx_11_0_x86_64.whl"

@mwidjaja1
Copy link

mwidjaja1 commented Nov 18, 2020

EDIT: DO NOT USE THIS. Well you can, it didn't work for me after all, but you can try. I posted an updated version of this, in light of some new updates in the world of Miniconda, later in this post.


Thanks @grwche! For those installing this on ARM, the libraries are slightly different, so here was my version.

  1. Download the archive from https://github.com/apple/tensorflow_macos/releases
  2. Run the below in a bash terminal and replace the first two variables.
# If you have Tensorflow in your env, you must install it first -- uncomment this line if you're in this boat
# pip uninstall tensorflow tensorboard

# Put a path to where the arm64 libraries are. For example...
libs="/Users/Matthew/Downloads/tensorflow_macos/arm64/"

# Replace this with the name of your Conda environment
env="tensorflow"

# The rest should work
pip install --upgrade pip wheel setuptools cached-property six

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl"

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/h5py-2.10.0-cp38-cp38-macosx_11_0_arm64.whl"

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/numpy-1.18.5-cp38-cp38-macosx_11_0_arm64.whl"

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/tensorflow_addons-0.11.2+mlcompute-cp38-cp38-macosx_11_0_arm64.whl"

pip install absl-py astunparse flatbuffers gast google_pasta keras_preprocessing opt_einsum protobuf tensorflow_estimator termcolor typing_extensions wrapt wheel tensorboard typeguard

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/tensorflow_macos-0.1a0-cp38-cp38-macosx_11_0_arm64.whl"

@hoytak hoytak closed this as completed Nov 19, 2020
@hoytak hoytak reopened this Nov 19, 2020
@hoytak
Copy link
Collaborator

hoytak commented Nov 19, 2020

Thank you for the responses here. We will look into supporting conda more seamlessly in the future.

@JacopoMangiavacchi
Copy link

@mwidjaja1 were you able to install Conda on M1 ?

@mwidjaja1
Copy link

@JacopoMangiavacchi Yes, just a standard Anaconda installation too if I recall. I don't think I did anything fancy (If I did, it would have been just to throw a arch -x86_64 before any bash command to install so that it compiles in Rosetta)

@jtkiley
Copy link

jtkiley commented Nov 19, 2020

Thank you for the responses here. We will look into supporting conda more seamlessly in the future.

@hoytak, that would be great. I suppose the approach depends whether this is a fork that you're looking to maintain indefinitely or whether you're planning on upstreaming it. Either way, it would be great if the conda solver would use the accelerated version when appropriate so that a single environment file could be both fast and cross platform. That's good practice in general and especially for things like the courses/workshops that I do.

@JacopoMangiavacchi
Copy link

Thank you @mwidjaja1, I just found how to install native arm miniconda here https://conda-forge.org/blog/posts/2020-10-29-macos-arm64/

@mwidjaja1
Copy link

And I guess on that note, @hoytak, would you consider submitting this version of TensorFlow (as well as any other packages you've made) to conda-forge's new ARM database so anyone can conda install it?

To share @JacopoMangiavacchi's link again: https://conda-forge.org/blog/posts/2020-10-29-macos-arm64/

@JacopoMangiavacchi
Copy link

JacopoMangiavacchi commented Nov 19, 2020

@mwidjaja1 I was able to install it on arm miniconda with the script above BUT the env variable has to contain the path to the conda env and not the name of the env.

@JacopoMangiavacchi
Copy link

Then I was able to add other packages such as pandas and notebook via conda but as soon as I start a notebook on the associated ipkernel the NotebookApp crash miserably.

Is anyone able to use notebook on M1 ?

@mwidjaja1
Copy link

Thanks for nudging me in the right direction @JacopoMangiavacchi! I forgot you can downgrade to Python 3.8.

I finally got things working with these modifications that takes into account,

  1. There's an ARM Miniconda (yay!)
  2. There's Python 3.8 there
  3. A lot of the packages we need, such as Numpy, is already there (Yay again!)
  4. The great work @hoytak did to build TensorFlow for ARM.

So what I did to get things finally working,

  1. Download the archive for this repo from https://github.com/apple/tensorflow_macos/releases
  2. I downloaded Miniconda from https://conda-forge.org/blog/posts/2020-10-29-macos-arm64/
  3. Install Miniconda
  4. Once it's installed, create a Python 3.8 env by running conda create --name python38 python=3.8
  5. Because it's a new env, there's no way you have any packages like Tensorflow on there already (good) so...
  6. Run this script:
# Put a path to where the arm64 libraries are. For example...
libs="/Users/Matthew/Downloads/tensorflow_macos/arm64/"

# Replace this with the path of your Conda environment
env="/Users/Matthew/miniforge3/envs/python38"

# The rest should work
conda upgrade -c conda-forge pip setuptools cached-property six

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl"

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/h5py-2.10.0-cp38-cp38-macosx_11_0_arm64.whl"

# pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/numpy-1.18.5-cp38-cp38-macosx_11_0_arm64.whl"

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/tensorflow_addons-0.11.2+mlcompute-cp38-cp38-macosx_11_0_arm64.whl"

conda install -c conda-forge -y absl-py
conda install -c conda-forge -y astunparse
conda install -c conda-forge -y gast
conda install -c conda-forge -y opt_einsum
conda install -c conda-forge -y termcolor
conda install -c conda-forge -y typing_extensions
conda install -c conda-forge -y wheel
conda install -c conda-forge -y typeguard

pip install tensorboard

pip install wrapt flatbuffers tensorflow_estimator google_pasta keras_preprocessing protobuf

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/tensorflow_macos-0.1a0-cp38-cp38-macosx_11_0_arm64.whl"

@nehbit
Copy link

nehbit commented Nov 19, 2020

As an additional reference for future visitors, here's how I got this working in Anaconda on x64: #7 (comment) (though instructions above look quite good as well)

@bryanlimy
Copy link

bryanlimy commented Nov 19, 2020

I am able to install on my MacBook Pro 2018 following @nehbit instructions.

Basically, rename macosx_11_0_x86_64.whl to macosx_16_10_x86_64.whl in all 6 files under tensorflow_macos\x86_64. Create a new conda env, activate the conda env and run

pip install --no-dependencies --force "grpcio-1.33.2-cp38-cp38-macosx_10_16_x86_64.whl"
pip install --no-dependencies --force "h5py-2.10.0-cp38-cp38-macosx_10_16_x86_64.whl"
pip install --no-dependencies --force "numpy-1.18.5-cp38-cp38-macosx_10_16_x86_64.whl"
pip install --no-dependencies --force "scipy-1.5.4-cp38-cp38-macosx_10_16_x86_64.whl"
pip install --no-dependencies --force "tensorflow_addons-0.11.2+mlcompute-cp38-cp38-macosx_10_16_x86_64.whl"

conda install -c conda-forge -y absl-py
conda install -c conda-forge -y astunparse
conda install -c conda-forge -y gast
conda install -c conda-forge -y opt_einsum
conda install -c conda-forge -y termcolor
conda install -c conda-forge -y typing_extensions
conda install -c conda-forge -y wheel
conda install -c conda-forge -y typeguard

pip install tensorboard

pip install wrapt flatbuffers tensorflow_estimator google_pasta keras_preprocessing protobuf

pip install --no-dependencies --force "tensorflow_macos-0.1a0-cp38-cp38-macosx_10_16_x86_64.whl"

@Dunguyntie
Copy link

Dunguyntie commented Nov 19, 2020

Why after I did pip install all .whl files from x86_64 folders and went to Jupiter Notebook to try import TensorFlow and mlcompute, it returned "No module named 'mlcompute'"?

@isuruf
Copy link

isuruf commented Nov 21, 2020

We will look into supporting conda more seamlessly in the future.

@hoytak, I was the one who ported conda to macos arm64 and we already have packages like scipy running natively on DTK. Let us know at conda-forge/conda-forge.github.io#1126 if you want to collaborate.

@noahc1510
Copy link

@mwidjaja1 I tried it on intel platform but I got this issue #28

@Kairobo
Copy link

Kairobo commented Nov 25, 2020

@bryanlimy "conda upgrade -c conda-forge pip setuptools cached-property six" might cause a problem. "PackageNotInstalledError: Package is not installed in prefix."
My way to fix it is using pip instead: "pip install --upgrade cached-property six".
The other stuff can be installed by "conda upgrade -c conda-forge pip setuptools "

I tested a deep learning model following your last comment. It is pretty fast. Thank you for the guidance!

@fassifihri
Copy link

after installing, when i launch python and the commands
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
i have the message
I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: SSE4.2 AVX AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Thank you for the guidance!

@TheMartian32
Copy link

Hey everyone so I followed the steps and I'm getting this error when running the script.

Note: I copied it to a text edit file ( cleared formatting ), copied path to my tensorflow download and conda env and pasted them in. Then I saved it as a .sh file. Ran chmod +x filename.sh, then ./filename to execute.

This is what I got as an error:

Processing /Users/user/tensorflow_macos/arm64/tensorflow_macos-0.1a0-cp38-cp38-macosx_11_0_arm64.whl
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/Users/user/tensorflow_macos/arm64/tensorflow_macos-0.1a0-cp38-cp38-macosx_11_0_arm64.whl'```

@mwidjaja1
Copy link

@TheMartian32 that honestly seems like user error because it's saying the path you provided does not exist. Double check to make sure you're following the instructions correctly.

@TheMartian32
Copy link

@mwidjaja1 I tried cd'ing into the path but I left out the file at the end of it. worked fine. The directory definitely exists but I'm not sure why theres an environment error. just to be sure I doubled checked everything and I printed out the path, everything checks out.

@mwidjaja1
Copy link

@TheMartian32 Without knowing the line number you got that error, I think you might be confusing the Python Environment vs. the Installer. When you run the script, it's asking for you for the python environment where to install TF too, not the location of the Whl file (the script infers that)

@TheMartian32
Copy link

@mwidjaja1 I'm not sure what I did, but I just moved the script to the same folder as my TensorFlow install, conda activated the venv, ran the script, and somehow it ran great! All of my imports ran great and there were 0 problems. Thank you so much for writing the script!

@Maxlanglet
Copy link

@mwidjaja1 I followed your instructions and it worked great ! Importing TensorFlow via the terminal works great. The issue I have is running TensorFlow in a Jupyter notebook, I have the following error message :
"No module named 'tensorflow'".
I am correctly in the right environment though so it seems weird to me. Maybe Jupyter is related to the base Conda environment and not the one I created ?

@Maxlanglet
Copy link

I found a solution to my problem with this link https://medium.com/@nrk25693/how-to-add-your-conda-environment-to-your-jupyter-notebook-in-just-4-steps-abeab8b8d084, it is only needed to follow step 3. After following the instructions, I had to download in the new environment some libraries but in the end everything works just fine.

@rkraghu88
Copy link

Thanks for nudging me in the right direction @JacopoMangiavacchi! I forgot you can downgrade to Python 3.8.

I finally got things working with these modifications that takes into account,

  1. There's an ARM Miniconda (yay!)
  2. There's Python 3.8 there
  3. A lot of the packages we need, such as Numpy, is already there (Yay again!)
  4. The great work @hoytak did to build TensorFlow for ARM.

So what I did to get things finally working,

  1. Download the archive for this repo from https://github.com/apple/tensorflow_macos/releases
  2. I downloaded Miniconda from https://conda-forge.org/blog/posts/2020-10-29-macos-arm64/
  3. Install Miniconda
  4. Once it's installed, create a Python 3.8 env by running conda create --name python38 python=3.8
  5. Because it's a new env, there's no way you have any packages like Tensorflow on there already (good) so...
  6. Run this script:
# Put a path to where the arm64 libraries are. For example...
libs="/Users/Matthew/Downloads/tensorflow_macos/arm64/"

# Replace this with the path of your Conda environment
env="/Users/Matthew/miniforge3/envs/python38"

# The rest should work
conda upgrade -c conda-forge pip setuptools cached-property six

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl"

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/h5py-2.10.0-cp38-cp38-macosx_11_0_arm64.whl"

# pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/numpy-1.18.5-cp38-cp38-macosx_11_0_arm64.whl"

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/tensorflow_addons-0.11.2+mlcompute-cp38-cp38-macosx_11_0_arm64.whl"

conda install -c conda-forge -y absl-py
conda install -c conda-forge -y astunparse
conda install -c conda-forge -y gast
conda install -c conda-forge -y opt_einsum
conda install -c conda-forge -y termcolor
conda install -c conda-forge -y typing_extensions
conda install -c conda-forge -y wheel
conda install -c conda-forge -y typeguard

pip install tensorboard

pip install wrapt flatbuffers tensorflow_estimator google_pasta keras_preprocessing protobuf

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/tensorflow_macos-0.1a0-cp38-cp38-macosx_11_0_arm64.whl"

Thanks a lot! This solved my Scipy requirement as well!!

@rkraghu88 rkraghu88 mentioned this issue Dec 27, 2020
@lorenzocov
Copy link

lorenzocov commented Dec 30, 2020

@Maxlanglet,

That for the instructions, which I'm trying, and I would like to ask for your help.

Which libraries did you download to the new environment and how?

This is what I run:

$ conda activate python38lc
$ python -m ipykernel install --user --name=python38lc

This is the error and it seems related to cython

Traceback (most recent call last):
File "/Users/lorenzocoviello/miniforge3/envs/python38lc/lib/python3.8/runpy.py", line 185, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/Users/lorenzocoviello/miniforge3/envs/python38lc/lib/python3.8/runpy.py", line 144, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/Users/lorenzocoviello/miniforge3/envs/python38lc/lib/python3.8/runpy.py", line 111, in _get_module_details
import(pkg_name)
File "/Users/lorenzocoviello/miniforge3/envs/python38lc/lib/python3.8/site-packages/ipykernel/init.py", line 2, in
from .connect import *
File "/Users/lorenzocoviello/miniforge3/envs/python38lc/lib/python3.8/site-packages/ipykernel/connect.py", line 18, in
import jupyter_client
File "/Users/lorenzocoviello/miniforge3/envs/python38lc/lib/python3.8/site-packages/jupyter_client/init.py", line 4, in
from .connect import *
File "/Users/lorenzocoviello/miniforge3/envs/python38lc/lib/python3.8/site-packages/jupyter_client/connect.py", line 21, in
import zmq
File "/Users/lorenzocoviello/miniforge3/envs/python38lc/lib/python3.8/site-packages/zmq/init.py", line 50, in
from zmq import backend
File "/Users/lorenzocoviello/miniforge3/envs/python38lc/lib/python3.8/site-packages/zmq/backend/init.py", line 40, in
reraise(*exc_info)
File "/Users/lorenzocoviello/miniforge3/envs/python38lc/lib/python3.8/site-packages/zmq/utils/sixcerpt.py", line 34, in reraise
raise value
File "/Users/lorenzocoviello/miniforge3/envs/python38lc/lib/python3.8/site-packages/zmq/backend/init.py", line 27, in
_ns = select_backend(first)
File "/Users/lorenzocoviello/miniforge3/envs/python38lc/lib/python3.8/site-packages/zmq/backend/select.py", line 28, in select_backend
mod = import(name, fromlist=public_api)
File "/Users/lorenzocoviello/miniforge3/envs/python38lc/lib/python3.8/site-packages/zmq/backend/cython/init.py", line 6, in
from . import (constants, error, message, context,
ImportError: dlopen(/Users/lorenzocoviello/miniforge3/envs/python38lc/lib/python3.8/site-packages/zmq/backend/cython/constants.cpython-38-darwin.so, 2): no suitable image found. Did find:
/Users/lorenzocoviello/miniforge3/envs/python38lc/lib/python3.8/site-packages/zmq/backend/cython/constants.cpython-38-darwin.so: mach-o, but wrong architecture
/Users/lorenzocoviello/miniforge3/envs/python38lc/lib/python3.8/site-packages/zmq/backend/cython/constants.cpython-38-darwin.so: mach-o, but wrong architecture

@isuruf
Copy link

isuruf commented Dec 31, 2020

You can do conda create -n tf tensorflow-addons tensorflow -c isuruf/label/tf -c conda-forge to install on conda (both Intel and Apple Silicon chips). This is temporary until these packages end up in conda-forge.

@lorenzocov
Copy link

Thanks @isuruf,

I'm operating from a Conda environment created as follows:
conda create --name python38-v1 python=3.8
On which I installed tensorflow_macos (following the steps at https://www.ai-buzz.com/18-steps-to-install-tensorflow_macos-on-m1-macbook-2020/).

Given you suggestion, should I "conda update" instead of "conda create"? Thanks!

@isuruf
Copy link

isuruf commented Jan 1, 2021

I suggest creating a new environment with conda create -n python38-v2 tensorflow-addons tensorflow -c isuruf/label/tf -c conda-forge

@lorenzocov
Copy link

Thanks again @isuruf :)

I have to followup questions:

1 - Given that I installed tensoflow_macos in the conda env python38-v1, and I want the jupiter notebook to see that environment, I was thinking to run "python -m ipykernel install --user --name=python38-v1" from the conda env python38-v1.

If I create a new conda env python38-v2, how would I go with making tensorflow_macos available from jupiter notebook?

2 - You command is also telling conda to look in "isuruf/label/tf", which I assume it's specific to your system. What is that?

Thanks!

@isuruf
Copy link

isuruf commented Jan 1, 2021

  1. I suggest using just one env. Makes it easier.
  2. It's a channel for testing. It's not specific to my system. It's a channel I created and you can use it freely.

@lorenzocov
Copy link

Thanks @isuruf!

To summarize for future readers.

After I created the conda env python38-v1 and installed tf_macos following the steps at https://www.ai-buzz.com/18-steps-to-install-tensorflow_macos-on-m1-macbook-2020/, I ran the following:

conda install -n python38-v1 tensorflow-addons -c isuruf/label/tf -c conda-forge

conda update -n python38-v1 tensorflow -c isuruf/label/tf -c conda-forge

conda install -n python38-v1 -c conda-forge notebook

conda install -n python38-v1 -c anaconda ipykernel

python -m ipykernel install --user --name=python38-v1

Now, the Jupiter notebook sees the runtime python38-v1 with the correct version of tensorflow.

@isuruf
Copy link

isuruf commented Jan 2, 2021

Btw, you don't need to follow steps from that link. If you are starting new, the steps are

  1. Install miniforge from https://github.com/conda-forge/miniforge#miniforge3
  2. conda create -n python38 tensorflow-addons tensorflow -c isuruf/label/tf -c conda-forge
  3. conda activate python38

@chinitaberrio
Copy link

Thanks for nudging me in the right direction @JacopoMangiavacchi! I forgot you can downgrade to Python 3.8.

I finally got things working with these modifications that takes into account,

  1. There's an ARM Miniconda (yay!)
  2. There's Python 3.8 there
  3. A lot of the packages we need, such as Numpy, is already there (Yay again!)
  4. The great work @hoytak did to build TensorFlow for ARM.

So what I did to get things finally working,

  1. Download the archive for this repo from https://github.com/apple/tensorflow_macos/releases
  2. I downloaded Miniconda from https://conda-forge.org/blog/posts/2020-10-29-macos-arm64/
  3. Install Miniconda
  4. Once it's installed, create a Python 3.8 env by running conda create --name python38 python=3.8
  5. Because it's a new env, there's no way you have any packages like Tensorflow on there already (good) so...
  6. Run this script:
# Put a path to where the arm64 libraries are. For example...
libs="/Users/Matthew/Downloads/tensorflow_macos/arm64/"

# Replace this with the path of your Conda environment
env="/Users/Matthew/miniforge3/envs/python38"

# The rest should work
conda upgrade -c conda-forge pip setuptools cached-property six

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl"

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/h5py-2.10.0-cp38-cp38-macosx_11_0_arm64.whl"

# pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/numpy-1.18.5-cp38-cp38-macosx_11_0_arm64.whl"

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/tensorflow_addons-0.11.2+mlcompute-cp38-cp38-macosx_11_0_arm64.whl"

conda install -c conda-forge -y absl-py
conda install -c conda-forge -y astunparse
conda install -c conda-forge -y gast
conda install -c conda-forge -y opt_einsum
conda install -c conda-forge -y termcolor
conda install -c conda-forge -y typing_extensions
conda install -c conda-forge -y wheel
conda install -c conda-forge -y typeguard

pip install tensorboard

pip install wrapt flatbuffers tensorflow_estimator google_pasta keras_preprocessing protobuf

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/tensorflow_macos-0.1a0-cp38-cp38-macosx_11_0_arm64.whl"

This worked so well!!! thanks!

@shreyasdangare
Copy link

Hey everyone so I followed the steps and I'm getting this error when running the script.

Note: I copied it to a text edit file ( cleared formatting ), copied path to my tensorflow download and conda env and pasted them in. Then I saved it as a .sh file. Ran chmod +x filename.sh, then ./filename to execute.

This is what I got as an error:

Processing /Users/user/tensorflow_macos/arm64/tensorflow_macos-0.1a0-cp38-cp38-macosx_11_0_arm64.whl
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/Users/user/tensorflow_macos/arm64/tensorflow_macos-0.1a0-cp38-cp38-macosx_11_0_arm64.whl'```

Change 0.1a0 to 0.1a1 in path

@sohaaan
Copy link

sohaaan commented Jan 25, 2021

I successfully did everything, yet while launching Spyder or Jupyter Notebook the following error occurred.

Traceback (most recent call last):
File "/Users/sohanmahmud/miniforge3/envs/tf1/bin/spyder", line 7, in 
from spyder.app.start import main
File "/Users/sohanmahmud/miniforge3/envs/tf1/lib/python3.8/site-packages/spyder/app/start.py", line 35, in 
from spyder.utils.external import lockfile
File "/Users/sohanmahmud/miniforge3/envs/tf1/lib/python3.8/site-packages/spyder/utils/external/lockfile.py", line 31, in 
from spyder.utils.programs import is_spyder_process
File "/Users/sohanmahmud/miniforge3/envs/tf1/lib/python3.8/site-packages/spyder/utils/programs.py", line 30, in 
import psutil
File "/Users/sohanmahmud/miniforge3/envs/tf1/lib/python3.8/site-packages/psutil/__init__.py", line 159, in 
from . import _psosx as _psplatform
File "/Users/sohanmahmud/miniforge3/envs/tf1/lib/python3.8/site-packages/psutil/_psosx.py", line 15, in 
from . import _psutil_osx as cext
ImportError: dlopen(/Users/sohanmahmud/miniforge3/envs/tf1/lib/python3.8/site-packages/psutil/_psutil_osx.cpython-38-darwin.so, 2): no suitable image found. Did find:
/Users/sohanmahmud/miniforge3/envs/tf1/lib/python3.8/site-packages/psutil/_psutil_osx.cpython-38-darwin.so: mach-o, but wrong architecture
/Users/sohanmahmud/miniforge3/envs/tf1/lib/python3.8/site-packages/psutil/_psutil_osx.cpython-38-darwin.so: mach-o, but wrong architecture

what can I do?

@isuruf
Copy link

isuruf commented Jan 25, 2021

How did you install psutil? conda install psutil?

@sohaaan
Copy link

sohaaan commented Jan 25, 2021

I didn't install that. I just followed the 18 steps. then run spyder from anaconda under my environment tf1, than it showed this message.

However, I executed the following codes

conda install -n tf1 tensorflow-addons -c isuruf/label/tf -c conda-forge

conda update -n tf1 tensorflow -c isuruf/label/tf -c conda-forge

conda install -n tf1 -c conda-forge notebook

conda install -n tf1 -c anaconda ipykernel

Now, it seems, Jupyter Notebook can be opened from terminal(not from anaconda) under tf1 environment.... but still tensorflow module was not found when i ran the code

@km5ar
Copy link

km5ar commented Jan 30, 2021

EDIT: DO NOT USE THIS. Well you can, it didn't work for me after all, but you can try. I posted an updated version of this, in light of some new updates in the world of Miniconda, later in this post.

Thanks @grwche! For those installing this on ARM, the libraries are slightly different, so here was my version.

  1. Download the archive from https://github.com/apple/tensorflow_macos/releases
  2. Run the below in a bash terminal and replace the first two variables.
# If you have Tensorflow in your env, you must install it first -- uncomment this line if you're in this boat
# pip uninstall tensorflow tensorboard

# Put a path to where the arm64 libraries are. For example...
libs="/Users/Matthew/Downloads/tensorflow_macos/arm64/"

# Replace this with the name of your Conda environment
env="tensorflow"

# The rest should work
pip install --upgrade pip wheel setuptools cached-property six

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl"

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/h5py-2.10.0-cp38-cp38-macosx_11_0_arm64.whl"

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/numpy-1.18.5-cp38-cp38-macosx_11_0_arm64.whl"

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/tensorflow_addons-0.11.2+mlcompute-cp38-cp38-macosx_11_0_arm64.whl"

pip install absl-py astunparse flatbuffers gast google_pasta keras_preprocessing opt_einsum protobuf tensorflow_estimator termcolor typing_extensions wrapt wheel tensorboard typeguard

pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/tensorflow_macos-0.1a0-cp38-cp38-macosx_11_0_arm64.whl"
Last login: Sat Jan 30 18:07:46 on ttys001
(base) keyu@x86_64-apple-darwin13 ~ % libs="/Users/keyu/Desktop/tensorflow_macos/arm64/"
(base) keyu@x86_64-apple-darwin13 ~ % env="tensorflow_conda"
(base) keyu@x86_64-apple-darwin13 ~ % pip install --upgrade pip wheel setuptools cached-property six
Requirement already satisfied: pip in ./opt/anaconda3/lib/python3.8/site-packages (20.3.3)
Requirement already satisfied: wheel in ./opt/anaconda3/lib/python3.8/site-packages (0.36.2)
Requirement already satisfied: setuptools in ./opt/anaconda3/lib/python3.8/site-packages (52.0.0.post20210125)
Requirement already satisfied: six in ./opt/anaconda3/lib/python3.8/site-packages (1.15.0)
Collecting cached-property
  Using cached cached_property-1.5.2-py2.py3-none-any.whl (7.6 kB)
Collecting pip
  Using cached pip-21.0.1-py3-none-any.whl (1.5 MB)
Installing collected packages: pip, cached-property
  Attempting uninstall: pip
    Found existing installation: pip 20.3.3
    Uninstalling pip-20.3.3:
      Successfully uninstalled pip-20.3.3
Successfully installed cached-property-1.5.2 pip-21.0.1
(base) keyu@x86_64-apple-darwin13 ~ % pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl"
ERROR: grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl is not a supported wheel on this platform.
(base) keyu@x86_64-apple-darwin13 ~ % 

I'm getting an error "ERROR: grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl is not a supported wheel on this platform."

@mwidjaja1
Copy link

@km5ar Please refer to the merge request #63 which explicitly says Miniforge (Anaconda is not supported for ARM)

@NdodaEnde
Copy link

Btw, you don't need to follow steps from that link. If you are starting new, the steps are

  1. Install miniforge from https://github.com/conda-forge/miniforge#miniforge3
  2. conda create -n python38 tensorflow-addons tensorflow -c isuruf/label/tf -c conda-forge
  3. conda activate python38

while trying to extract tar file I get this error "tar: Error opening archive: Failed to open 'tensorlow_macos-0.1alpha2.tar'. kindly assist

@NdodaEnde
Copy link

Btw, you don't need to follow steps from that link. If you are starting new, the steps are

  1. Install miniforge from https://github.com/conda-forge/miniforge#miniforge3
  2. conda create -n python38 tensorflow-addons tensorflow -c isuruf/label/tf -c conda-forge
  3. conda activate python38

while trying to extract tar file I get this error "tar: Error opening archive: Failed to open 'tensorlow_macos-0.1alpha2.tar'. kindly assist

found my mistake....left an 'f' on TensorFlow..
my bad

@NdodaEnde
Copy link

now am stuck on step 10. this is the error I get after trying to install pip

(python38-demo-v1) luzuko@Luzukos-MacBook-Air arm64 % pip installl --upgrade -t “$env/lib/python3.8/site-packages/” --no-dependencies -–force “$libs/grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl”

Usage:
pip install [options] [package-index-options] ...
pip install [options] -r [package-index-options] ...
pip install [options] [-e] ...
pip install [options] [-e] ...
pip install [options] <archive url/path> ...

no such option: -–

@NdodaEnde
Copy link

so I downgraded pip to pip==20.2.4. now this is the error I get:
Screenshot 2021-02-11 at 09 11 30

kindly assist.
thanks.

@NdodaEnde
Copy link

so I downgraded pip to pip==20.2.4. now this is the error I get:
Screenshot 2021-02-11 at 09 11 30

kindly assist.
thanks.

So I removed the quotation marks(" ") in front of libs and it worked fine for both this and h5py installations. but its giving me the same error for TensorFlow_addons.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests