apple / tensorflow_macos

TensorFlow for macOS 11.0+ accelerated using Apple's ML Compute framework.
Other
3.67k stars 308 forks source link

Tricky step to install SciPy and TensorBoard for M1 chip #184

Open maestrofx opened 3 years ago

maestrofx commented 3 years ago

Hi,

This is not an issue, but a simple trick to successfully install SciPy in the same environment the tensorflow_macos in M1. Should we update this README?

...
Notes
For Macs with M1, the following packages are currently unavailable:

SciPy and dependent packages
Server/Client TensorBoard packages
...

Tricky part

Install all the packages first before the tensorflow_macos script executed

I've been playing around with multiple virtual environments to up and running all the packages I need. So far, it works by managing the packages using miniforge.

# Packages to install via conda (that fails in pip)
# E.g: scikit-learn, scipy
tf_venv="YOUR_VENV"
conda install -c conda-forge -n $tf_venv scipy scikit-learn

Your conda venv:

tensorflow_macos git:(master) ✗ conda info -e
# conda environments:
#
base                    /opt/homebrew/Caskroom/miniforge/base
YOUR_VENV   *  /opt/homebrew/Caskroom/miniforge/base/envs/YOUR_VENV

Step to reproduce.

  1. Install Python 3.8 using miniforge via brew or pyenv.
    
    # Install miniforge using brew
    brew install miniforge

tf_venv="YOUR_VENV"

Create TF virtual environment using conda

conda create -n $tf_venv python=3.8

Init the shell

conda init "$(basename "${SHELL}")"

Activate the virtual env

conda activate $tf_venv

2. Install the packages using `conda` not `pip`

```shell
# Packages to install via conda (that fails in pip)
# E.g: scikit-learn, scipy
tf_venv="YOUR_VENV"
conda install -c conda-forge -n $tf_venv scipy scikit-learn
  1. Install this repo tensorflow_macos to the existing virtual environment instead of creating the new one. This line,
    Path to new or existing virtual environment [default: /Users/fx/tensorflow_macos_venv/]:

    Change to /opt/homebrew/Caskroom/miniforge/base/envs/YOUR_VENV/

    Path to new or existing virtual environment [default: /Users/fx/tensorflow_macos_venv/]: /opt/homebrew/Caskroom/miniforge/base/envs/YOUR_VENV/
➜  tensorflow_macos git:(master) ✗ ./scripts/download_and_install.sh

Installation script for pre-release tensorflow_macos 0.1alpha2.  Please visit https://github.com/apple/tensorflow_macos
for instructions and license information.

This script will download tensorflow_macos 0.1alpha2 and needed binary dependencies, then install them into a new
or existing Python 3.8 virtual environment.
Continue [y/N]? y

Downloading installer.
/var/folders/22/vz4qt0tn5v59rdq4b653mn000000gn/T/tmp.J6kIvMRX ~/tensorflow_macos
Extracting installer.
Path to new or existing virtual environment [default: /Users/fx/tensorflow_macos_venv/]:

Expected result

image

and

image

Thank you.