Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
How to Install PyBrain on MacOS?
Next article icon

How to Install Pytorch on MacOS?

Last Updated : 08 Sep, 2021
Comments
Improve
Suggest changes
Like Article
Like
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:

  • Python
  • Python-pip or Anaconda-conda should be installed.

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.


Next Article
How to Install PyBrain on MacOS?
author
anilabhadatta
Improve
Article Tags :
  • Python
  • How To
  • Installation Guide
  • Python-PyTorch
  • how-to-install
Practice Tags :
  • python

Similar Reads

  • How to Install PyBrain on MacOS?
    PyBrain is an open-source and free-to-use Python-based Machine Learning Library. Its main purpose is to provide machine learning tasks with flexible, easy-to-use, still a very powerful algorithms. It also provides a wide range of predefined environments which is used to test and compare different ty
    2 min read
  • How to Install PyUSB on MacOS?
    In this article, we will learn how to install PyUSB in Python on MacOS. The PyUSB module provides for Python easy access to the host machine's Universal Serial Bus (USB) system. Installation:Method 1: Using pip to install PyUSB Follow the below steps to install pyusb package on macOS using pip: Step
    2 min read
  • How to Install PIL on MacOS?
    PIL is an acronym for the python image library. It is a library that is used to manipulate images, using PIL library with python we can perform various operations on images. In this article, we are going to learn how we can install PIL on MacOS. Method 1: Using PIP to install PIL (Pillow). Python co
    1 min read
  • How to Install Theano on MacOS?
    Theano is a Python library that allows us to evaluate mathematical operations including multi-dimensional arrays so efficiently. It is mostly used in building Deep Learning Projects. It works way faster on Graphics Processing Unit (GPU) rather than on the CPU. In this article, we will look into the
    1 min read
  • How to Install Pillow on MacOS?
    In this article, we will learn how to install Pillow in Python on MacOS. Python Imaging Library (expansion of PIL) is the de facto image processing package for Python language. Installation:Method 1: Using pip to install Pillow Follow the below steps to install the Pillow package on macOS using pip:
    2 min read
  • How to Install Python sympy on MacOS?
    Sympy is a lightweight, open-source Python library for symbolic math. Its vision is to become a fully functional computer algebra system while keeping the code as simple, understandable, and extensible as possible. Sympy relies only on mpmath, a pure Python library for arbitrary floating-point arith
    2 min read
  • How to Install Seaborn on MacOS?
    In this article, we will learn how to install seaborn in Python on MacOS. Seaborn is a library for making statistical graphics in Python. It is built on top of matplotlib and is closely integrated with pandas data structures. Installation:Method 1: Using pip to install Seaborn Package Follow the bel
    2 min read
  • How to Install Tkinter on MacOS?
    In this article, we will learn how to install Tkinter in Python on MacOS. Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit, and is Python's de-facto standard GUI. Installation:Method 1: Using pip to install Tkinter Follow the below steps to
    2 min read
  • How to Install ReactJS on MacOS
    Are you looking to set up ReactJS on your Mac? Whether you’re using a MacBook Air, MacBook Pro, iMac, or any macOS version like Monterey, Ventura, Big Sur, or macOS 15 Sequoia, this step-by-step guide is here to help. ReactJS, the popular JavaScript library for building dynamic user interfaces, requ
    4 min read
  • How to Install Opencv 4 on MacOS?
    In this article, we will learn how to install Opencv 4 in Python on MacOS. OpenCV (Open Source Computer Vision Library) is a library of programming functions mainly aimed at real-time computer vision. Installation:Method 1: Using pip to install Opencv 4 Package Follow the below steps to install the
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences