I am trying to install intel optimized pytorch in different ways - pytorch

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.

You can install PyTorch in 3 ways.
Using pip
Using conda
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.

Related

Failed to install PyTorch

I tried my best to install Pytorch but each and every time I failed to install it.
Conda version: 4.6.14
I have used Preview(Nightly) and LTS versions to install but for both of times I have faced the same error like Solving environment: | Killed .
Preview(Nightly) command: conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch-nightly
LTS command: conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch-lts
Faced error is given in the attached file, please check it.
have you tried installing pytorch into a new environment? problems usually arise when you try to install it into your base environment.
conda create -n (NameOfEnviroment) -c pytorch pytorch torchvision
conda update --all

how to solve the pytorch_geometric install error. Undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSs #999

how to solve the pytorch_geometric install error. Undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKSs #999
solution:
conda install pytorch pyg -c pytorch -c pyg -c conda-forge
conda create -n py38 pip
conda install pytorch pyg -c pytorch -c pyg -c conda-forge
conda install pyg -c pyg -c conda-forge
sudo apt-get install libfreetype6-dev
pip install -r requirements.txt
Maybe check here:
https://github.com/pyg-team/pytorch_geometric/issues/999
Most people say it is due to how you installed pytorch and two versions (the cpu and gpu versions are both installed)
I had a similar issue. As mentioned in this GitHub comment, this issue occurs when we have different torch versions installed in our system. This problem occurred in my anaconda virtual environment, which I installed in the following path.
/home/anaconda3/envs/python-3.9
I followed the following steps to solve this issue.
Step 01: First remove all the existing torch installations and their dependencies.
$ cd /home/anaconda3/envs/python-3.9/lib/python3.9/site-packages
$ rm -rf torch*
Step 02: Reinstall a specific PyTorch version and relevant dependencies as follows.
$ pip install torch -f https://data.pyg.org/whl/torch-<PYTORCH-VERSION>+<CPU|GPU>.html
$ pip install torch-geometric -f https://data.pyg.org/whl/torch-<PYTORCH-VERSION>+<CPU|GPU>.html
$ pip install torch-sparse -f https://data.pyg.org/whl/torch-<<PYTORCH-VERSION>+<CPU|GPU>.html
$ pip install torch-scatter -f https://data.pyg.org/whl/torch-<PYTORCH-VERSION>+<CPU|GPU>.html
Make sure you install a PyTorch version according to your requirements and your system (CPU or GPU). For example, I installed the following version.
$ pip install torch -f https://data.pyg.org/whl/torch-1.12.1+cpu.html
$ pip install torch-geometric -f https://data.pyg.org/whl/torch-1.12.1+cpu.html
$ pip install torch-sparse -f https://data.pyg.org/whl/torch-1.12.1+cpu.html
$ pip install torch-scatter -f https://data.pyg.org/whl/torch-1.12.1+cpu.html
You can find all the stable PyTorch versions here. In addition, now you will be able to see the installed packages inside your anaconda installation path /home/anaconda3/envs/python-3.9/lib/python3.9/site-packages.

Pytorch Import Error: <pathname>: object file has no loadable segments

I've been trying to install the Pytorch module for my Ubuntu 16.04 LTS through conda. I used conda install pytorch torchvision cpuonly -c pytorch to install it (non CUDA version). However when I type import torch on the Python shell, this is what I see -
ImportError: /home/student/anaconda2/lib/python2.7/site-packages/torch/_C.so: object file has no loadable segments
I have verified that Pytorch was installed using conda list
I had the same issue on Ubuntu 18.04 for conda env with python 3.8. The problem I think is for the incomplete torch installation. So I did pip install from wheel instead of conda install. You may follow as below (assuming you have cuda11 installed):
create conda env
conda create --name=myenv python=3.8
conda activate myenv
Install torch from wheel
pip install torch==1.7.0+cu110 torchvision==0.8.1+cu110 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
Please note I had to install torchvision==0.8.1+cu110 as reported here

i tried installing tensorflow using 'pip install tensorflow ' in anaconda prompt and command prompt. its showing following output

Found existing installation: wrapt 1.10.11
Cannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
Try the below commands mentioned, it worked for me
conda update wrapt
pip install tensorflow
(1) First try to install wrapt manually using following command
pip install wrapt --upgrade --ignore-installed
make sure that you use "--ignore-installed" flag when install 'wrapt' as above mentioned command
(2) Then install tensorflow with pip
eg:
pip install tensorflow==1.14
this should work
You might want to upgrade numpy with following incase its not compatible otherwise it will throw errors.
pip install numpy --upgrade
I was getting this error while installing from conda environment. Always upgrade conda or pip before a new installation.
Following worked for me:
[Optional] If installing in conda environment, then temporarily remove the conda env:
conda remove --name myenv --all
Update all conda packages:
conda update --all
Create conda env again:
conda create -n myenv
Activate conda env:
conda activate
Install tensorflow:
pip install tensorflow

Pytorch installation problems with Anaconda

After having upgraded my environment's python to Python 3.61, I attempted to install pytorch using this command:
conda install -c peterjc123 pytorch
However I got this error:
Fetching package metadata .............
Solving package specifications: .
UnsatisfiableError: The following specifications were found to be in conflict:
-pytorch
-pyqt
I also used the commands
conda install -c peterjc123 pytorch cuda90
conda install -c peterjc123 pytorch cuda80
But the result is still the same. Anyone got a clue how to solve this?
The problem was solved after downgrading from Python 3.6.2 to Python 3.5.1 after running:
conda install -c anaconda python=3.5.1
After running this command, run:
conda install -c peterjc123 pytorch
Pytorch should install as per normal. A similar issue occurs for openCV as well
An alternative way to install pytorch using anaconda is
conda create -n py_env python=3.5
source activate py_env
conda install pytorch-cpu torchvision -c pytorch
Go to python shell and import using the command
import torch
Hope this helps.

Resources