Software and Hardware Environment

  • Ubuntu 18.04 64 – bit
  • NVidia GTX 1070Ti
  • Anaconda with python 3.7
  • CUDA 10.1
  • CuDNN 7.6
  • Pytorch 1.8

Python and GPU environments

This is not much to say, not installed, you can refer to the following link

  • Anaconda Basic use
  • Ubuntu installs CUDA and cuDNN

Compilation step

Installation Base Dependence

conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses
Copy the code

Because you need to use gpu, you also need to install LAPACK support. Install the corresponding software package based on CUDA version

# Add LAPACK support for the GPU if needed conda install -c pytorch magma-cuda101 # or [ magma-cuda101 | magma-cuda100 |  magma-cuda92 ] depending on your cuda versionCopy the code

Then you can start cloning your code

git clone --recursive https://github.com/pytorch/pytorch
cd pytorch
# if you are updating an existing checkout
git submodule sync
git submodule update --init --recursive
Copy the code

Once the preparation is complete, you are ready to compile

export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/.. /"} python setup.py installCopy the code

CMAKE_PREFIX_PATH anaconda is in fact the installation directory, such as I/home/here/xugaoxiang anaconda3

It takes a long time to compile, so wait patiently

test

Open a new terminal to test

(base) xugaoxiang@1070Ti:~$ipython Python 3.7.6 (default, Jan 8 2020, 19:59:22) Type 'copyright', 'Credits' or 'license' for more information IPython 7.19.0 -- An enhanced Interactive Python. Type '? In [1]: import torch In [2]: torch.__version__ Out[2]: '1.8.0a0+46d846f' In [3]: torch.cuda.is_available() Out[3]: True In [4]:Copy the code

Pytorch has been installed in anaconda and is a GPU version.

summary

The whole compilation process was very smooth. Compared with opencV, TensorFlow and Caffe, PyTorch did a very good job in handling the dependencies. It was incorporated into our own project as a subproject, and no errors were reported during the compilation process. No wonder its market share is getting bigger and bigger.

The resources

  • Github.com/pytorch/pyt…
  • Xugaoxiang.com/2019/12/08/…
  • Xugaoxiang.com/2019/12/13/…