How to install PyTorch with conda

PyTorch is an open source machine learning framework,it is an optimized tensor library for deep learning using GPUs and CPUs. This tutorials covers steps required to install PyTorch on windows with conda.

Create new virtual environment

Create virtual environment pytorch_venv with Python 3.7, using anaconda command prompt


conda create --name pytorch_venv python=3.7


Activate virtual environment


conda activate pytorch_venv

Install PyTorch for NON-CUDA devices


conda install pytorch torchvision cpuonly -c pytorch

Install PyTorch for CUDA-Capable devices

Change cudatoolkit version accordingly


conda install pytorch torchvision cudatoolkit=10.1 -c pytorch

Verify installation


import torch

print(torch.__version__)



Example Output:


1.5.0

Categories: PyTorch