Menu toggle

How to setup PyTorch on a Mac

Both Mac OS X and Linux are based on the Unix operating system. Therefore your Mac has a pre-installed command-line environment running a shell that is essentially Bash.

  • First open the terminal application on your Mac.

  • To setup PyTorch:

    • If it's not already installed on your system make sure you have Python 3. Download the correct MacOS installer from https://www.python.org/downloads/mac-osx/ and use it to install Python3.

    • Scroll to the QUICK START LOCALLY part of pytorch.org.

    • Choose Stable, Mac, conda, Python, and None and cut and paste and run each line that doesn't start with # in the Run this command box into your terminal on your Mac. If you find out that you don't have conda installed, change the settings to use pip instead.

      Note: the QUICK START LOCALLY part of pytorch.org might kick out the command

      pip install torch torchvision

      Instead, use this

      /usr/bin/pip3 install torch torchvision

      See our page Installing Python Packages for more best practice when installing software.

    • Check and see if PyTorch installed successfully by opening the Python interpreter (by entering python3 at the command line) and entering import torch. You shouldn't see an error. (Hit control-d to exit the interpreter.)