9951 explained code solutions for 126 technologies


python-pytorchHow do I install PyTorch on a Mac?


  1. Prerequisites:

    • Python 3.6 or later
    • macOS 10.14 or later
    • Xcode 11.3 or later
  2. Install PyTorch:

    • Open a terminal window and run the following command:
      pip3 install torch torchvision
  3. Confirm installation:

    • To confirm that PyTorch is installed correctly, run the following command:
      python3 -c "import torch; print(torch.__version__)"
    • Output: 1.7.1
  4. Install required dependencies:

    • Install additional dependencies, such as cffi and numpy, with the following command:
      pip3 install cffi numpy
  5. Install additional packages:

    • Install additional packages, such as Jupyter Notebook and Matplotlib, with the following command:
      pip3 install jupyter matplotlib
  6. Verify installation:

    • To verify that the installation is correct, run the following command:
      python3 -c "import torch; import jupyter; import matplotlib"
    • If there are no errors, the installation is successful.
  7. Further information:

Edit this code on GitHub