Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to install PyTorch

📅 2020-Mar-04 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ pytorch ⬩ 📚 Archive

PyTorch can be installed in many ways. I prefer installing the Python3 version locally using pip3 and with CUDA/GPU support.

To do this:

$ sudo apt install python3-pip
$ pip3 install --user torch torchvision
$ python3
>>> import torch
>>> torch.cuda.is_available()
True
>>> torch.rand(5)
tensor([0.9035, 0.2334, 0.3102, 0.2368, 0.5607])

Tried with: PyTorch 1.4.0, Python 3.6, CUDA 10.1 and Ubuntu 18.04


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