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

Fixing Install Script Typo & adding Conda Install Support #63

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ An archive containing Python packages and an installation script can be download

- Alternatively, download the archive file from the [releases](https://github.com/apple/tensorflow_macos/releases). The archive contains an installation script, accelerated versions of TensorFlow, TensorFlow Addons, and needed dependencies.

#### Notes
#### Conda
Alternatively, you can download Miniforge Python (which has the Conda package manager) and install TensorFlow on it.

1. Download a Python 3.8 for Apple Silicon ARM from https://github.com/conda-forge/miniforge/#download and install it.
2. [Optional] Create a Python 3.8 Conda Environment for TensorFlow
3. Download the archive file from the [releases](https://github.com/apple/tensorflow_macos/releases)
4. Run `scripts/install_venv.sh --prompt` and at the prompt, provide the path to your environment's directory. For example: `~/miniforge3/envs/tensorflow` if your env name is `tensorflow` and you installed Miniforge ot your home directory.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
4. Run `scripts/install_venv.sh --prompt` and at the prompt, provide the path to your environment's directory. For example: `~/miniforge3/envs/tensorflow` if your env name is `tensorflow` and you installed Miniforge ot your home directory.
4. Run `scripts/install_venv.sh --prompt` and at the prompt, provide the path to your environment's directory. For example: `~/miniforge3/envs/tensorflow` if your env name is `tensorflow` and you installed Miniforge in your home directory.


#### Notes/Users/Matthew/miniforge3/envs/tensorflow

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#### Notes/Users/Matthew/miniforge3/envs/tensorflow
#### Notes


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

Expand Down
18 changes: 12 additions & 6 deletions scripts/install_venv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ set -e
arch_list_x86_64=( numpy-1.18.5-cp38-cp38-macosx_11_0_x86_64.whl
grpcio-1.33.2-cp38-cp38-macosx_11_0_x86_64.whl
h5py-2.10.0-cp38-cp38-macosx_11_0_x86_64.whl
scipy-1.5.4-cp38-cp38-macosx_11_0_x86_64.whl
scipy-1.5.4-cp38-cp38-macosx_11_0_x86_64.whl
tensorflow_addons-0.11.2+mlcompute-cp38-cp38-macosx_11_0_x86_64.whl )

arch_list_arm64=( numpy-1.18.5-cp38-cp38-macosx_11_0_arm64.whl
Expand All @@ -66,7 +66,7 @@ function usage() {
echo
echo "WARNING: Existing packages in this virtual environment may be modified."
echo
echo " -p, --prompt Prompt for the path to the virtual environment."
echo " -p, --prompt Prompt for the path to a virtual environment or conda environment."
echo
echo " --python=<python path> Path to the python executable to use."
echo
Expand Down Expand Up @@ -183,7 +183,7 @@ tf_install_message=""

# Now, see if a virtual environment was given as an argument.
if [[ -e $virtual_env ]] ; then
if [[ ! -d "$virtual_env" ]] || [[ ! -e "$virtual_env/bin/activate" ]] ; then
if [[ ! -d "$virtual_env" ]] || [[ ! -e "$virtual_env/bin/activate" ]] && [[ ! -e "$virtual_env/bin/python" ]]; then
error_exit "$virtual_env does not seem to be a virtual environment. Please specify a new directory or an existing Python 3.8 virtual environment. "
fi
create_venv=0
Expand Down Expand Up @@ -307,7 +307,12 @@ if [[ $create_venv == 1 ]] ; then
"$python_bin" -m venv "$virtual_env"
fi

. "$virtual_env/bin/activate"
# Activates virtual environment. If activate doesn't exist, it's a conda env and we can
# proceed without activating the env, since we'll be installing via conda's Python3 soon.
if [[ -e "$virtual_env/bin/activate" ]] ; then
. "$virtual_env/bin/activate"
fi

python_bin="$virtual_env/bin/python3"

export MACOSX_DEPLOYMENT_TARGET=11.0
Expand All @@ -325,7 +330,8 @@ echo ">> Installing bundled binary dependencies."

# Note: As soon python packaging supports macOS 11.0 in full, we can remove the -t hackery.
for f in ${packages[@]} ; do
"$python_bin" -m pip install --upgrade -t "$VIRTUAL_ENV/lib/python3.8/site-packages/" --no-dependencies --force "$package_dir/$f"
echo ">> Running: $python_bin" -m pip install --upgrade -t "$virtual_env/lib/python3.8/site-packages/" --no-dependencies --force "$package_dir/$f"
"$python_bin" -m pip install --upgrade -t "$virtual_env/lib/python3.8/site-packages/" --no-dependencies --force "$package_dir/$f"
done

# Manually install all the other dependencies.
Expand All @@ -336,7 +342,7 @@ echo ">> Installing dependencies."
"$python_bin" -m pip install ipython

# Install the tensorflow wheel itself
"$python_bin" -m pip install --upgrade --force -t "$VIRTUAL_ENV/lib/python3.8/site-packages/" --no-dependencies "$package_dir"/tensorflow_macos*-cp38-cp38-macosx_11_0_$arch.whl
"$python_bin" -m pip install --upgrade --force -t "$virtual_env/lib/python3.8/site-packages/" --no-dependencies "$package_dir"/tensorflow_macos*-cp38-cp38-macosx_11_0_$arch.whl

# Finally, upgrade pip to give the developers the correct version.
"$python_bin" -m pip install --upgrade pip
Expand Down