#1617·pytorch3d

在 Windows 11 和 WSL2 上安装 Pytorch3D 失败

作者: danielsjf创建于 2023年8月19日更新于 2026年3月6日

Bugs / Unexpected behaviors

I'm trying to install pytorch3D on Windows 11 + Python 3.11, within WSL2 and with CUDA 12.2. I'm using the nightly build for Pytorch 2.01 for CUDA 12.1. Pytorch installs fine. Then I tried to install pytorch3D from git as there were no wheels available:

bash
pip install 'git+https://GitHub.com/facebookresearch/pytorch3d.git@stable'

When installing, I get the following error:

In file included from /tmp/pip-req-build-nbn989gk/pytorch3d/csrc/face_areas_normals/face_areas_normals.cu:9:
      /xxx/.venv/lib/python3.11/site-packages/torch/include/ATen/ATen.h:4:2: error: #error C++17 or later compatible compiler is required to use ATen.
          4 | #error C++17 or later compatible compiler is required to use ATen.
            |  ^~~~~
      In file included from /xxx/.venv/lib/python3.11/site-packages/torch/include/c10/util/string_view.h:4,
                       from /xxx/.venv/lib/python3.11/site-packages/torch/include/c10/util/StringUtil.h:6,
                       from /xxx/.venv/lib/python3.11/site-packages/torch/include/c10/util/Exception.h:5,
                       from /xxxr/.venv/lib/python3.11/site-packages/torch/include/ATen/core/Generator.h:11,
                       from /xxx/.venv/lib/python3.11/site-packages/torch/include/ATen/CPUGeneratorImpl.h:3,
                       from /xxx/.venv/lib/python3.11/site-packages/torch/include/ATen/Context.h:3,
                       from /xxx/.venv/lib/python3.11/site-packages/torch/include/ATen/ATen.h:7,
                       from /tmp/pip-req-build-nbn989gk/pytorch3d/csrc/face_areas_normals/face_areas_normals.cu:9:
      /xxx/.venv/lib/python3.11/site-packages/torch/include/c10/util/C++17.h:27:2: error: #error You need C++17 to compile PyTorch
         27 | #error You need C++17 to compile PyTorch
            |  ^~~~~

The gcc version seems fine

$ g++ --version
g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I've already tried a few things:
* From the error I thought it was an issue with my Windows installation of Visual Studio C++ installer. I've updated everything there.
* I read that adding two environment variables pointing to g++ can help so I did that:

export CC=/path/to/gcc export CXX=/path/to/g++


There are quite a few related errors with the installation of pytorch, however, since that seems to run smooth I am reporting the issue here. Maybe there is something in the settings of pytorch3D which is configured differently.

内容来源: facebookresearch/pytorch3d