安装 pycuda 出现 PEP517 的错误

执行:pip install pycuda

出现:Building wheel for pycuda (PEP 517) ... error

Building wheels for collected packages: pycuda, pytools
  Building wheel for pycuda (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3.8 /usr/local/lib/python3.8/dist-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmp8diqrj_c
       cwd: /tmp/pip-install-xt280urn/pycuda_5d4c81cb559b4a6fa572a62bf9757598
  Complete output (101 lines):
  *************************************************************
  *** I have detected that you have not run configure.py.
  *************************************************************
  *** Additionally, no global config files were found.
  *** I will go ahead with the default configuration.
  *** In all likelihood, this will not work out.
  ***
  *** See README_SETUP.txt for more information.
  ***
  *** If the build does fail, just re-run configure.py with the
  *** correct arguments, and then retry. Good luck!
  *************************************************************
  *** HIT Ctrl-C NOW IF THIS IS NOT WHAT YOU WANT
  *************************************************************
  Continuing in 1 seconds...    
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.8
  creating build/lib.linux-x86_64-3.8/pycuda
  copying pycuda/cumath.py -> build/lib.linux-x86_64-3.8/pycuda
  copying pycuda/compiler.py -> build/lib.linux-x86_64-3.8/pycuda
  copying pycuda/_cluda.py -> build/lib.linux-x86_64-3.8/pycuda
  copying pycuda/elementwise.py -> build/lib.linux-x86_64-3.8/pycuda
  copying pycuda/characterize.py -> build/lib.linux-x86_64-3.8/pycuda
  copying pycuda/tools.py -> build/lib.linux-x86_64-3.8/pycuda
  copying pycuda/debug.py -> build/lib.linux-x86_64-3.8/pycuda
  copying pycuda/autoinit.py -> build/lib.linux-x86_64-3.8/pycuda
  copying pycuda/autoprimaryctx.py -> build/lib.linux-x86_64-3.8/pycuda
  copying pycuda/scan.py -> build/lib.linux-x86_64-3.8/pycuda
  copying pycuda/reduction.py -> build/lib.linux-x86_64-3.8/pycuda
  copying pycuda/_mymako.py -> build/lib.linux-x86_64-3.8/pycuda
  copying pycuda/driver.py -> build/lib.linux-x86_64-3.8/pycuda
  copying pycuda/curandom.py -> build/lib.linux-x86_64-3.8/pycuda
  copying pycuda/__init__.py -> build/lib.linux-x86_64-3.8/pycuda
  copying pycuda/gpuarray.py -> build/lib.linux-x86_64-3.8/pycuda
  creating build/lib.linux-x86_64-3.8/pycuda/gl
  copying pycuda/gl/autoinit.py -> build/lib.linux-x86_64-3.8/pycuda/gl
  copying pycuda/gl/__init__.py -> build/lib.linux-x86_64-3.8/pycuda/gl
  creating build/lib.linux-x86_64-3.8/pycuda/sparse
  copying pycuda/sparse/packeted.py -> build/lib.linux-x86_64-3.8/pycuda/sparse
  copying pycuda/sparse/operator.py -> build/lib.linux-x86_64-3.8/pycuda/sparse
  copying pycuda/sparse/coordinate.py -> build/lib.linux-x86_64-3.8/pycuda/sparse
  copying pycuda/sparse/cg.py -> build/lib.linux-x86_64-3.8/pycuda/sparse
  copying pycuda/sparse/pkt_build.py -> build/lib.linux-x86_64-3.8/pycuda/sparse
  copying pycuda/sparse/inner.py -> build/lib.linux-x86_64-3.8/pycuda/sparse
  copying pycuda/sparse/__init__.py -> build/lib.linux-x86_64-3.8/pycuda/sparse
  creating build/lib.linux-x86_64-3.8/pycuda/compyte
  copying pycuda/compyte/array.py -> build/lib.linux-x86_64-3.8/pycuda/compyte
  copying pycuda/compyte/dtypes.py -> build/lib.linux-x86_64-3.8/pycuda/compyte
  copying pycuda/compyte/__init__.py -> build/lib.linux-x86_64-3.8/pycuda/compyte
  running egg_info
  /usr/local/lib/python3.8/dist-packages/setuptools/_distutils/dist.py:275: UserWarning: Unknown distribution option: 'test_requires'
    warnings.warn(msg)
  warning: no files found matching 'doc/source/*.rst'
  warning: no files found matching 'doc/source/conf.py'
  warning: no files found matching 'doc/source/_static/*.css'
  warning: no files found matching 'doc/source/_templates/*.html'
  warning: no files found matching '*.cpp' under directory 'bpl-subset/bpl_subset/boost'
  warning: no files found matching '*.html' under directory 'bpl-subset/bpl_subset/boost'
  warning: no files found matching '*.inl' under directory 'bpl-subset/bpl_subset/boost'
  warning: no files found matching '*.txt' under directory 'bpl-subset/bpl_subset/boost'
  warning: no files found matching '*.h' under directory 'bpl-subset/bpl_subset/libs'
  warning: no files found matching '*.ipp' under directory 'bpl-subset/bpl_subset/libs'
  warning: no files found matching '*.pl' under directory 'bpl-subset/bpl_subset/libs'
  writing manifest file 'pycuda.egg-info/SOURCES.txt'
  creating build/lib.linux-x86_64-3.8/pycuda/cuda
  copying pycuda/cuda/pycuda-complex-impl.hpp -> build/lib.linux-x86_64-3.8/pycuda/cuda
  copying pycuda/cuda/pycuda-complex.hpp -> build/lib.linux-x86_64-3.8/pycuda/cuda
  copying pycuda/cuda/pycuda-helpers.hpp -> build/lib.linux-x86_64-3.8/pycuda/cuda
  copying pycuda/sparse/pkt_build_cython.pyx -> build/lib.linux-x86_64-3.8/pycuda/sparse
  running build_ext
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/bpl-subset
  creating build/temp.linux-x86_64-3.8/bpl-subset/bpl_subset
  creating build/temp.linux-x86_64-3.8/bpl-subset/bpl_subset/libs
  creating build/temp.linux-x86_64-3.8/bpl-subset/bpl_subset/libs/python
  creating build/temp.linux-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src
  creating build/temp.linux-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/converter
  creating build/temp.linux-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/object
  creating build/temp.linux-x86_64-3.8/bpl-subset/bpl_subset/libs/smart_ptr
  creating build/temp.linux-x86_64-3.8/bpl-subset/bpl_subset/libs/smart_ptr/src
  creating build/temp.linux-x86_64-3.8/bpl-subset/bpl_subset/libs/system
  creating build/temp.linux-x86_64-3.8/bpl-subset/bpl_subset/libs/system/src
  creating build/temp.linux-x86_64-3.8/bpl-subset/bpl_subset/libs/thread
  creating build/temp.linux-x86_64-3.8/bpl-subset/bpl_subset/libs/thread/src
  creating build/temp.linux-x86_64-3.8/bpl-subset/bpl_subset/libs/thread/src/pthread
  creating build/temp.linux-x86_64-3.8/src
  creating build/temp.linux-x86_64-3.8/src/cpp
  creating build/temp.linux-x86_64-3.8/src/wrapper
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -fwrapv -Wall -O3 -DNDEBUG -fPIC -DBOOST_ALL_NO_LIB=1 -DBOOST_THREAD_BUILD_DLL=1 -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION=1 -DBOOST_PYTHON_SOURCE=1 -Dboost=pycudaboost -DBOOST_THREAD_DONT_USE_CHRONO=1 -DPYGPU_PACKAGE=pycuda -DPYGPU_PYCUDA=1 -DHAVE_CURAND=1 -Isrc/cpp -Ibpl-subset/bpl_subset -I/usr/local/cuda/include -I/usr/local/lib/python3.8/dist-packages/numpy/core/include -I/usr/include/python3.8 -c bpl-subset/bpl_subset/libs/python/src/converter/arg_to_python_base.cpp -o build/temp.linux-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/converter/arg_to_python_base.o
  In file included from bpl-subset/bpl_subset/boost/python/detail/prefix.hpp:13:0,
                   from bpl-subset/bpl_subset/boost/python/handle.hpp:8,
                   from bpl-subset/bpl_subset/boost/python/converter/arg_to_python_base.hpp:7,
                   from bpl-subset/bpl_subset/libs/python/src/converter/arg_to_python_base.cpp:6:
  bpl-subset/bpl_subset/boost/python/detail/wrap_python.hpp:50:11: fatal error: pyconfig.h: No such file or directory
   # include <pyconfig.h>
             ^~~~~~~~~~~~
  compilation terminated.
  error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for pycuda
  Building wheel for pytools (setup.py) ... done
  Created wheel for pytools: filename=pytools-2022.1.12-py2.py3-none-any.whl size=65018 sha256=2f79761cd040baf74f025c6e24389b80090418b274cfa64973308c7e1f2748f1
  Stored in directory: /tmp/pip-ephem-wheel-cache-5i9u00g4/wheels/d6/c4/2a/41a750b89bfe174e3f6ee7c874e2c8595b94d2f924dcf53755
Successfully built pytools
Failed to build pycuda
ERROR: Could not build wheels for pycuda which use PEP 517 and cannot be installed directly

使用:pip install pycuda --no-binary :all:

不解决问题。

从源码编译,解决问题。

1、下载 pycuda-2021.1.tar.gz

2、tar xfz pycuda-2021.1.tar.gz

3、cd pycuda-2021.1

4、python3 configure.py --cuda-root=/usr/local/cuda   

5、make install

如果有找不到 pyconfig.h 的错误,就安装 python3-dev。

如果有找不到 nvcc 的错误,就 export CUDA_ROOT=/usr/local/cuda/bin。

2022-11-04:

在 安装了 python3-dev 后,直接 pip install pycuda 也会成功。

参考:

Installing PyCUDA on Linux - Andreas Klöckner's Former Wiki

pycuda -- 'CUDA_ROOT not set, and nvcc not in path.' - Stack Overflow

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值