9951 explained code solutions for 126 technologies


python-pytorchHow do I install PyTorch on Ubuntu using Python?


  1. Install the latest version of Python3 using sudo apt install python3
  2. Install PyTorch using pip3 install torch torchvision
  3. Verify the installation by running the following code block:
import torch
print(torch.__version__)

Output example

1.5.1

  1. Install Jupyter Notebook using pip3 install jupyter
  2. Verify the installation by running the following code block:
import jupyter
print(jupyter.__version__)

Output example

1.0.0

  1. Create a virtual environment using virtualenv -p python3 venv
  2. Activate the virtual environment using source venv/bin/activate

Helpful links

Edit this code on GitHub