NVIDIA / NVIDIA/apex

g++/c++ compiler incompatibility

Open
#974 7 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
9k
Forks
1.5k
Avg merge
2d 4h
Merged PRs (30d)
3

Description

I am working with an application that uses Pytorch and Apex. The application requires that Apex be compiled with the --cpp_ext and --cuda_ext flags. I set up my environment like so.

conda create -n layoutlm
conda activate layoutlm
conda install -c creditx gcc-7
conda install pytorch cudatoolkit=10.1 -c pytorch
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./

I see the following warning when Apex compiles.

                                  !! WARNING !!

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    Your compiler (c++) is not compatible with the compiler Pytorch was
    built with for this platform, which is g++ on linux. Please
    use g++ to to compile your extension. Alternatively, you may
    compile PyTorch from source using c++, and then you can also use
    c++ to compile your extension.

    See https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md for help
    with compiling PyTorch from source.
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Looking at the build logs it does appear that sometimes g++ is being used and other times c++.

The application I'm building ultimately fails with a mysterious error, so I'm trying to see if this compiler incompatibility is the cause.

How do I "use g++ to compile [my] extension"? I don't see a Makefile in Apex, and it doesn't look like it's possible to specify a compiler using the options in setup.py.

  • Pytorch 1.6
  • Apex installed from latest source
  • CUDA 10.1
  • CentOS Linux release 7.6.1810 (Core)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Apex's setup.py, the provided pip install command, and the build logs to trace where g++ and c++ are selected during extension compilation. Reproduce the warning in the stated PyTorch 1.6, CUDA 10.1, and CentOS environment, then establish whether compiler selection explains the reported failure and document the supported result.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python, pytorch
Domain
build-system, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.