Open derwind opened 1 year ago
Now Aer uses cuquantum PiPy package and I'm wondering that this is an issue to use the package.
https://github.com/Qiskit/qiskit-aer/blob/b4e393c57a946a5f003f9065c7887d1c4ff6f2dd/setup.py#L59
Should the #1877 have fixed this one? Still facing the same issue when trying to use the qiskit-aer-gpu python package
The problem is fixed and merged but qiskit-aer-gpu is not released on PyPI. Please refer to #1882 and build from source until new qiskit-aer-gpu will be released.
The problem is fixed and merged but qiskit-aer-gpu is not released on PyPI. Please refer to #1882 and build from source until new qiskit-aer-gpu will be released.
Hi @doichanj , I have been able to build from source for the qiskit-aer-gpu as you mentioned in #1882 , and until the end of that notebook everything ran fine and I saw no problems. However, when I try to import AerSimulator to see if I can access the 'tensor_network' methods, I could not do so. I'll be grateful if you could help me with this.
I added test script to run with tensor_network
method
https://colab.research.google.com/drive/1mLEYEPzBJTJmCDRjFJ9tHuacYu15c0hY?usp=sharing
Thanks a lot for your help! It does work for me!
Hi @doichanj ! I am also having a similar trouble building the Qiskit-Aer from source. I tried to follow the steps as were provided in the google collab link.
I am using Cuda toolkit version 12.2, Python version 3.11 and Operating system Ubuntu 22.04
When I run the command
python3 ./setup.py bdist_wheel -- -DAER_THRUST_BACKEND=CUDA -DCMAKE_VERBOSE_MAKEFILE=true -DAER_DEBUG=false -DAER_MPI=false -DCMAKE_CUDA_FLAGS=-std=c++14 -DAER_PYTHON_CUDA_ROOT=/usr/local --
I reach to this point
[ 33%] Building CUDA object qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir/bindings.cc.o cd {long path...}
Before getting the following errors
In file included from /home/lghafourpour/thesis_code/qiskit-aer/src/simulators/statevector/chunk/chunk.hpp:22, from /home/lghafourpour/thesis_code/qiskit-aer/src/simulators/statevector/chunk/chunk_manager.hpp:18, from /home/lghafourpour/thesis_code/qiskit-aer/src/simulators/statevector/qubitvector_thrust.hpp:34, from /home/lghafourpour/thesis_code/qiskit-aer/src/simulators/unitary/unitarymatrix_thrust.hpp:19, from /home/lghafourpour/thesis_code/qiskit-aer/src/simulators/density_matrix/densitymatrix_thrust.hpp:19, from /home/lghafourpour/thesis_code/qiskit-aer/src/simulators/superoperator/superoperator_thrust.hpp:19, from /home/lghafourpour/thesis_code/qiskit-aer/src/simulators/superoperator/superoperator_state.hpp:28, from /home/lghafourpour/thesis_code/qiskit-aer/src/noise/quantum_error.hpp:20, from /home/lghafourpour/thesis_code/qiskit-aer/src/noise/noise_model.hpp:34, from /home/lghafourpour/thesis_code/qiskit-aer/src/framework/qobj.hpp:24, from /home/lghafourpour/thesis_code/qiskit-aer/src/controllers/aer_controller.hpp:46, from /home/lghafourpour/thesis_code/qiskit-aer/qiskit_aer/backends/wrappers/aer_controller_binding.hpp:34, from /home/lghafourpour/thesis_code/qiskit-aer/qiskit_aer/backends/wrappers/bindings.cc:15: /home/lghafourpour/thesis_code/qiskit-aer/src/simulators/statevector/chunk/cuStateVec_chunk_container.hpp:20:10: fatal error: custatevec.h: No such file or directory 20 | #include "custatevec.h" | ^
~~~~~ compilation terminated. gmake[2]: [qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir/build.make:80: qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir/bindings.cc.o] Error 1 gmake[2]: Leaving directory '/home/lghafourpour/thesis_code/qiskit-aer/_skbuild/linux-x86_64-3.11/cmake-build' gmake[1]: [CMakeFiles/Makefile2:857: qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir/all] Error 2 gmake[1]: Leaving directory '/home/lghafourpour/thesis_code/qiskit-aer/_skbuild/linux-x86_64-3.11/cmake-build' gmake: *** [Makefile:149: all] Error 2Traceback (most recent call last): File "/home/lghafourpour/.local/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/lghafourpour/.local/lib/python3.11/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/lghafourpour/.local/lib/python3.11/site-packages/skbuild/cmaker.py", line 742, in make_impl raise SKBuildError(msg)
An error occurred while building with CMake. Command: /home/lghafourpour/.local/lib/python3.11/site-packages/cmake/data/bin/cmake --build . --target install --config Release -- Install target: install Source directory: /home/lghafourpour/thesis_code/qiskit-aer Working directory: /home/lghafourpour/thesis_code/qiskit-aer/_skbuild/linux-x86_64-3.11/cmake-build
I would be very grateful for any guidance you can shed on this!
Please try building with option -DAER_PYTHON_CUDA_ROOT=/home/lghafourpour/.local
This option sets the path to the local Python environments.
Thanks @doichanj for the tip! The building now reached 66% before stopping due to another issue which I've detailed here.
I decided to remove and reinstall Ubuntu 22.04 to start from scratch. I've configured my Ubuntu in such a way to match what I saw on the Google collab:
I've followed the steps from the google collab, pip installing the cu11 versions of the Nvidia libraries since my Cuda version is 11.8.
When it comes to building, I run with the added Python Cuda Root option as you suggested:
python3 ./setup.py bdist_wheel -- -DAER_THRUST_BACKEND=CUDA -DCMAKE_VERBOSE_MAKEFILE=true -DAER_DEBUG=false -DAER_MPI=false -DCMAKE_CUDA_FLAGS=-std=c++14 -DAER_PYTHON_CUDA_ROOT=/home/lghafourpour/.local --
The build manages to reach :
[ 66%] Building CUDA object qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir/__/__/__/src/simulators/statevector/qv_avx2.cpp.o
before it gives the following error and stops the build process
cd /home/lghafourpour/thesis_code/qiskit-aer/_skbuild/linux-x86_64-3.10/cmake-build/qiskit_aer/backends/wrappers && /usr/bin/nvcc -forward-unknown-to-host-compiler -DAER_CUSTATEVEC -DAER_CUTENSORNET -DAER_THRUST_SUPPORTED=TRUE -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA -Dcontroller_wrappers_EXPORTS --options-file CMakeFiles/controller_wrappers.dir/includes_CUDA.rsp -std=c++14 -O3 -DNDEBUG -std=c++14 "--generate-code=arch=compute_61,code=[compute_61,sm_61]" -Xcompiler=-fPIC -Xcompiler=-fvisibility=hidden --compiler-options -fopenmp -gencode arch=compute_61,code=sm_61 -DAER_THRUST_CUDA -I/home/lghafourpour/thesis_code/qiskit-aer/src -isystem /home/lghafourpour/thesis_code/qiskit-aer/src/third-party/headers -use_fast_math --expt-extended-lambda -I/home/lghafourpour/.local/lib/python3.10/site-packages/cuquantum/include -I/home/lghafourpour/.local/lib/python3.10/site-packages/cutensor/include --compiler-options -mfma --compiler-options -mavx2 -MD -MT qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir////src/simulators/statevector/qv_avx2.cpp.o -MF CMakeFiles/controller_wrappers.dir////src/simulators/statevector/qv_avx2.cpp.o.d -x cu -c /home/lghafourpour/thesis_code/qiskit-aer/src/simulators/statevector/qv_avx2.cpp -o CMakeFiles/controller_wrappers.dir///__/src/simulators/statevector/qv_avx2.cpp.o
/usr/lib/gcc/x86_64-linux-gnu/11/include/serializeintrin.h(41): error: identifier "__builtin_ia32_serialize" is undefined
/home/lghafourpour/thesis_code/qiskit-aer/src/simulators/statevector/qv_avx2.cpp(272): warning #177-D: parameter "dummy" was declared but never referenced
/home/lghafourpour/thesis_code/qiskit-aer/src/simulators/statevector/qv_avx2.cpp(276): warning #177-D: parameter "dummy" was declared but never referenced
/home/lghafourpour/thesis_code/qiskit-aer/src/simulators/statevector/qv_avx2.cpp(1127): warning #1650-D: result of call is not used
/home/lghafourpour/thesis_code/qiskit-aer/src/simulators/statevector/qv_avx2.cpp(1184): warning #1650-D: result of call is not used
/home/lghafourpour/thesis_code/qiskit-aer/src/simulators/statevector/qv_avx2.cpp(142): warning #177-D: parameter "omp_threads" was declared but never referenced detected during: instantiation of "AER::QV::Avx AER::QV::_apply_avx_kernel
(const uint64_t , double , size_t, const double , size_t) [with num_qubits=1UL]" (1031): here instantiation of "AER::QV::Avx AER::QV::apply_matrix_avx<FloatType,num_qubits>(FloatType , uint64_t, const uint64_t , const FloatType , size_t) [with FloatType=double, num_qubits=1UL]" (1041): here instantiation of "AER::QV::Avx AER::QV::apply_matrix_avx(FloatType , uint64_t, const uint64_t , size_t, const FloatType *, size_t) [with FloatType=double]" (1062): here 1 error detected in the compilation of "/home/lghafourpour/thesis_code/qiskit-aer/src/simulators/statevector/qv_avx2.cpp". gmake[2]: [qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir/build.make:95: qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir///__/src/simulators/statevector/qv_avx2.cpp.o] Error 1 gmake[2]: Leaving directory '/home/lghafourpour/thesis_code/qiskit-aer/_skbuild/linux-x86_64-3.10/cmake-build' gmake[1]: [CMakeFiles/Makefile2:857: qiskit_aer/backends/wrappers/CMakeFiles/controller_wrappers.dir/all] Error 2 gmake[1]: Leaving directory '/home/lghafourpour/thesis_code/qiskit-aer/_skbuild/linux-x86_64-3.10/cmake-build' gmake: *** [Makefile:149: all] Error 2
Traceback (most recent call last): File "/home/lghafourpour/.local/lib/python3.10/site-packages/skbuild/setuptools_wrap.py", line 674, in setup cmkr.make(make_args, install_target=cmake_install_target, env=env) File "/home/lghafourpour/.local/lib/python3.10/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/lghafourpour/.local/lib/python3.10/site-packages/skbuild/cmaker.py", line 742, in make_impl raise SKBuildError(msg)
I tried to search online for fixes for the identifier "__builtin_ia32_serialize"
error message but wasn't able to find anything. Would be very grateful if you could help me in fixing this error message.
I think this is a bug in GCC 11 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100438 Please try using other version of compiler
@doichanj Thank you for all the help. Unfortunately, I was still unable to make the relevant fix. However, since my deadline for this project is due next Friday, I've been able to find ways around needing the GPU version. Out of curiosity, when is the fixed version of the library going to be released on PyPi?
We are planning to include this fix in 0.13.0 release. I created binary distribution of the latest codes and put on TestPyPI temporary. https://test.pypi.org/project/qiskit-aer-gpu/0.13.0/
Before installing by pip, other required packages should be installed manually, as following
pip install nvidia-cuda-runtime-cu12 nvidia-cublas-cu12 nvidia-cusolver-cu12 nvidia-cusparse-cu12 cuquantum-cu12
The example is here : https://colab.research.google.com/drive/1bXwlFyfoJmAw2nrMZDN8oYe8PAgqV8Co?usp=sharing
This is a validation report.
I tried to build qiskit-aer
according to @doichanj 's https://colab.research.google.com/drive/1mLEYEPzBJTJmCDRjFJ9tHuacYu15c0hY?usp=sharing on my devenv in my GCP Compute Engine VM using a CUDA 12-based docker image (included in my issue report).
In short, build process essentially successes except a small problem (will be referred later). Of course we no longer need to set additional paths to LD_LIBRARY_PATH
.
$ docker run -it --rm --gpus all python311:ubuntu22-cuda121
# pip install qiskit-aer
# pip uninstall -y qiskit-aer
# git clone https://github.com/Qiskit/qiskit-aer
# pip install nvidia-cuda-runtime-cu12 nvidia-cublas-cu12 nvidia-cusolver-cu12 nvidia-cusparse-cu12 cuquantum-cu12
# pip install -r qiskit-aer/requirements-dev.txt
# pip install pybind11
and then
# cd qiskit-aer
# python ./setup.py bdist_wheel -- -DAER_THRUST_BACKEND=CUDA -DCMAKE_VERBOSE_MAKEFILE=true -DAER_DEBUG=false -DAER_MPI=false -DCMAKE_CUDA_FLAGS=-std=c++14 -DAER_PYTHON_CUDA_ROOT=/usr/local --
which will fail due to:
---
CMake Error at /usr/local/lib/python3.11/site-packages/cmake/data/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find BLAS (missing: BLAS_LIBRARIES)
---
so we may need to do the following procedure in addition (if needed):
# apt update && apt install -y libopenblas-dev
I retried:
# cd qiskit-aer
# python ./setup.py bdist_wheel -- -DAER_THRUST_BACKEND=CUDA -DCMAKE_VERBOSE_MAKEFILE=true -DAER_DEBUG=false -DAER_MPI=false -DCMAKE_CUDA_FLAGS=-std=c++14 -DAER_PYTHON_CUDA_ROOT=/usr/local --
which successfully finished after several (about 5~10) minutes. So I installed qiskit-aer
by
# pip install -U dist/*
Finally I tested with two (CPU and cuTensorNet) simulators of
sim = AerSimulator(method='statevector')
and
sim_gpu = AerSimulator(method='tensor_network', device='GPU')
and both are OK. I also tested with:
sim_gpu_cusv = AerSimulator(method='statevector', device='GPU', cuStateVec_enable=True)
and this is also OK.
>>> print(result_gpu_cusv.to_dict()['results'][0]['metadata']['cuStateVec_enable'])
True
@doichanj and @gluca99 I have found that the installation problem to do with "custatevec.h" is due to the missing cuQuantum and cuTensor. Once these two NVIDIA products are installed then all of the required components and headers can be found, and the qiskit-aer-gpu compiles fine (well, with lots and lots warnings). Perhaps, this needs to be added to qiskit-aer-gpu documentation as a requirement (it may be obvious for some but not for others).
I am as well still encountering this issue. I recreated a conda environment and specifically pip installed the qiskit-aer-gpu-cu11 package, but the custatevec.h file is still missing. Has there been any update?
Now the latest version of Aer is 0.13.1 but the latest GPU distribution is not published yet because of PyPI's new authorization. This problem should be fixed on the latest Aer
Do you have any other advice as to how to fix the file missing error? I pip installed the qiskit-aer-gpu and installed the cuQuantum and cuTensor as the previous response said. However, I am still encountering this error. Could it perhaps be due to the cuda environment or something similar?
I put GPU distributions of Aer 0.13.1 on release page, https://github.com/Qiskit/qiskit-aer/releases
Please download one for your environment instead of pip install qiskit-aer-gpu
I put GPU distributions of Aer 0.13.1 on release page, https://github.com/Qiskit/qiskit-aer/releases Please download one for your environment instead of
pip install qiskit-aer-gpu
Thanks for the reply. I am locally installing it to the computer, and then doing pip install "filename.whl", but I believe the python versions might be incompatible as I am getting the "'filename.whl' is not a supported wheel on this platform". I am currently running python 3.12 and the latest version of the .whl file I see is 3.10. Does this mean that I have to change my python version, or is there a 3.12 version?
Now the latest version of Aer is 0.13.1 but the latest GPU distribution is not published yet because of PyPI's new authorization. This problem should be fixed on the latest Aer
i'm waiting for this solution.
Informations
- Qiskit Aer version: qiskit-aer-gpu 0.12.2
- Python version: 3.11
- Operating system: Ubuntu 22.04
- CUDA version: 12.1.1 / 11.8.0
What is the current behavior?
If I run the following procedure in a very clean environment, I will get a library load error and not be able to use qiskit_aer.
>>> import qiskit_aer
Traceback (most recent call last): File "", line 1, in ... ImportError: libcustatevec.so.1: cannot open shared object file: No such file or directory
Steps to reproduce the problem
- Create a clean environment. For example, use the following docker images:
- Enter a clean environment. e.g.,
docker run -it --rm --gpus all python311:ubuntu22-cuda121
if you will use docker images above.- Set up
qiskit-aer-gpu
with the following stepspip install qiskit pip uninstall -y qiskit-aer pip install "qiskit-aer-gpu==0.12.2"
(For CUDA 11.8 the last line would be
pip install "qiskit-aer-gpu-cu11==0.12.2"
.)
- Run
python -c "import qiskit_aer"
What is the expected behavior?
Importing
qiskit_aer
will successfully finish.Suggested solutions
It would be nice if the library paths (
LD_LIBRARY_PATH
) could be properly set. One work around would be:mkdir -p /usr/local/nvidia/lib64 ln -s /usr/local/lib/python3.11/site-packages/cuquantum/lib/libcustatevec.so.1 /usr/local/nvidia/lib64/libcustatevec.so.1 ln -s /usr/local/lib/python3.11/site-packages/cuquantum/lib/libcutensornet.so.2 /usr/local/nvidia/lib64/libcutensornet.so.2 ln -s /usr/local/lib/python3.11/site-packages/cutensor/lib/libcutensor.so.1 /usr/local/nvidia/lib64/libcutensor.so.1
in my case, the library is in here:
(quantum) edmondium@LAPTOP-1Q9H40K6:~$ ls /home/edmondium/quantum/lib/python3.11/site-packages/cuquantum/lib/
libcustatevec.so.1* libcutensornet.so.2*
In case anyone is looking for a potential solution I have one. Running on Rocky Linux 8.8 with Cuda 12.2
This works
pip install cuquantum-python
pip install nvidia-cusparse-cu12 nvidia-cublas-cu12 nvidia-cuda-runtime-cu12 custatevec_cu12
pip install qiskit-aer-gpu==0.14.0.1
ln -s /usr/local/lib/python3.9/site-packages/cuquantum/lib/libcustatevec.so.1 /usr/local/cuda/lib64/libcustatevec.so.1
ln -s /usr/local/lib/python3.9/site-packages/cuquantum/lib/libcutensornet.so.2 /usr/local/cuda/lib64/libcutensornet.so.2
ln -s /usr/local/lib/python3.9/site-packages/cutensor/lib/libcutensor.so.2 /usr/local/cuda/lib64/libcutensor.so.2
Additionally, some problems with symengine for example:
File "/usr/local/lib/python3.9/site-packages/symengine/__init__.py", line 12, in <module> import symengine.lib.symengine_wrapper as wrapper ModuleNotFoundError: No module named 'symengine.lib.symengine_wrapper'
See https://github.com/symengine/symengine.py/issues/474 Can be resolved by building it yourself
dnf install -y cmake gmp-devel
git clone https://github.com/symengine/symengine.git
cd symengine
mkdir build && cd build
cmake ..
make
make install
cd /opt/
git clone https://github.com/symengine/symengine.py.git
cd symengine.py
git checkout v0.11.0
sed -i 's/-DSYMENGINE_INSTALL_PY_FILES=OFF/-DSYMENGINE_INSTALL_PY_FILES=ON/' setup.py
python setup.py install
cd /opt/
Informations
What is the current behavior?
If I run the following procedure in a very clean environment, I will get a library load error and not be able to use qiskit_aer.
Traceback (most recent call last): File "", line 1, in
...
ImportError: libcustatevec.so.1: cannot open shared object file: No such file or directory
Steps to reproduce the problem
Enter a clean environment. e.g.,
docker run -it --rm --gpus all python311:ubuntu22-cuda121
if you will use docker images above.Set up
qiskit-aer-gpu
with the following steps(For CUDA 11.8 the last line would be
pip install "qiskit-aer-gpu-cu11==0.12.2"
.)python -c "import qiskit_aer"
What is the expected behavior?
Importing
qiskit_aer
will successfully finish.Suggested solutions
It would be nice if the library paths (
LD_LIBRARY_PATH
) could be properly set. One work around would be: