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, Linux and Mac with conda.

Create new virtual environment

Create virtual environment pytorch_venv with Python (this post is written with Python 3.7), using anaconda command prompt

    
conda create --name pytorch_venv python=3.7
    
    
    

Activate virtual environment

    
conda activate pytorch_venv
    
    
PyTorch installation on Windows using conda

Install PyTorch on Windows for NON-CUDA devices(CPU)

    
conda install pytorch torchvision torchaudio cpuonly -c pytorch
    
    

Install PyTorch on Windows for CUDA 10.2 devices

    
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
    
    

Install PyTorch on Windows for CUDA 11.3 devices


conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch

PyTorch installation on Linux using conda

Install PyTorch on Linux for NON-CUDA devices(CPU)


conda install pytorch torchvision torchaudio cpuonly -c pytorch

Install PyTorch on Linux for CUDA 10.2 devices


conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch

Install PyTorch on Linux for CUDA 11.3 devices


conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch

PyTorch installation on Mac using conda

Install PyTorch on Mac for NON-CUDA devices(CPU)


conda install pytorch torchvision torchaudio -c pytorch

Verify installation

    
import torch

print(torch.__version__)  
    
    

Categories: PyTorch

Similar Articles