- Since CUDA 9.1 doesn't support LLVM 9.0.0, you need to install Command Line Tool 8.3.2 and switch:
$ sudo xcode-select --switch /Library/Developer/CommandLineTools/
$ clang --version
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin17.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
- CTL 8.3.2 is supposed for macOS Sierra 10.12, so you also need to create a symbol link for SDK.
$ sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX10.12.sdk /Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk
- Install dependencies:
$ pip3 install numpy pyyaml setuptools cmake cffi
- Clone PyTorch
$ git clone --recursive https://github.com/pytorch/pytorch
$ cd pytorch
- Configure, build and install:
$ MACOSX_DEPLOYMENT_TARGET=10.13 CC=clang CXX=clang++ python3 setup.py install
- Validate
>>> import torch
>>> x = torch.cuda.FloatTensor(5, 3)
>>> print(x)
-0.0000 -593.0276 13.3445
0.0000 0.0000 0.0000
0.0000 0.0000 nan
nan nan nan
nan nan nan
[torch.cuda.FloatTensor of size 5x3 (GPU 0)]