How to Install Pytorch on MacOS?
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
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
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
Step 4: Check if Pytorch is successfully installed by entering the following command in the command prompt.
pip3 show torch
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
Step 2: Check if conda is installed by entering the following command in Anaconda Prompt.
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
Step 4: Check if Pytorch is successfully installed by entering the following command in Anaconda prompt.
conda list -f pytorch
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
Share your thoughts in the comments
Please Login to comment...