Skip to content

sainatarajan/pytorch-mps-convtranspose3d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

Installing PyTorch for Apple MPS with ConvTranspose3D Support

This guide provides step-by-step instructions for installing PyTorch with support for Apple Metal Performance Shaders (MPS) including ConvTranspose3D operations, which aren't available in the standard PyTorch distribution.

Prerequisites

  • macOS with Apple Silicon (M1/M2/M3) or compatible GPU
  • Python 3.7+
  • Git

Installation Steps

  1. Clone the PyTorch repository from GitHub:
git clone https://github.com/pytorch/pytorch
  1. Install the specific CMake version required:
pip install cmake==3.26.4
  1. Verify the CMake installation:
cmake --version
  1. Navigate to the PyTorch directory:
cd pytorch
  1. Fetch the specific pull request that adds ConvTranspose3D support for MPS:
git fetch origin pull/145366/head:ts_export
  1. Checkout the branch with the necessary changes:
git checkout ts_export
  1. Synchronize Git submodules:
git submodule sync
  1. Initialize and update all submodules recursively:
git submodule update --init --recursive
  1. Build and install PyTorch:
python setup.py install

Verification

To verify the installation has ConvTranspose3D support on MPS, you can run:

import torch
x = torch.randn(1, 3, 10, 10, 10).to('mps')
conv = torch.nn.ConvTranspose3d(3, 5, 3, stride=2, padding=1).to('mps')
output = conv(x)
print(f"Output shape: {output.shape}")

Notes

  • The installation process can take significant time (30-60 minutes depending on your system).
  • This builds PyTorch from source, so you'll need sufficient disk space (10+ GB).
  • The specific pull request referenced adds support for ConvTranspose3D operations on Apple's MPS backend.

Troubleshooting

If you encounter build errors:

  • Ensure you have Xcode Command Line Tools installed
  • Make sure you're using the correct version of CMake
  • Try increasing the resources allocated to the build with MAX_JOBS=8 before the install command

About

Guide for installing PyTorch with Apple MPS and ConvTranspose3D support for 3D Medical Imaging tasks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors