Open In App

How to Install Pytorch on MacOS?

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

PyTorch is an open-source machine learning library based on the Torch library, used for applications such as computer vision and natural language processing, primarily developed by Facebook’s AI Research lab. It is free and open-source software released under the Modified BSD license.

Prerequisites:

Installation Procedure:

Method 1: Using pip to install the required dependencies.

Step 1: Check if python3 is already installed by entering the following command in the command prompt.

python3 --version

checking python version

If this command runs successfully, and we are able to get a Python version 3.9+ then we are good to go or else install python3 by referring to this article here.

Step 2: Check if pip3 is already installed by entering the following command in the command prompt.

pip3 --version

checking pip version

If this command runs successfully, and we are able to get a pip version then we are good to go or else install pip by referring to this article here.

Step 3: Enter the following command to install the latest stable release of Pytorch.

1. Compute Platform: CPU

pip3 install torch torchvision torchaudio

installing  torch, torchvision, and torchaudio

Step 4: Check if Pytorch is successfully installed by entering the following command in the command prompt.

pip3 show torch

verifying torch installation

If this command runs successfully, and we are able to get a torch version then we are good to go or else reinstall it.

Method 2: Using conda to install the required dependencies.

Step 1: Activate Anaconda prompt if it is deactivated.

conda activate

activate conda

Step 2: Check if conda is installed by entering the following command in Anaconda Prompt.

conda --version

check conda version

If this command runs successfully, and we are able to get a conda version then we are good to go or else install Anaconda on MacOS.

Step 3: Enter the following commands to install the latest stable release of Pytorch.

1. Compute Platform : CPU

conda install pytorch torchvision torchaudio -c pytorch

installing  torch, torchvision, and torchaudioinstalling  torch, torchvision, and torchaudio

Step 4: Check if Pytorch is successfully installed by entering the following command in Anaconda prompt.

conda list -f pytorch

verifying torch installation

If this command runs successfully, and we are able to get a torch version then we are good to go or else reinstall it.


Last Updated : 08 Sep, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads