PennyLaneAI / pennylane-qulacs

The PennyLane-Qulacs plugin integrates the Qulacs quantum computing framework with PennyLane's quantum machine learning capabilities.
https://docs.pennylane.ai/projects/qulacs
Apache License 2.0
27 stars 17 forks source link

Unable to install GPU version of Pennylane-Qulacs #62

Closed JustinS6626 closed 7 months ago

JustinS6626 commented 7 months ago

Hi, I am trying to install Pennylane-Qulacs GPU with python3.11 and Pennylane.

My Pennylane info is as follows:

Name: PennyLane
Version: 0.35.0
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page: https://github.com/PennyLaneAI/pennylane
Author: 
Author-email: 
License: Apache License 2.0
Location: /usr/local/lib/python3.11/dist-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml, typing-extensions
Required-by: pennylane-qulacs, PennyLane_Lightning, PennyLane_Lightning_GPU

Platform info:           Linux-6.5.0-25-generic-x86_64-with-glibc2.35
Python version:          3.11.0
Numpy version:           1.26.3
Scipy version:           1.12.0
Installed devices:
- lightning.qubit (PennyLane_Lightning-0.35.1)
- qulacs.simulator (pennylane-qulacs-0.32.0)
- default.clifford (PennyLane-0.35.0)
- default.gaussian (PennyLane-0.35.0)
- default.mixed (PennyLane-0.35.0)
- default.qubit (PennyLane-0.35.0)
- default.qubit.autograd (PennyLane-0.35.0)
- default.qubit.jax (PennyLane-0.35.0)
- default.qubit.legacy (PennyLane-0.35.0)
- default.qubit.tf (PennyLane-0.35.0)
- default.qubit.torch (PennyLane-0.35.0)
- default.qutrit (PennyLane-0.35.0)
- null.qubit (PennyLane-0.35.0)
- lightning.gpu (PennyLane_Lightning_GPU-0.35.1)

When I enter

sudo pip3.11 install --upgrade qulacs-gpu

I get the following error:

