Skip to content

Instantly share code, notes, and snippets.

@corenel
Created January 11, 2018 02:59
Show Gist options
  • Save corenel/3c7bc8692b7be1afd4ba7b2c7db4c98f to your computer and use it in GitHub Desktop.
Save corenel/3c7bc8692b7be1afd4ba7b2c7db4c98f to your computer and use it in GitHub Desktop.
Install PyTorch 0.4.0 on macOS High Sierra 10.13.2 with GTX1080Ti, CUDA 9.1 and cuDNN 7
  1. 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
  1. 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
  1. Install dependencies:
$ pip3 install numpy pyyaml setuptools cmake cffi
  1. Clone PyTorch
$ git clone --recursive https://github.com/pytorch/pytorch
$ cd pytorch
  1. Configure, build and install:
$ MACOSX_DEPLOYMENT_TARGET=10.13 CC=clang CXX=clang++ python3 setup.py install
  1. 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)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment