Qiskit / qiskit-aer

Aer is a high performance simulator for quantum circuits that includes noise models
https://qiskit.github.io/qiskit-aer/
Apache License 2.0
476 stars 355 forks source link

Conan error when building qiskit-aer #1789

Open ghost opened 1 year ago

ghost commented 1 year ago

Informations

What is the current behavior?

Trying to use cuQuantum from Qiskit, I came across this site.

https://github.com/Qiskit/qiskit-aer/blob/main/CONTRIBUTING.md

I found from #1609 that I need to build qiskit-aer to use cuQuantum from qiskit-aer, so I built the source and got an error when I entered the following command.

qiskit-aer$ python ./setup.py bdist_wheel -- -DAER_THRUST_BACKEND=CUDA -DCUQUANTUM_ROOT=./home/quantum_talk_ch/miniconda3/envs/test/lib/python3.11/site-packages/cuquantum -DCUTENSOR_ROOT=./miniconda3/envs/test/lib/python3.11/site-packages/cutensor -DAER_ENABLE_CUQUANTUM=true --
・・・
・・・
-- Performing Test flag_supported - Success
-- Conan: Automatic detection of conan settings from cmake
-- Conan: Settings= -s;build_type=Release;-s;compiler=gcc;-s;compiler.version=9;-s;compiler.libcxx=libstdc++11
-- Conan: checking conan executable
-- Conan: Found program /home/quantum_talk_ch/miniconda3/envs/test/bin/conan
-- Conan: Version found Conan version 2.0.4

-- Conan executing: /home/quantum_talk_ch/miniconda3/envs/test/bin/conan install . -s build_type=Release -s compiler=gcc -s compiler.version=9 -s compiler.libcxx=libstdc++11 -e=CONAN_CMAKE_PROGRAM=/usr/bin/cmake -g=cmake --build=missing
usage: conan install [-h] [-f FORMAT] [-v [V]] [--name NAME]
                     [--version VERSION] [--user USER] [--channel CHANNEL]
                     [--requires REQUIRES] [--tool-requires TOOL_REQUIRES]
                     [-b BUILD] [-r REMOTE | -nr] [-u] [-o OPTIONS_HOST]
                     [-o:b OPTIONS_BUILD] [-o:h OPTIONS_HOST]
                     [-pr PROFILE_HOST] [-pr:b PROFILE_BUILD]
                     [-pr:h PROFILE_HOST] [-s SETTINGS_HOST]
                     [-s:b SETTINGS_BUILD] [-s:h SETTINGS_HOST] [-c CONF_HOST]
                     [-c:b CONF_BUILD] [-c:h CONF_HOST] [-l LOCKFILE]
                     [--lockfile-partial] [--lockfile-out LOCKFILE_OUT]
                     [--lockfile-packages] [--lockfile-clean] [-g GENERATOR]
                     [-of OUTPUT_FOLDER] [--deploy DEPLOY] [--build-require]
                     [path]
conan install: error: unrecognized arguments: -e=CONAN_CMAKE_PROGRAM=/usr/bin/cmake
ERROR: Exiting with code: 2
CMake Error at cmake/conan.cmake:402 (message):
  Conan install failed='2'
Call Stack (most recent call first):
  cmake/conan.cmake:497 (conan_cmake_install)
  cmake/conan_utils.cmake:71 (conan_cmake_run)
  cmake/dependency_utils.cmake:20 (setup_conan)
  CMakeLists.txt:144 (setup_dependencies)

