Search code examples
pytorchintelintel-pytorch

I am trying to install intel optimized pytorch in different ways


I am very first time using pyTorch. I am trying to install it. In how many ways I can do this? Please provide the steps for that.


Solution

  • You can install PyTorch in 3 ways.

    1. Using pip
    2. Using conda
    3. From source

    1.Intel Optimized Pytorch Installation

    Install the stable version (v 1.0) on Linux via Pip for Python 3.6.

    pip install https://download.pytorch.org/whl/cpu/torch-1.0.1.post2-cp36-cp36m-linux_x86_64.whl
    
    pip install torchvision
    

    2.Conda Pytorch Installation

    conda install pytorch-cpu torchvision-cpu -c pytorch
    

    3.PyTorch Installation from source

    Create a new environment:

    conda create -n <env_name> python=3.6
    
    export CMAKE_PREFIX_PATH=/home/user/.conda/envs/<env_name> 
    
    source activate <env_name>   
    

    Install dependencies:

    conda install numpy pyyaml mkl mkl-include setuptools cmake cffi typing
    
    conda install -c conda-forge opencv
    
    conda install Pillow
    

    Get the PyTorch source:

    git clone --recursive https://github.com/intel/pytorch
    
    cd pytorch
    
    mv caffe2/contrib/cuda-convnet2/ /tmp       
    # Fix the bug removing the old package out
    

    Install PyTorch:

    python setup.py install 2>&1 | tee build.out
    

    Hope this will help you.