Contributed by Mark (Zixuan) Song
.. warning::
This page is deprecated. Please visit the update tutorial <development_Mac.html>
_ for the latest information.
For completely new macos or macos without xcode and brew
Need graphical access to the machine.
Run xcode-select --install
to install if on optimal internet.
Or Download from Apple Command Line Tools installation image then install if internet connection is weak.
Due to the limitation of MacOS and packages, the lastest version of python does not always function as desired, thus miniconda installation is advised to solve the issues.
curl -o ~/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
source ~/miniconda/bin/activate
conda install -c apple tensorflow-deps
pip install numpy scipy tensornetwork networkx
There are four backends to choose from, Numpy, Tensorflow, Jax, Torch.
pip install [Package Name]
conda config --add channels conda-forge
conda config --set channel_priority strict
conda create -n tc_venv python tensorflow=2.7
import tensorflow as tf
cifar = tf.keras.datasets.cifar100
(x_train, y_train), (x_test, y_test) = cifar.load_data()
model = tf.keras.applications.ResNet50(
include_top=True,
weights=None,
input_shape=(32, 32, 3),
classes=100,)
loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)
model.compile(optimizer="adam", loss=loss_fn, metrics=["accuracy"])
model.fit(x_train, y_train, epochs=5, batch_size=64)
For tensorflow version 2.13 or later:
pip install tensorflow
pip install tensorflow-metal
For tensorflow version 2.12 or earlier:
pip install tensorflow-macos
pip install tensorflow-metal
import tensorflow as tf
cifar = tf.keras.datasets.cifar100
(x_train, y_train), (x_test, y_test) = cifar.load_data()
model = tf.keras.applications.ResNet50(
include_top=True,
weights=None,
input_shape=(32, 32, 3),
classes=100,)
loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)
model.compile(optimizer="adam", loss=loss_fn, metrics=["accuracy"])
model.fit(x_train, y_train, epochs=5, batch_size=64)
pip install tensorcircuit
Testing Platform (Tested Jun 2023)
- Platform 1:
- MacOS Ventura 13.1 (Build version 22C65)
- M1 Ultra
- Platform 2:
- MacOS Ventura 13.2 (Build version 22D49)
- M1 Ultra (Virtual)
- Platform 4:
- MacOS Sonoma 14.0 Beta 2 (Build version 23A5276g)
- M2 Max