PyTorch pip code example

Example 1: get pytorch version

import torch
print(torch.__version__)

Example 2: pytorch install

pip install torch==1.8.1+cu102 torchvision==0.9.1+cu102 torchaudio===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

Example 3: torch conda

conda install pytorch torchvision cudatoolkit=10.2 -c pytorch

Example 4: pip install pytorch windows

conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch

Example 5: mac install pytorch 3.6

conda install pytorch torchvision -c pytorch

Example 6: install pytorch cuda 10

# CUDA 9.2
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=9.2 -c pytorch

# CUDA 10.0
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch

# CPU Only
conda install pytorch==1.2.0 torchvision==0.4.0 cpuonly -c pytorch