Gallery

Contacts

405 W. Greenlawn Ave Lansing, Michigan 48910

contact@techjacksolutions.com

+1-616-320-4064


PYTORCH

How to Install PyTorch (2026): Windows, Mac, Linux & CUDA

PyTorch 2.12.0 installs in under two minutes on most machines. The right command depends on three choices: your OS, whether you have an NVIDIA GPU or Apple Silicon, and whether you prefer pip or conda. This guide gives you the exact command for your setup , plus verification steps and fixes for the five most common installation errors.

PyTorch 2.12.0 , Quick Reference
2.12.0 Stable release (May 13, 2026)
3.10–3.14 Python versions supported
Free BSD-3-Clause , no licensing cost
CUDA 12.6+ CUDA 12.6, 13.0, 13.2 supported
ROCm 7.2 AMD GPU acceleration (Linux)
MPS Apple M1/M2/M3/M4 GPU support

Prerequisites , Before You Install

Before running any install command, confirm your environment meets these requirements. Skipping this step is the single most common reason installation appears to succeed but import torch fails or the wrong Python picks up the package.

Installation Prerequisites Checklist

pip vs conda: which should you use?

Use pip if you're working in a standard Python virtual environment, a Docker container, or a CI/CD pipeline. It's faster and produces smaller installs. Use conda if you're on Windows with a CUDA GPU , conda bundles the CUDA runtime libraries, so you don't need to install the CUDA toolkit separately. This is a significant time savings for new GPU setups.

Quick Install: CPU-Only (All Platforms)

If you don't have a GPU, or you just want to get started immediately, the CPU-only pip install works on Windows, macOS, and Linux with a single command.

pip , CPU-only (all platforms)
pip install torch torchvision torchaudio

This installs the three core packages: torch (the core framework), torchvision (image datasets and model zoo), and torchaudio (audio processing). All three are versioned together ; don't install them independently or you risk version mismatches.

The CPU-only package is roughly 250 MB. It runs on any hardware including laptops without dedicated GPUs. For learning, prototyping, and inference workloads on small models, CPU-only is sufficient. For training large neural networks, you'll want GPU acceleration , see the CUDA and Apple MPS sections below.

Verify basic install
python -c "import torch; x = torch.rand(5, 3); print(x)"

If you see a 5×3 matrix of random numbers, PyTorch is working correctly.

CUDA GPU Installation (Windows & Linux)

GPU-accelerated PyTorch requires matching your CUDA version to the right wheel. PyTorch 2.12.0 supports CUDA 12.6, CUDA 13.0, and CUDA 13.2. The conda approach is recommended for Windows because it bundles the CUDA libraries automatically.

Option 1: conda (recommended for Windows, easy CUDA setup)

conda , CUDA 12.6 (Windows/Linux)
conda install pytorch torchvision torchaudio pytorch-cuda=12.6 -c pytorch -c nvidia

The pytorch-cuda=12.6 flag tells conda to install the CUDA 12.6 runtime alongside PyTorch. You still need your NVIDIA GPU driver installed (run nvidia-smi to verify), but you don't need a separate CUDA toolkit installation. This is the fastest path from zero to GPU-accelerated PyTorch on Windows.

Option 2: pip with CUDA wheels

For pip-based CUDA installs, the exact command depends on your CUDA version. Use the official selector at pytorch.org/get-started/locally to generate the correct command. For CUDA 12.6, the general form is:

pip , CUDA 12.6 (Linux/Windows)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
Verify CUDA GPU is available
python -c "import torch; print(torch.cuda.is_available())"
# Expected output: True

python -c "import torch; print(torch.cuda.get_device_name(0))"
# Expected output: your GPU name, e.g. NVIDIA GeForce RTX 4090

If torch.cuda.is_available() returns False after a CUDA install, the most common causes are: NVIDIA driver not installed, CUDA version mismatch between the wheel and your driver, or a virtual environment that picked up a different PyTorch installation. See the Troubleshoot section at the end of this guide.

ROCm for AMD GPUs (Linux only)

PyTorch 2.12.0 supports AMD GPU acceleration via ROCm 7.2 on Linux. Generate the exact ROCm install command from pytorch.org/get-started/locally after selecting your AMD ROCm version. ROCm support is Linux-only ; Windows AMD GPU users should use the CPU build.

macOS Installation (Apple Silicon & Intel)

macOS installation uses pip3 regardless of whether you're on Apple Silicon or Intel. The difference is what GPU acceleration you get afterward.

Apple Silicon (M1/M2/M3/M4) , MPS acceleration

pip , macOS (Apple Silicon or Intel)
pip3 install torch torchvision torchaudio

On Apple Silicon Macs, this installs a native ARM64 build of PyTorch with Metal Performance Shaders (MPS) support included. MPS lets PyTorch use the unified memory GPU in your M-series chip , no CUDA, no extra configuration. After installing, verify MPS:

Verify Apple MPS GPU
python -c "import torch; print(torch.backends.mps.is_available())"
# Expected output: True (on Apple Silicon)

To use MPS in your code, move tensors and models to the MPS device:

Using MPS in PyTorch code
device = torch.device("mps" if torch.backends.mps.is_available() else "cpu")
model = MyModel().to(device)
x = x.to(device)

Intel Mac , CPU only

Intel Macs use the same pip3 install torch torchvision torchaudio command. PyTorch does not support CUDA on macOS (NVIDIA stopped CUDA support for macOS in CUDA 10.2). Intel Mac users get CPU-only acceleration. For GPU-accelerated training on macOS hardware, you need an Apple Silicon Mac.

macOS minimum requirement: macOS 10.15 Catalina or higher. Python 3.10–3.14 is required , the system Python on older macOS versions is typically 3.9 or earlier and is not supported.

