Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to parse the compilation of pytorch-gpu source code

Shulou Source: shulou.com Published: 2022-06-01 17:48:38 10月01日 Update

This article introduces how to parse pytorch-gpu source code compilation, the content is very detailed, interested friends can refer to reference, I hope to help you.

Software and hardware environment ubuntu 18.04 64bitNVidia GTX 1070Tianaconda with python 3.7CUDA 10.1cuDNN 7.6python 1.8python and GPU environment

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

anaconda basic use ubuntu installation CUDA and cuDNN compilation steps

Installation Base Dependency

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

Since you want to use GPU, you also need to install LAPACK support, and install the corresponding software package according to 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 version

Then you can start cloning 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

Once the preparations are complete, you can start compiling.

export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../ "}

python setup.py install

CMAKE_PREFIX_PATH is actually the installation directory of anaconda, such as/home/xugaoxiang/anaconda3

pytorch

It takes a long time to compile, just wait patiently.

test

Open a new terminal for testing.

(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 '? ' for help.

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]:

Pytorch has been installed in the anaconda environment, and is the gpu version, done!

The whole compilation process is still very smooth, before we compiled opencv, tensorflow, caffe, compared with them, pytorch in the dependency processing is very good, in the form of sub-projects into their own projects, the whole compilation process did not appear error, the document is also written simple and clear, no wonder its market share will be higher and higher.

About how to parse pytorch-gpu source code compilation to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

Tags: Compilation environment source code content more version process reference help test good patience next code interest foundation subitems guys buddies that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Huawei OPPO Reno Xiaomi Shulou Technology