facebookresearch / pytorch3d

PyTorch3D is FAIR's library of reusable components for deep learning with 3D data
https://pytorch3d.org/
Other
8.7k stars 1.3k forks source link

Workaround: Building from source in Docker results in build error, requires `--std=c++17` #1649

Closed MathijsdeBoer closed 10 months ago

MathijsdeBoer commented 11 months ago

🐛 Bugs / Unexpected behaviors

Trying to setup a docker container with Pytorch3D, using Nvidia's Pytorch images, I kept running into a strange build error, which spat out an immense amount of red text. Digging through I found some references to certain features in the source code requiring the C++17 standard, which apparently had not been set.

To work around this issue I've adjusted the setup.py file on lines 52 and 77 to build with --std=c++17 instead, and builds are now successful. I haven't yet had a chance to test whether the GPU acceleration works, but at least it'll build in a consistent manner.

Instructions To Reproduce the Issue:

Please include the following (depending on what the issue is):

  1. Any changes you made (git diff) or code you wrote
    
    diff --git a/setup.py b/setup.py
    index 54e6283..a5aecf7 100755
    --- a/setup.py
    +++ b/setup.py
    @@ -49,7 +49,7 @@ def get_extensions():
     source_cuda = glob.glob(os.path.join(extensions_dir, "**", "*.cu"), recursive=True)
     extension = CppExtension

@@ -74,7 +74,7 @@ def get_extensions(): "-D__CUDA_NO_HALF2_OPERATORS__", ] if os.name != "nt":

Dockerfile:

FROM nvcr.io/nvidia/pytorch:23.09-py3

RUN apt-get update \
    && apt-get upgrade -y\
    && apt-get install -y wget \
    build-essential \
    ca-certificates \
    git \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* \
    && gcc --version

COPY ./pytorch3d /pytorch3d
RUN cd /pytorch3d \
    && pip install .
  1. The exact command(s) you ran: In order to create the following file setup:
    ./
    |- pytorch3d (cloned from git, tag v0.7.4)
    |- Dockerfile (referenced above)
    $ git clone --depth 1 --branch v0.7.4 https://github.com/facebookresearch/pytorch3d.git
    $ docker build -t pytorch3d:latest .
  2. What you observed (including the full logs):
    The full error log is way too long to include here, in fact it didn't even fit in my terminal buffer.

I am not in the loop enough to know why the setup.py calls out the c++14 standard, while the C++ code seems to require c++17 features, nor do I know if this is kept at c++14 for a particular reason. But if this is all it takes to get a successful build in a Docker image, I'll post it here too in case it ends up being useful for someone else.

bottler commented 10 months ago

setup.py is now updated to use c++17.