

This post explains how I managed to do that. This setup works well for me, and I’d like to keep it. For managing virtual environments, I use venv which is Python’s relatively new, built-in implementation of virtual environments. But, for all my projects, both work and personal, I use Homebrew for managing non-Python dependencies and pip for Python-dependencies. In this short post, I will show you how to get TensorFlow up and running with GPU support on your Apple Silicon Mac without installing Miniforge or anything else related to Conda!įirst a quick bit of background. If you are like me and already have a setup for running virtual environments that does not involve Conda, and you’d like to keep it that way, Apple’s instructions are not very helpful. Unfortunately, Apple’s installation instructions are not very clear, and they expect you to use a mix of conda and pip. With the release of Apple Silicon Macs, we finally have a way to (easily) install and run TensorFlow with GPU support on macOS. TLDR Run brew install hdf5, then pip install tensorflow-macos and finally pip install tensorflow-metal. Open the Activity Monitor and you can see that Python is using GPU resources.TensorFlow with GPU support on Apple Silicon Mac with Homebrew and without Conda / Miniforge evaluate ( test_images, test_labels ) test_acc fit ( train_images, train_labels, epochs = 5, batch_size = 64 ) test_loss, test_acc = model. compile ( optimizer = 'rmsprop', loss = 'categorical_crossentropy', metrics = ) model. astype ( 'float32' ) / 255 train_labels = to_categorical ( train_labels ) test_labels = to_categorical ( test_labels ) model. astype ( 'float32' ) / 255 test_images = test_images. load_data () train_images = train_images. Install Xcode Command Line Tools by downloading it from Apple Developer or by typing:įrom import mnist from import to_categorical ( train_images, train_labels ), ( test_images, test_labels ) = mnist. This article serves as an update of the Apple Silicon Mac M1/M2 Machine Learning Environment (TensorFlow, JupyterLab, VSCode), and will give you a detailed introduction to how to install the latest supported GPU Accelerated TensorFlow. You can now leverage Apple’s tensorflow-metal PluggableDevice in TensorFlow v2.5 for accelerated training on Mac GPUs directly with Metal. A few days ago, I saw that has been archived, and the README stated that TensorFlow v2.5 natively supports M1.
