Tensorexperiments
Boilerplate for GPU-Accelerated TensorFlow and PyTorch code on M1 Macbook
Install / Use
/learn @alexfromapex/TensorexperimentsREADME
What is this repo?
- Quick start boilerplate for GPU acceleration working with Tensorflow and PyTorch on Macbook Air M1 (ARM-64 architecture)
- Uses Metal to access the GPU capabilities
- Doesn't require Conda / Miniforge
- Doesn't need a Jupyter notebook
- Works with Python 3.8
- Dependencies installed via Pyenv and Poetry
Before doing anything else
- Install Homebrew
- Run
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
- Run
- Run
brew install hdf5 pyenv pyenv-virtualenv - Run
export HDF5_DIR="$(brew --prefix hdf5)"; - Add the following lines to your
~/.zprofilefile if using Zsh or~/.bash_profilefile if using Bash (you can check Zsh vs Bash by typingecho $SHELLin your terminal):
export PATH="$HOME/.poetry/bin:$PATH";
export PYENV_VIRTUALENV_DISABLE_PROMPT=0;
eval "$(pyenv init -)";
eval "$(pyenv virtualenv-init -)";
- Restart your terminal or reload the profile, e.g.
source ~/.zprofileorsource ~/.bash_profile - Install Poetry, by running
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - - Install Python 3.8 into Pyenv, by running
pyenv install 3.8.10 - Create a Pyenv virtual environment to work in, by running
pyenv virtualenv 3.8.10 tfexperiment - Activate the Pyenv virtual environment, by running
pyenv activate 3.8.10/envs/tfexperiment - Check that
python --versionsays3.8.10andwhich pythonsays something like/Users/.../.pyenv/shims/python - Finally,
cdto the directory with thepyproject.tomlfile, then runpoetry install
Getting Started with TensorFlow
- After following steps above in "Before anything else" section, running
poetry run tfshould execute the code insrc/tf.py
Getting Started with PyTorch
- If you want only PyTorch and its dependencies, check out the
torchbranch - Run
poetry installto install the Nightly build of PyTorch - Run
poetry run torchto check if everything is working - Modify
tensorexperiments/torch.pyas needed - You will want to use
torch.device('mps')to leverage GPU capabilities
Troubleshooting
- H5Py
- If you have an issue with H5Py:
- Make sure you have run
export HDF5_DIR="$(brew --prefix hdf5)"; - install with
pip install --no-binary=h5py h5py
- Make sure you have run
- If you have an issue with H5Py:
Related Skills
node-connect
353.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
111.7kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
111.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
353.3kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
