Cannot install Lightning-GPU on Ubuntu

When building a wheel from the package sources using the direct SDK path, I meet a error on the second step:

$ cmake --build ./Build --verbose
/usr/local/bin/cmake -S/home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main -B/home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start /home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build/CMakeFiles /home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build//CMakeFiles/progress.marks
/usr/bin/make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build'
/usr/bin/make  -f _deps/kokkos-build/core/src/CMakeFiles/kokkoscore.dir/build.make _deps/kokkos-build/core/src/CMakeFiles/kokkoscore.dir/depend
make[2]: Entering directory '/home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build'
cd /home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main /home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build/_deps/kokkos-src/core/src /home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build /home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build/_deps/kokkos-build/core/src /home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build/_deps/kokkos-build/core/src/CMakeFiles/kokkoscore.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build'
/usr/bin/make  -f _deps/kokkos-build/core/src/CMakeFiles/kokkoscore.dir/build.make _deps/kokkos-build/core/src/CMakeFiles/kokkoscore.dir/build
make[2]: Entering directory '/home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build'
[  1%] Building CXX object _deps/kokkos-build/core/src/CMakeFiles/kokkoscore.dir/impl/Kokkos_CPUDiscovery.cpp.o
cd /home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build/_deps/kokkos-build/core/src && /usr/local/bin/cmake -E __run_co_compile --tidy="clang-tidy;-extra-arg=-std=c++17;--extra-arg-before=--driver-mode=g++" --source=/home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build/_deps/kokkos-src/core/src/impl/Kokkos_CPUDiscovery.cpp -- /usr/bin/c++ -DKOKKOS_DEPENDENCE -I/home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build/_deps/kokkos-build/core/src -I/home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build/_deps/kokkos-src/core/src -I/home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build/_deps/kokkos-build -O2 -g -DNDEBUG -fPIC -std=gnu++2a -MD -MT _deps/kokkos-build/core/src/CMakeFiles/kokkoscore.dir/impl/Kokkos_CPUDiscovery.cpp.o -MF CMakeFiles/kokkoscore.dir/impl/Kokkos_CPUDiscovery.cpp.o.d -o CMakeFiles/kokkoscore.dir/impl/Kokkos_CPUDiscovery.cpp.o -c /home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build/_deps/kokkos-src/core/src/impl/Kokkos_CPUDiscovery.cpp
Error running 'clang-tidy': No such file or directory
make[2]: *** [_deps/kokkos-build/core/src/CMakeFiles/kokkoscore.dir/build.make:76: _deps/kokkos-build/core/src/CMakeFiles/kokkoscore.dir/impl/Kokkos_CPUDiscovery.cpp.o] Error 1
make[2]: Leaving directory '/home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build'
make[1]: *** [CMakeFiles/Makefile2:1269: _deps/kokkos-build/core/src/CMakeFiles/kokkoscore.dir/all] Error 2
make[1]: Leaving directory '/home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/Build'
make: *** [Makefile:136: all] Error 2

My platform is:
Conda environment python3.8
cuQuantum 22.7.1
gcc version 10.3.0 (Ubuntu 10.3.0-1ubuntu1~20.04)
cmake version 3.25.0-rc2

I am wandering if there are any suggestions?

Hi @Jinkai_Tian, welcome to the forum!

Can you please post the output of qml.about()?

Also, what GPU will you be using?

I’m thinking that you may be using an old version of PennyLane and PennyLane-Lightning, or it may be an issue with the architecture you’re using.

Also, you could try updating your GCC to 11.x.
If you do this does the problem get fixed?

Hi @Jinkai_Tian
Just to jump in and have a look at your error message. We use a tool named clang-tidy to ensure any and all development adheres to a given standard when building the libraries.

On your machine this doesn’t appear to be installed. You can try apt install clang-tidy to see if this helps. Otherwise, you can explicitly disable this step using -DENABLE_CLANG_TIDY=off to see if it helps.

Though, if you are on an x86_64 machine, you can simply pip install lightning.gpu and not build it from scratch with

python3 -m venv pypenv
source ./pyenv/bin/activate
python -m pip install pennylane pennylane-lightning[gpu] cuquantum

hope this helps.

1 Like

The GPU I am using is 2080Ti.
The output of qml.about() is as follows:

Name: PennyLane
Version: 0.26.0
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: https://github.com/XanaduAI/pennylane
Author:
Author-email:
License: Apache License 2.0
Location: /home/joselyn/.conda/envs/quantum38/lib/python3.8/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, retworkx, scipy, semantic-version, toml
Required-by: PennyLane-Lightning

