install torch code example

Example 1: get pytorch version

import torch
print(torch.__version__)

Example 2: conda install pytorch

conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch

Example 3: pytorch anaconda install windows

conda install pytorch torchvision cudatoolkit=10.1 -c pytorch

Example 4: install torch anaconda

conda install pytorch torchvision cudatoolkit=10.0 -c pytorch

Example 5: cuda 10 install pytorch

# 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

Example 6: mac install pytorch 3.6

conda install pytorch torchvision -c pytorch