Linux Installation

Linux is the most fully supported PyTorch platform. All CUDA versions, ROCm, and CPU builds are available. The minimum system requirement is glibc 2.28 or higher, which corresponds to Ubuntu 20.04+, Debian 10+, CentOS 8+, Fedora 24+, and Linux Mint 20+.

CPU-only (any distro)

pip , Linux CPU
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu

CUDA on Linux (pip)

pip , Linux CUDA 12.6
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126

CUDA on Linux (conda)

conda , Linux CUDA 12.6
conda install pytorch torchvision torchaudio pytorch-cuda=12.6 -c pytorch -c nvidia

NVIDIA Jetson (edge devices)

For NVIDIA Jetson platforms (Nano, TX1/TX2, Xavier NX/AGX, AGX Orin), PyTorch requires JetPack 4.2 or higher. Install using the NVIDIA-provided wheel for your JetPack version rather than standard pip , the standard wheel will not have the correct ARM library linkages.

Verify Your Installation

Run through these five verification steps in order. Each step builds on the previous , if step 2 fails, there's no point running step 4. Check each one off as you go.

Installation Verification Checklist 0 / 5 complete
  1. Basic import test python -c "import torch; print(torch.__version__)"  →  should print 2.12.0
  2. Tensor creation test python -c "import torch; x = torch.rand(5, 3); print(x)"  →  prints a 5×3 matrix
  3. CUDA availability (GPU users) python -c "import torch; print(torch.cuda.is_available())"  →  True
  4. Apple MPS check (Apple Silicon) python -c "import torch; print(torch.backends.mps.is_available())"  →  True
  5. torchvision import python -c "import torchvision; print(torchvision.__version__)"  →  should match torch version

Building from Source (Advanced)

Building from source gives you a PyTorch build customized for your exact hardware and lets you test unreleased features from the main branch. It is significantly more complex than pip or conda and is not recommended for most users.

Before You Build from Source
Time commitment
Expect 30–60 minutes on a modern CPU. Slower machines can take 2+ hours. You will need 10 GB or more of free disk space for the build artifacts.
Compiler requirement
Linux: gcc 11.3.0+ (C++20 compatible). Windows: Visual Studio with MSVC toolset. macOS: Clang from Xcode Command Line Tools.
CUDA source builds
GPU source builds additionally require CUDA toolkit + cuDNN v9.0+. On Windows, NVTX must also be installed. This adds another hour and 5+ GB of dependencies.
Not for beginners
If you're installing PyTorch for the first time, use pip or conda. Source builds are for contributors, hardware researchers, or users who need unsupported CUDA versions.

For source build instructions, refer to the official PyTorch GitHub README. The process involves cloning the repository, installing build dependencies (cmake, ninja, pybind11, etc.), setting environment variables for CUDA paths, and running the build script.

Common Installation Errors Fixed

These are the five errors that account for the majority of PyTorch installation failures. Each has a deterministic fix.

Troubleshooting Accordion
Video Resources
Install PyTorch with CUDA , Step by Step
Nicholas Renotte • YouTube
PyTorch Setup: pip, conda & virtual environments
Patrick Loeber • YouTube
PyTorch on Apple Silicon , MPS GPU Acceleration
Sentdex • YouTube
Related Reading
Breakdown
What Is PyTorch? Framework, Features & 2026 Ecosystem
Understand the architecture, compiler stack, and ecosystem before you dive into coding.
Read article →
Guide
PyTorch Tutorial for Beginners: Tensors to Neural Networks
Now that PyTorch is installed, build your first neural network from scratch with runnable examples.
Read article →
Comparison
PyTorch vs TensorFlow: Which Should You Use in 2026?
Honest trade-offs between the two leading frameworks , deployment, debugging, research adoption, and when TF still wins.
Read article →
Verified against PyTorch 2.12.0 official documentation and GitHub repository (May 2026). Installation commands checked against pytorch.org/get-started/locally selector.
PyTorch™ and the PyTorch logo are trademarks of The Linux Foundation. PyTorch is a project of the PyTorch Foundation, a directed fund of The Linux Foundation. CUDA® is a trademark of NVIDIA Corporation. Apple® and M1/M2/M3/M4 are trademarks of Apple Inc. AMD and ROCm are trademarks of Advanced Micro Devices, Inc. Tech Jacks Solutions is editorially independent and is not affiliated with the PyTorch Foundation, Meta Platforms, NVIDIA, Apple, or AMD.
Before You Use AI
Your Privacy

PyTorch is an open-source library that runs locally on your hardware. No training data is sent to any third party when you run models locally. Cloud deployments (AWS SageMaker, Azure ML, Google Cloud) and hosted inference APIs operate under each provider's own data processing agreements. Review your cloud provider's DPA before sending sensitive data to hosted endpoints.

Mental Health & AI Use

PyTorch is a technical framework for machine learning. If technical complexity or learning pressure is contributing to distress, please reach out for support. If you are experiencing a mental health crisis:

  • 988 Suicide & Crisis Lifeline: Call or text 988
  • SAMHSA Helpline: 1-800-662-4357
  • Crisis Text Line: Text HOME to 741741

AI systems, including models built with PyTorch, can produce plausible-sounding but incorrect outputs. For medical, legal, financial, or safety-critical decisions, always consult a qualified professional.

Your Rights & Our Transparency

This article was researched and written by Tech Jacks Solutions editorial staff. Factual claims are grounded in PyTorch's official documentation and GitHub repository. We have no sponsored relationship with the PyTorch Foundation or Meta Platforms. We may earn commissions from cloud provider links at no cost to you.

Under GDPR and CCPA, you have the right to access, correct, or delete personal data we hold. This content is covered by the EU AI Act's transparency obligations where applicable.