You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

从源码编译Qiskit Aer遇编译错误求助(含MPI与CUDA配置)

问题描述

我需要为Qiskit Aer配置MPI及GPU(GeForce GTX 1080 Ti,CUDA驱动版本11.4,运行版本10.1)支持,因此选择从源码编译。我的Python版本为3.8.16,已安装CONTRIBUTING.md中提及的所有依赖。但执行以下编译命令时:

python3 ./setup.py bdist_wheel -- -DAER_THRUST_BACKEND=CUDA -DAER_MPI=True

出现无法解决的错误,错误信息如下:

/usr/include/pybind11/pybind11.h(78): error: an rvalue reference cannot be bound to an lvalue
      detected during:
        instantiation of "pybind11::cpp_function::cpp_function(Return (Class::*)(Arg...), const Extra &...) [with Return=void, Class=AER::AerState, Arg=<const AER::reg_t &, AER::cmatrix_t &&>, Extra=<pybind11::name, pybind11::is_method, pybind11::sibling>]" 
(1112): here
        instantiation of "pybind11::class_<type_, options...> &pybind11::class_<type_, options...>::def(const char *, Func &&, const Extra &...) [with type_=AER::AerState, options=<>, Func=void (AER::AerState::*)(const AER::reg_t &, AER::cmatrix_t &&), Extra=<>" 
/home/dell/vir/qiskit-aer-main/qiskit_aer/backends/wrappers/aer_state_binding.hpp(124): here
        instantiation of "void bind_aer_state(MODULE) [with MODULE=pybind11::module]" 
/home/dell/vir/qiskit-aer-main/qiskit_aer/backends/wrappers/bindings.cc(28): here

2 errors detected in the compilation of "/tmp/tmpxft_000012da_00000000-6_bindings.cpp1.ii".
make[2]: *** [qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir/build.make:76: qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir/bindings.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:874: qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
Traceback (most recent call last):
  File "/home/dell/miniconda3/envs/QiskitDevEnv/lib/python3.8/site-packages/skbuild/setuptools_wrap.py", line 674, in setup
cmkr.make(make_args, install_target=cmake_install_target, env=env)
  File "/home/dell/miniconda3/envs/QiskitDevEnv/lib/python3.8/site-packages/skbuild/cmaker.py", line 697, in make
self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)
  File "/home/dell/miniconda3/envs/QiskitDevEnv/lib/python3.8/site-packages/skbuild/cmaker.py", line 742, in make_impl
raise SKBuildError(msg)

An error occurred while building with CMake.
Command:
/home/dell/miniconda3/envs/QiskitDevEnv/lib/python3.8/site-packages/cmake/data/bin/cmake --build . --target install --config Release --
  Install target:
  install
  Source directory:
/home/dell/vir/qiskit-aer-main
  Working directory:
/home/dell/vir/qiskit-aer-main/_skbuild/linux-x86_64-3.8/cmake-build
Please check the install target is valid and see CMake's output for more information.

解决方案

1. 修复pybind11版本兼容性

这个错误是pybind11绑定右值引用成员函数时的兼容性问题,降级到稳定版本即可:

pip install pybind11==2.6.2

2. 统一CUDA版本

CUDA驱动11.4和运行版本10.1版本差过大,建议升级CUDA运行时到11.4,和驱动版本保持一致,避免工具链冲突。

3. 切换到稳定分支

如果使用的是main分支,可能存在未修复的编译问题,切换到稳定分支后重新编译:

git checkout 0.12.0

4. 明确指定CUDA编译器路径

在编译命令中添加CUDA编译器路径,确保CMake能找到匹配版本的nvcc:

python3 ./setup.py bdist_wheel -- -DAER_THRUST_BACKEND=CUDA -DAER_MPI=True -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc

内容的提问来源于stack exchange,提问作者aneela

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 16:57:47