Collecting qulacs-gpu
  Using cached Qulacs-GPU-0.3.1.tar.gz (209 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: qulacs-gpu
  Building wheel for qulacs-gpu (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [173 lines of output]
      running bdist_wheel
      running build
      running build_ext
      /tmp/pip-install-8o8kjk9r/qulacs-gpu_dc39012c072548388f98f5526c10dac2/setup.py:48: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        cmake_version = LooseVersion(re.search(r'version\s*([\d.]+)', out.decode()).group(1))
      /tmp/pip-install-8o8kjk9r/qulacs-gpu_dc39012c072548388f98f5526c10dac2/setup.py:18: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        version = LooseVersion(out)
      /tmp/pip-install-8o8kjk9r/qulacs-gpu_dc39012c072548388f98f5526c10dac2/setup.py:19: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        return version >= LooseVersion('7.0.0')
      /tmp/pip-install-8o8kjk9r/qulacs-gpu_dc39012c072548388f98f5526c10dac2/setup.py:18: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        version = LooseVersion(out)
      /tmp/pip-install-8o8kjk9r/qulacs-gpu_dc39012c072548388f98f5526c10dac2/setup.py:19: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        return version >= LooseVersion('7.0.0')
      CMake Warning (dev) in CMakeLists.txt:
        No project() command is present.  The top-level CMakeLists.txt file must
        contain a literal, direct call to the project() command.  Add a line of
        code such as

          project(ProjectName)

        near the top of the file, but after cmake_minimum_required().

        CMake is pretending there is a "project(Project)" command on the first
        line.
      This warning is for project developers.  Use -Wno-dev to suppress it.

      -- The C compiler identification is GNU 11.4.0
      -- The CXX compiler identification is GNU 11.4.0
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: /usr/bin/gcc - skipped
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Check for working CXX compiler: /usr/bin/g++ - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      CMake Deprecation Warning at CMakeLists.txt:2 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.

        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.

      -- SIMD SUPPORT: Yes
      -- CMAKE_HOST_SYSTEM_PROCESSOR = x86_64
      -- USE_SIMD = Yes
      -- USE_OMP = Yes
      -- USE_GPU = Yes
      -- USE_TEST = Yes
      -- USE_PYTHON = Yes
      -- OPT_FLAGS = -mtune=native -march=native -mfpmath=both
      -- Fetch googletest for C++ testing
      CMake Deprecation Warning at build/temp.linux-x86_64-cpython-311/_deps/googletest_fetch-src/CMakeLists.txt:1 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.

        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.

      CMake Deprecation Warning at build/temp.linux-x86_64-cpython-311/_deps/googletest_fetch-src/googlemock/CMakeLists.txt:42 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.

        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.

      CMake Deprecation Warning at build/temp.linux-x86_64-cpython-311/_deps/googletest_fetch-src/googletest/CMakeLists.txt:49 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.

        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.

      -- Found PythonInterp: /usr/bin/python3.11 (found version "3.11")
      -- Looking for pthread.h
      -- Looking for pthread.h - found
      -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
      -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
      -- Found Threads: TRUE
      -- Fetch pybind11 for python-binding
      -- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.11.so
      -- Performing Test HAS_CPP14_FLAG
      -- Performing Test HAS_CPP14_FLAG - Success
      -- pybind11 v2.5.0
      -- Install from pip
      -- OUTDIR = /tmp/pip-install-8o8kjk9r/qulacs-gpu_dc39012c072548388f98f5526c10dac2/build/lib.linux-x86_64-cpython-311
      -- CMAKE_SYSTEM_NAME = Linux
      -- CMAKE_C_COMPILER = /usr/bin/gcc
      -- CMAKE_CXX_COMPILER = /usr/bin/g++
      -- CMAKE_BUILD_TYPE = Release
      -- CMAKE_CXX_FLAGS = -DVERSION_INFO=\"0.3.1\" -std=gnu++14 -pthread -fext-numeric-literals -fopenmp -fPIC
      -- CMAKE_CXX_FLAGS_DEBUG = -g
      -- CMAKE_CXX_FLAGS_RELEASE = -O3 -DNDEBUG -mtune=native -march=native -mfpmath=both
      CMake Deprecation Warning at src/CMakeLists.txt:1 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.

        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.

      CMake Deprecation Warning at src/csim/CMakeLists.txt:1 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.

        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.

      CMake Deprecation Warning at src/gpusim/CMakeLists.txt:1 (cmake_minimum_required):
        Compatibility with CMake < 2.8.12 will be removed from a future version of
        CMake.

        Update the VERSION argument <min> value or use a ...<max> suffix to tell
        CMake that the project does not need compatibility with older versions.

      CMake Error at /usr/share/cmake-3.22/Modules/FindCUDA.cmake:859 (message):
        Specify CUDA_TOOLKIT_ROOT_DIR
      Call Stack (most recent call first):
        src/gpusim/CMakeLists.txt:3 (find_package)

      -- Configuring incomplete, errors occurred!
      See also "/tmp/pip-install-8o8kjk9r/qulacs-gpu_dc39012c072548388f98f5526c10dac2/build/temp.linux-x86_64-cpython-311/CMakeFiles/CMakeOutput.log".
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-8o8kjk9r/qulacs-gpu_dc39012c072548388f98f5526c10dac2/setup.py", line 111, in <module>
          setup(
        File "/usr/local/lib/python3.11/dist-packages/setuptools/__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/local/lib/python3.11/dist-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
                 ^^^^^^^^^^^^^^^^^^
        File "/usr/local/lib/python3.11/dist-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/usr/local/lib/python3.11/dist-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/usr/local/lib/python3.11/dist-packages/setuptools/dist.py", line 963, in run_command
          super().run_command(command)
        File "/usr/local/lib/python3.11/dist-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/usr/local/lib/python3.11/dist-packages/wheel/bdist_wheel.py", line 368, in run
          self.run_command("build")
        File "/usr/local/lib/python3.11/dist-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/usr/local/lib/python3.11/dist-packages/setuptools/dist.py", line 963, in run_command
          super().run_command(command)
        File "/usr/local/lib/python3.11/dist-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/usr/local/lib/python3.11/dist-packages/setuptools/_distutils/command/build.py", line 131, in run
          self.run_command(cmd_name)
        File "/usr/local/lib/python3.11/dist-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/usr/local/lib/python3.11/dist-packages/setuptools/dist.py", line 963, in run_command
          super().run_command(command)
        File "/usr/local/lib/python3.11/dist-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/tmp/pip-install-8o8kjk9r/qulacs-gpu_dc39012c072548388f98f5526c10dac2/setup.py", line 50, in run
          self.build_extension(ext)
        File "/tmp/pip-install-8o8kjk9r/qulacs-gpu_dc39012c072548388f98f5526c10dac2/setup.py", line 108, in build_extension
          subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
        File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['cmake', '/tmp/pip-install-8o8kjk9r/qulacs-gpu_dc39012c072548388f98f5526c10dac2', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-8o8kjk9r/qulacs-gpu_dc39012c072548388f98f5526c10dac2/build/lib.linux-x86_64-cpython-311', '-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/tmp/pip-install-8o8kjk9r/qulacs-gpu_dc39012c072548388f98f5526c10dac2/build/lib.linux-x86_64-cpython-311', '-DPYTHON_EXECUTABLE=/usr/bin/python3.11', '-DPYTHON_SETUP_FLAG:STR=Yes', '-DCMAKE_C_COMPILER=gcc', '-DCMAKE_CXX_COMPILER=g++', '-DCMAKE_BUILD_TYPE=Release', '-DUSE_GPU:STR=Yes']' returned non-zero exit status 1.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for qulacs-gpu
  Running setup.py clean for qulacs-gpu
Failed to build qulacs-gpu
ERROR: Could not build wheels for qulacs-gpu, which is required to install pyproject.toml-based project

I am wondering what this means, and how I can fix it. Thank you very much for your help.

josh146 commented 7 months ago

Hi @JustinS6626! This looks like an error compiling Qulacs for GPUs on your system; unfortunately, we'll likely be unable to help you out here, as this looks to be an issue with Qulacs. I suggest opening an issue in the Qulacs GitHub here: https://github.com/qulacs/qulacs

JustinS6626 commented 7 months ago

Thank you very much for getting back to me! I actually succeeded in overcoming the issue for Qulacs-GPU using the command

USE_GPU=Yes sudo pip3.11 install --no-build-isolation .

Could it work for pennylane-qulacs-gpu as well?