9951 explained code solutions for 126 technologies


python-pytorchHow can I install PyTorch using Pip on Python?


PyTorch can be installed using Pip on Python with the following steps:

  1. Install Python 3.6 or higher:
python --version

Output example

Python 3.7.3

  1. Install Pip:
python -m pip install --upgrade pip
  1. Install PyTorch:
python -m pip install torch torchvision
  1. Check whether PyTorch is installed properly:
python -c "import torch; print(torch.__version__)"

Output example

1.4.0

  1. Install a specific version of PyTorch:
python -m pip install torch==1.3.1 torchvision==0.4.2
  1. Install PyTorch with GPU support:
python -m pip install torch torchvision
  1. Install PyTorch with CUDA support:
python -m pip install torch torchvision -f https://download.pytorch.org/whl/torch_stable.html

Helpful links

Edit this code on GitHub