How to get latest PyTorch using pip, and conda?

If you are using PyTorch and want to upgrade the version to latest PyTorch follow the below commands for pip, conda, and other packages.
To get the latest version of PyTorch using pip:
pip install --upgrade torch torchvision
The best way to update PyTorch using conda:
conda update pytorch torchvision
The above two commands upgrade PyTorch and TorchVision. To upgrade PyTorch only you can remove torchvision from the commands.

If you are installing PyTorch first time, use the following commands available on PyTorch official website. Installing using these commands, you will get the latest PyTorch version.
Installing PyTorch

Installing PyTorch on Windows

Pip commands

  • For CPU only
pip3 install torch torchvision torchaudio
  • CUDA 11.7
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117
  • CUDA 11.6
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116

Conda Commands

  • for CPU only
conda install pytorch torchvision torchaudio cpuonly -c pytorch
  • CUDA 11.7
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
  • CUDA 11.6
conda install pytorch torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia

Installing PyTorch on Linux

Pip commands

  • for CPU
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
  • CUDA 11.7
pip3 install torch torchvision torchaudio
  • CUDA 11.6
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116
  • ROCm 5.2
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/rocm5.2/

Conda Commands

  • For CPU only
conda install pytorch torchvision torchaudio cpuonly -c pytorch
  • CUDA 11.7
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
  • CUDA 11.6
conda install pytorch torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia
  • ROCm 5.2
NOTE: Conda packages are not currently available for ROCm, please use pip instead

Installing PyTorch on MacOS

Pip commands

# default
pip3 install torch torchvision torchaudio

Conda Commands

# default
conda install pytorch torchvision torchaudio -c pytorch
Please visit PyTorch official website to install Pytorch for other programming languages, packages, etc.

Advertisements

Comments