Platform info: Linux-5.11.0-34-generic-x86_64-with-glibc2.17
Python version: 3.8.13
Numpy version: 1.23.4
Scipy version: 1.9.3
Installed devices:

  • lightning.qubit (PennyLane-Lightning-0.26.1)
  • default.gaussian (PennyLane-0.26.0)
  • default.mixed (PennyLane-0.26.0)
  • default.qubit (PennyLane-0.26.0)
  • default.qubit.autograd (PennyLane-0.26.0)
  • default.qubit.jax (PennyLane-0.26.0)
  • default.qubit.tf (PennyLane-0.26.0)
  • default.qubit.torch (PennyLane-0.26.0)
  • default.qutrit (PennyLane-0.26.0)

And are there any dependence on CUDA version?

Successfully installed! but get errors when I testing it. Any suggestions?

$ make test-python
python3 -I -m pytest tests --tb=short
====================================== test session starts ========================================================
platform linux – Python 3.9.13, pytest-7.2.0, pluggy-1.0.0
rootdir: /home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/tests, configfile: pytest.ini
collected 645 items / 1 skipped

tests/test_adjoint_jacobian.py …EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEsss…FFFFFFFFFFFF… [ 31%]
tests/test_apply.py …EEs [ 68%]
tests/test_comparison.py …Fatal Python error: Segmentation fault

Current thread 0x00007f778e32b280 (most recent call first):
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pennylane_lightning/lightning_qubit.py”, line 200 in apply_lightning
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pennylane_lightning/lightning_qubit.py”, line 169 in apply
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pennylane/_qubit_device.py”, line 315 in execute
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pennylane/_qubit_device.py”, line 586 in batch_execute
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/contextlib.py”, line 79 in inner
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pennylane/interfaces/execution.py”, line 122 in fn
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pennylane/interfaces/execution.py”, line 197 in wrapper
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pennylane/interfaces/autograd.py”, line 110 in _execute
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/autograd/tracer.py”, line 48 in f_wrapped
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pennylane/interfaces/autograd.py”, line 66 in execute
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pennylane/interfaces/execution.py”, line 443 in execute
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pennylane/qnode.py”, line 661 in call
File “/home/joselyn/Documents/tianjk/pennylane-lightning-gpu-main/tests/test_comparison.py”, line 249 in test_n_qubit_circuit
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/_pytest/python.py”, line 195 in pytest_pyfunc_call
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pluggy/_callers.py”, line 39 in _multicall
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pluggy/_manager.py”, line 80 in _hookexec
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pluggy/_hooks.py”, line 265 in call
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/_pytest/python.py”, line 1789 in runtest
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/_pytest/runner.py”, line 167 in pytest_runtest_call
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pluggy/_callers.py”, line 39 in _multicall
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pluggy/_manager.py”, line 80 in _hookexec
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pluggy/_hooks.py”, line 265 in call
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/_pytest/runner.py”, line 260 in
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/_pytest/runner.py”, line 339 in from_call
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/_pytest/runner.py”, line 259 in call_runtest_hook
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/_pytest/runner.py”, line 220 in call_and_report
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/_pytest/runner.py”, line 131 in runtestprotocol
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/_pytest/runner.py”, line 112 in pytest_runtest_protocol
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pluggy/_callers.py”, line 39 in _multicall
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pluggy/_manager.py”, line 80 in _hookexec
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pluggy/_hooks.py”, line 265 in call
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/_pytest/main.py”, line 349 in pytest_runtestloop
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pluggy/_callers.py”, line 39 in _multicall
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pluggy/_manager.py”, line 80 in _hookexec
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pluggy/_hooks.py”, line 265 in call
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/_pytest/main.py”, line 324 in _main
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/_pytest/main.py”, line 270 in wrap_session
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/_pytest/main.py”, line 317 in pytest_cmdline_main
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pluggy/_callers.py”, line 39 in _multicall
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pluggy/_manager.py”, line 80 in _hookexec
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pluggy/_hooks.py”, line 265 in call
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/_pytest/config/init.py”, line 167 in main
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/_pytest/config/init.py”, line 190 in console_main
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/site-packages/pytest/main.py”, line 5 in
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/runpy.py”, line 87 in _run_code
File “/home/joselyn/.conda/envs/qml-gpu-39/lib/python3.9/runpy.py”, line 197 in _run_module_as_main
make: *** [Makefile:70: test-builtin] Segmentation fault (core dumped)

Hi @Jinkai_Tian,

Unfortunately segmentation faults can happen for many different reasons, and it can be hard to debug the cause.

Talking to @mlxd he suggested doing the following:

Use your system Python, rather than conda, and create a fresh environment with

python3 -m venv pypenv 
source ./pyenv/bin/activate 
python -m pip install pennylane pennylane-lightning[gpu] cuquantum

If that fails, we may need to see your LD_LIBRARY_PATH with

echo $LD_LIBRARY_PATH

as something may be causing problems there.

Please let us know if this resolves your issue!