如何使用特定的GCC编译器版本安装PIP软件包?

pinkon5k  于 2024-01-08  发布在  其他
关注(0)|答案(1)|浏览(247)

我一直在尝试在Python 3.10中使用PIP在anaconda环境中安装包mmcv-full,但是我在这样做时一直得到这个错误:

Emitting ninja build file /tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/build/temp.linux-x86_64-cpython-310/build.ninja...
      Compiling objects...
      Using envvar MAX_JOBS (4) as the number of workers...
      [1/128] c++ -MMD -MF /tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/build/temp.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/active_rotated_filter.o.d -pthread -B /home/vargog/anaconda3/envs/Donkey3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/vargog/anaconda3/envs/Donkey3/include -fPIC -O2 -isystem /home/vargog/anaconda3/envs/Donkey3/include -fPIC -DMMCV_WITH_CUDA -I/tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/mmcv/ops/csrc/pytorch -I/tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/mmcv/ops/csrc/common -I/tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/mmcv/ops/csrc/common/cuda -I/home/vargog/anaconda3/envs/Donkey3/lib/python3.10/site-packages/torch/include -I/home/vargog/anaconda3/envs/Donkey3/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/home/vargog/anaconda3/envs/Donkey3/lib/python3.10/site-packages/torch/include/TH -I/home/vargog/anaconda3/envs/Donkey3/lib/python3.10/site-packages/torch/include/THC -I/usr/local/cuda/include -I/home/vargog/anaconda3/envs/Donkey3/include/python3.10 -c -c /tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/mmcv/ops/csrc/pytorch/active_rotated_filter.cpp -o /tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/build/temp.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/active_rotated_filter.o -std=c++14 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_ext -D_GLIBCXX_USE_CXX11_ABI=0
      FAILED: /tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/build/temp.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/active_rotated_filter.o
      c++ -MMD -MF /tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/build/temp.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/active_rotated_filter.o.d -pthread -B /home/vargog/anaconda3/envs/Donkey3/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/vargog/anaconda3/envs/Donkey3/include -fPIC -O2 -isystem /home/vargog/anaconda3/envs/Donkey3/include -fPIC -DMMCV_WITH_CUDA -I/tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/mmcv/ops/csrc/pytorch -I/tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/mmcv/ops/csrc/common -I/tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/mmcv/ops/csrc/common/cuda -I/home/vargog/anaconda3/envs/Donkey3/lib/python3.10/site-packages/torch/include -I/home/vargog/anaconda3/envs/Donkey3/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/home/vargog/anaconda3/envs/Donkey3/lib/python3.10/site-packages/torch/include/TH -I/home/vargog/anaconda3/envs/Donkey3/lib/python3.10/site-packages/torch/include/THC -I/usr/local/cuda/include -I/home/vargog/anaconda3/envs/Donkey3/include/python3.10 -c -c /tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/mmcv/ops/csrc/pytorch/active_rotated_filter.cpp -o /tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/build/temp.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/active_rotated_filter.o -std=c++14 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_ext -D_GLIBCXX_USE_CXX11_ABI=0
      In file included from /home/vargog/anaconda3/envs/Donkey3/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
                       from /tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/mmcv/ops/csrc/common/pytorch_cpp_helper.hpp:3,
                       from /tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/mmcv/ops/csrc/pytorch/active_rotated_filter.cpp:5:
      /home/vargog/anaconda3/envs/Donkey3/lib/python3.10/site-packages/torch/include/ATen/ATen.h:4:2: error: #error C++17 or later compatible compiler is required to use ATen.
       #error C++17 or later compatible compiler is required to use ATen.
        ^~~~~
      In file included from /home/vargog/anaconda3/envs/Donkey3/lib/python3.10/site-packages/torch/include/ATen/core/Generator.h:12,
                       from /home/vargog/anaconda3/envs/Donkey3/lib/python3.10/site-packages/torch/include/ATen/CPUGeneratorImpl.h:3,
                       from /home/vargog/anaconda3/envs/Donkey3/lib/python3.10/site-packages/torch/include/ATen/Context.h:3,
                       from /home/vargog/anaconda3/envs/Donkey3/lib/python3.10/site-packages/torch/include/ATen/ATen.h:7,
                       from /home/vargog/anaconda3/envs/Donkey3/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
                       from /tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/mmcv/ops/csrc/common/pytorch_cpp_helper.hpp:3,
                       from /tmp/pip-install-uk4j3r7w/mmcv-full_42af0b6427974452b4a43d94b764ae55/mmcv/ops/csrc/pytorch/active_rotated_filter.cpp:5:
      /home/vargog/anaconda3/envs/Donkey3/lib/python3.10/site-packages/torch/include/c10/util/C++17.h:27:2: error: #error You need C++17 to compile PyTorch
       #error You need C++17 to compile PyTorch

字符串
我运行的安装命令是pip3 install mmcv-full
有没有办法在我的C版本设置为C17而不是pip出于某种原因抓取的C++14的情况下运行这个命令?也许是某种参数。
我尝试了How to specify a gcc path in pip command?这篇文章中描述的方法,但这些方法似乎都不起作用。我还试图在pip命令std=c++17 pip3 install mmcv-full之前添加一个参数来指定编译器版本,但这也不起作用。
谢谢

cgvd09ve

cgvd09ve1#

如果你使用cuda(nvcc),你可以在运行pip install mmcv-full之前将这个环境变量设置为-std=c++17,否则你必须从source编译它。

相关问题