-- Configuring incomplete, errors occurred!
See also "/home/quantum_talk_ch/qiskit-aer/_skbuild/linux-x86_64-3.10/cmake-build/CMakeFiles/CMakeOutput.log".
Traceback (most recent call last):
  File "/home/quantum_talk_ch/miniconda3/lib/python3.10/site-packages/skbuild/setuptools_wrap.py", line 666, in setup
    env = cmkr.configure(
  File "/home/quantum_talk_ch/miniconda3/lib/python3.10/site-packages/skbuild/cmaker.py", line 356, in configure
    raise SKBuildError(msg)

An error occurred while configuring with CMake.
・・・
・・・

I seem to be getting some errors regarding Conan, but I don't know much about Cmake and can't solve them. What could be the cause and how can it be resolved?

Steps to reproduce the problem

On GCP VM instance.

  1. Install cuQuantum from the steps mentioned in the documentation.
  2. build qiskit-aer
$ git clone https://github.com/Qiskit/qiskit-aer

and following documentation

$ cd qiskit-aer
$ pip install -r requirements-dev.txt
$ sudo apt install build-essential
$ sudo apt install libopenblas-dev

then run setup.py.

qiskit-aer$ python ./setup.py bdist_wheel -- -DAER_THRUST_BACKEND=CUDA -DCUQUANTUM_ROOT=./home/quantum_talk_ch/miniconda3/envs/test/lib/python3.11/site-packages/cuquantum -DCUTENSOR_ROOT=./miniconda3/envs/test/lib/python3.11/site-packages/cutensor -DAER_ENABLE_CUQUANTUM=true --

What is the expected behavior?

The build of qiskit-aer is completed and cuquanutum can be used from qiskit-aer.

Now, if we flag cuStateVec_enable=True in AerSimulator() as in #1609,

$ python test.py 

Simulation failed and returned the following error message:
ERROR: Failed to load qobj: Simulation device "GPU" does not support cuStateVec on this system
Traceback (most recent call last):

and this error↑ occurs.

Suggested solutions

hhorii commented 1 year ago

Please see https://github.com/Qiskit/qiskit-aer/issues/1730. Conan 2.0 is not supported. Please use Conan 1.X.

ghost commented 1 year ago

Thank you, the conan error has been resolved but the following error regarding pybind11 has appeared.

-- PYBIND INCLUDES: /home/quantum_talk_ch/miniconda3/envs/QiskitDevEnv3/include/python3.11
-- The CUDA compiler identification is NVIDIA 11.1.74
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- /home/quantum_talk_ch/miniconda3/envs/QiskitDevEnv3/include/python3.11
-- PYTHON EXECUTABLE: /home/quantum_talk_ch/miniconda3/envs/QiskitDevEnv3/bin/python
Traceback (most recent call last):
  File "<string>", line 3, in <module>
ModuleNotFoundError: No module named 'pybind11'
CMake Warning at cmake/FindPybind11.cmake:21 (message):
  (NAIVE) CHECK COULD NOT FIND PYBIND!
Call Stack (most recent call first):
  src/open_pulse/CMakeLists.txt:1 (find_package)

-- PYBIND INCLUDES: /home/quantum_talk_ch/miniconda3/envs/QiskitDevEnv3/include/python3.11
-- Configuring done (3.6s)
-- Generating done (0.0s)
-- Build files have been written to: /home/quantum_talk_ch/qiskit-aer/_skbuild/linux-x86_64-3.11/cmake-build
[ 10%] Building CUDA object qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir/bindings.cc.o
/home/quantum_talk_ch/qiskit-aer/qiskit_aer/backends/wrappers/bindings.cc:9:10: fatal error: pybind11/pybind11.h: No such file or directory
    9 | #include <pybind11/pybind11.h>
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir/build.make:77: 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/quantum_talk_ch/miniconda3/envs/QiskitDevEnv3/lib/python3.11/site-packages/skbuild/setuptools_wrap.py", line 674, in setup
    cmkr.make(make_args, install_target=cmake_install_target, env=env)
  File "/home/quantum_talk_ch/miniconda3/envs/QiskitDevEnv3/lib/python3.11/site-packages/skbuild/cmaker.py", line 691, in make
    self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)
  File "/home/quantum_talk_ch/miniconda3/envs/QiskitDevEnv3/lib/python3.11/site-packages/skbuild/cmaker.py", line 736, in make_impl
    raise SKBuildError(msg)

An error occurred while building with CMake.

What error could this be?

hhorii commented 1 year ago

I guess that pybid11 is not installed correctly in your environment.

ghost commented 1 year ago

I tried,

pip install pybind11

However, the error is not resolved. is it possible that the missing module for pybind11 and the inability to successfully build it with cmake is because I forgot to do some command operation and the dependency was not resolved properly during the installation? I can't find any other examples of such an error. (I am concerned that I am not installing the required packages in addition to pybind11.)

hhorii commented 1 year ago

can you install pybind11 with pip install "pybind11[global]"?

hhorii commented 1 year ago

I confirmed that qiskit-aer can be compiled with cuquantum. I hope that this gist helps your trouble.

https://gist.github.com/hhorii/44f3c36722ba0c33ff900fdd1f5a118c

(in this gist, "pybind11[global]" was not necessary.)