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

Commit f9c03c3

Browse files
author
Hoyt Koepke
committed
Initial commit.
0 parents  commit f9c03c3

File tree

5 files changed

+509
-0
lines changed

5 files changed

+509
-0
lines changed

Diff for: ATTRIBUTIONS.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Attributions
2+
3+
We include binary wheels of the following open source packages compiled for macOS 11.0:
4+
5+
- NumPy: https://github.com/numpy/numpy
6+
- SciPy: https://github.com/scipy/scipy
7+
- gRPC: https://github.com/grpc/grpc
8+
- h5py: https://github.com/h5py/h5py
9+
10+

Diff for: LICENSE.txt

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Copyright (C) 2020 Apple Inc. All Rights Reserved.
2+
3+
IMPORTANT: This Apple software is supplied to you by Apple
4+
Inc. ("Apple") in consideration of your agreement to the following
5+
terms, and your use, installation, modification or redistribution of
6+
this Apple software constitutes acceptance of these terms. If you do
7+
not agree with these terms, please do not use, install, modify or
8+
redistribute this Apple software.
9+
10+
In consideration of your agreement to abide by the following terms, and
11+
subject to these terms, Apple grants you a personal, non-exclusive
12+
license, under Apple's copyrights in this original Apple software (the
13+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
14+
Software, with or without modifications, in source and/or binary forms;
15+
provided that if you redistribute the Apple Software in its entirety and
16+
without modifications, you must retain this notice and the following
17+
text and disclaimers in all such redistributions of the Apple Software.
18+
Neither the name, trademarks, service marks or logos of Apple Inc. may
19+
be used to endorse or promote products derived from the Apple Software
20+
without specific prior written permission from Apple. Except as
21+
expressly stated in this notice, no other rights or licenses, express or
22+
implied, are granted by Apple herein, including but not limited to any
23+
patent rights that may be infringed by your derivative works or by other
24+
works in which the Apple Software may be incorporated.
25+
26+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
27+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
28+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
29+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
30+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
31+
32+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
33+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
36+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
37+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
38+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
39+
POSSIBILITY OF SUCH DAMAGE.
40+

Diff for: README.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
## Mac-optimized TensorFlow and TensorFlow Addons
2+
3+
### INTRODUCTION
4+
5+
This pre-release delivers hardware-accelerated TensorFlow and TensorFlow Addons for macOS 11.0+. Native hardware acceleration is supported on Macs with M1 and Intel-based Macs through Apple’s [ML Compute](https://developer.apple.com/documentation/mlcompute) framework.
6+
7+
### SUPPORTED VERSIONS
8+
9+
- TensorFlow r2.4rc0
10+
- TensorFlow Addons 0.11.2
11+
12+
### REQUIREMENTS
13+
14+
- macOS 11.0+
15+
16+
### INSTALLATION
17+
18+
An archive containing Python packages and an installation script can be downloaded from the [releases](https://github.com/apple/tensorflow_macos/releases).
19+
20+
#### Details
21+
22+
- To quickly try this out, copy and paste the following into Terminal:
23+
24+
```
25+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/apple/tensorflow_macos/master/scripts/download_and_install.sh)"
26+
```
27+
This will verify your system, ask you for confirmation, then create a [virtual environment](https://docs.python.org/3.8/tutorial/venv.html) with TensorFlow for macOS installed.
28+
29+
- Alternatively, download the archive file from the [releases](https://github.com/apple/tensorflow_macos/releases). The archive contains an installation script,
30+
accelerated versions of TensorFlow, TensorFlow Addons, and needed dependencies.
31+
32+
#### Notes
33+
34+
For Macs with M1, the following packages are currently unavailable:
35+
- SciPy and dependent packages
36+
- Server/Client TensorBoard packages
37+
38+
### ISSUES AND FEEDBACK
39+
40+
Feedback is welcomed!
41+
42+
Please submit feature requests or report issues via [GitHub Issues](https://github.com/apple/tensorflow_macos/issues).
43+
44+
### ADDITIONAL INFORMATION
45+
46+
#### Device Selection (Optional)
47+
48+
It is not necessary to make any changes to your existing TensorFlow scripts to use ML Compute as a backend for TensorFlow and TensorFlow Addons.
49+
50+
There is an optional `mlcompute.set_mlc_device(device_name=’any')` API for ML Compute device selection. The default value for `device_name` is `'any’`, which means ML Compute will select the best available device on your system, including multiple GPUs on multi-GPU configurations. Other available options are `‘cpu’` and `‘gpu’`. Please note that in eager mode, ML Compute will use the CPU. For example, to choose the CPU device, you may do the following:
51+
52+
# Import mlcompute module to use the optional set_mlc_device API for device selection with ML Compute.
53+
from tensorflow.python.compiler.mlcompute import mlcompute
54+
55+
# Select CPU device.
56+
mlcompute.set_mlc_device(device_name=‘cpu’) # Available options are 'cpu', 'gpu', and ‘any'.

Diff for: scripts/download_and_install.sh

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#/bin/bash
2+
3+
set -e
4+
5+
VERSION=0.1alpha0
6+
INSTALLER_PACKAGE=tensorflow_macos-$VERSION.tar.gz
7+
INSTALLER_PATH=https://github.com/apple/tensorflow_macos/releases/download/v0.1alpha0/tensorflow_macos-0.1alpha0.tar.gz
8+
INSTALLER_SCRIPT=install_venv.sh
9+
10+
echo
11+
12+
# Check to make sure we're good to go.
13+
if [[ $(uname) != Darwin ]] || [[ $(sw_vers -productName) != macOS ]] || [[ $(sw_vers -productVersion) != "11."* ]] ; then
14+
echo "ERROR: TensorFlow with ML Compute acceleration is only available on macOS 11.0 and later."
15+
exit 1
16+
fi
17+
18+
# This
19+
echo "Installation script for pre-release tensorflow_macos 0.1alpha0. Please visit https://github.com/apple/tensorflow_macos "
20+
echo "for instructions and license information."
21+
echo
22+
echo "This script will download tensorflow_macos 0.1alpha0 and needed binary dependencies, then install them into a new "
23+
echo "or existing Python 3.8 virtual enviornoment."
24+
25+
# Make sure the user knows what's going on.
26+
read -p 'Continue [y/N]? '
27+
28+
if [[ ! $REPLY =~ ^[Yy]$ ]]
29+
then
30+
exit 1
31+
fi
32+
echo
33+
34+
echo "Downloading installer."
35+
tmp_dir=$(mktemp -d)
36+
37+
pushd $tmp_dir
38+
39+
curl -LO $INSTALLER_PATH
40+
41+
echo "Extracting installer."
42+
tar xf $INSTALLER_PACKAGE
43+
44+
cd tensorflow_macos
45+
46+
function graceful_error () {
47+
echo
48+
echo "Error running installation script with default options. Please fix the above errors and proceed by running "
49+
echo
50+
echo " $PWD/$INSTALLER_SCRIPT --prompt"
51+
echo
52+
echo
53+
exit 1
54+
}
55+
56+
bash ./$INSTALLER_SCRIPT --prompt || graceful_error
57+
58+
popd
59+
rm -rf $tmp_dir
60+
61+
62+
63+
64+
65+
66+
67+
68+
69+

0 commit comments

Comments
 (0)