Solution for link error:Cannot Open File 'python27_d.lib'

版权所有,转载请注明出处:http://guangboo.org/2013/01/17/solution-link-errorcannot-open-file-python27_dlib

使用C调用Python函数或解释器时,在添加了Include Directories和Library Directories等配置后,仍然编译错误:"LINK : fatal error LNK1104: cannot open file 'python27_d.lib'".代码如下:

#include <stdio.h>
#include <Python.h>

int main(void)
{
	Py_Initialize();
	if(!Py_IsInitialized()){
		printf("Python Initialize failed.\n");
		return 1;
	}

	PyRun_SimpleString("print('hello world!')");
	Py_Finalize();
	system("pause");

	return 0;
}

Stackoverflow贴出了pyconfig.h头文件中对Python27_d.lib的引用(http://stackoverflow.com/questions/11311877/creating-a-dll-from-a-wrapped-cpp-file-with-

swig/14372472#14372472),该文件用于调试用,如下代码:

/* For Windows the Python core is in a DLL by default.  Test
Py_NO_ENABLE_SHARED to find out.  Also support MS_NO_COREDLL for b/w compat */
#if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED)
#	define Py_ENABLE_SHARED 1 /* standard symbol for shared library */
#	define MS_COREDLL	/* deprecated old symbol */
#endif /* !MS_NO_COREDLL && ... */

/*  All windows compilers that use this header support __declspec */
#define HAVE_DECLSPEC_DLL

/* For an MSVC DLL, we can nominate the .lib files used by extensions */
#ifdef MS_COREDLL
#	ifndef Py_BUILD_CORE /* not building the core - must be an ext */
#		if defined(_MSC_VER)
			/* So MSVC users need not specify the .lib file in
			their Makefile (other compilers are generally
			taken care of by distutils.) */
#			ifdef _DEBUG
#				pragma comment(lib,"python27_d.lib")
#			else
#				pragma comment(lib,"python27.lib")
#			endif /* _DEBUG */
#		endif /* _MSC_VER */
#	endif /* Py_BUILD_CORE */
#endif /* MS_COREDLL */

可以发现,只有MS_NO_COREDLL或Py_NO_ENABLE_SHARED被定义了,那么#ifdef MS_COREDLL块的代码就不会被编译。因此可以在Configuration Properties->C/C++->Preprocessor->Preprocessor Definitions添加MS_NO_COREDLL或Py_NO_ENABLE_SHARED,去掉_DEBUG,将没有效果。也可以在引用python.h头文件前添加#define MS_NO_COREDLL或#define Py_NO_ENABLE_SHARED。

(li) lenovo@lenovo-ThinkStation-P920:/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan$ pip install -v --no-cache-dir --force-reinstall . 2>&1 | tee build.log Using pip 25.1 from /home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/pip (python 3.10) Looking in indexes: https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple Processing /media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan Preparing metadata (setup.py): started Running command python setup.py egg_info A module that was compiled using NumPy 1.x cannot be run in NumPy 2.2.6 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2. Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 35, in <module> File "/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/setup.py", line 17, in <module> import torch File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/__init__.py", line 1471, in <module> from .functional import * # noqa: F403 File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/functional.py", line 9, in <module> import torch.nn.functional as F File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/nn/__init__.py", line 1, in <module> from .modules import * # noqa: F403 File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/nn/modules/__init__.py", line 35, in <module> from .transformer import TransformerEncoder, TransformerDecoder, \ File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/nn/modules/transformer.py", line 20, in <module> device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'), /home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/nn/modules/transformer.py:20: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at ../torch/csrc/utils/tensor_numpy.cpp:84.) device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'), torch.__version__ = 2.2.0+cu118 CUDA_HOME = /home/lenovo/anaconda3/envs/li CUDA version: 11.8 /home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated. !! ******************************************************************************** Please consider removing the following classifiers in favor of a SPDX license expression: License :: OSI Approved :: BSD License See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details. ******************************************************************************** !! self._finalize_license_expression() running egg_info creating /tmp/pip-pip-egg-info-w2djvsss/selective_scan.egg-info writing /tmp/pip-pip-egg-info-w2djvsss/selective_scan.egg-info/PKG-INFO writing dependency_links to /tmp/pip-pip-egg-info-w2djvsss/selective_scan.egg-info/dependency_links.txt writing requirements to /tmp/pip-pip-egg-info-w2djvsss/selective_scan.egg-info/requires.txt writing top-level names to /tmp/pip-pip-egg-info-w2djvsss/selective_scan.egg-info/top_level.txt writing manifest file '/tmp/pip-pip-egg-info-w2djvsss/selective_scan.egg-info/SOURCES.txt' reading manifest file '/tmp/pip-pip-egg-info-w2djvsss/selective_scan.egg-info/SOURCES.txt' writing manifest file '/tmp/pip-pip-egg-info-w2djvsss/selective_scan.egg-info/SOURCES.txt' Preparing metadata (setup.py): finished with status 'done' Collecting torch (from selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/0a/7c/0a5b3aee977596459ec45be2220370fde8e017f651fecc40522fd478cb1e/torch-2.7.1-cp310-cp310-manylinux_2_28_x86_64.whl (821.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 821.2/821.2 MB 1.1 MB/s eta 0:00:00 Collecting packaging (from selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl (66 kB) Collecting ninja (from selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/eb/7a/455d2877fe6cf99886849c7f9755d897df32eaf3a0fba47b56e615f880f7/ninja-1.11.1.4-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (422 kB) Collecting einops (from selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/87/62/9773de14fe6c45c23649e98b83231fffd7b9892b6cf863251dc2afa73643/einops-0.8.1-py3-none-any.whl (64 kB) Collecting filelock (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/4d/36/2a115987e2d8c300a974597416d9de88f2444426de9571f4b59b2cca3acc/filelock-3.18.0-py3-none-any.whl (16 kB) Collecting typing-extensions>=4.10.0 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/69/e0/552843e0d356fbb5256d21449fa957fa4eff3bbc135a74a691ee70c7c5da/typing_extensions-4.14.0-py3-none-any.whl (43 kB) Collecting sympy>=1.13.3 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/a2/09/77d55d46fd61b4a135c444fc97158ef34a095e5681d0a6c10b75bf356191/sympy-1.14.0-py3-none-any.whl (6.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.3/6.3 MB 946.1 kB/s eta 0:00:00 Link requires a different Python (3.10.18 not in: '>=3.11'): https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/eb/8d/776adee7bbf76365fdd7f2552710282c79a4ead5d2a46408c9043a2b70ba/networkx-3.5-py3-none-any.whl (from https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/networkx/) (requires-python:>=3.11) Link requires a different Python (3.10.18 not in: '>=3.11'): https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/6c/4f/ccdb8ad3a38e583f214547fd2f7ff1fc160c43a75af88e6aec213404b96a/networkx-3.5.tar.gz (from https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/networkx/) (requires-python:>=3.11) Link requires a different Python (3.10.18 not in: '>=3.11'): https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/3f/a1/46c1b6e202e3109d2a035b21a7e5534c5bb233ee30752d7f16a0bd4c3989/networkx-3.5rc0-py3-none-any.whl (from https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/networkx/) (requires-python:>=3.11) Link requires a different Python (3.10.18 not in: '>=3.11'): https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/90/7e/0319606a20ced20730806b9f7fe91d8a92f7da63d76a5c388f87d3f7d294/networkx-3.5rc0.tar.gz (from https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/networkx/) (requires-python:>=3.11) Collecting networkx (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/b9/54/dd730b32ea14ea797530a4479b2ed46a6fb250f682a9cfb997e968bf0261/networkx-3.4.2-py3-none-any.whl (1.7 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 883.3 kB/s eta 0:00:00 Collecting jinja2 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl (134 kB) Collecting fsspec (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/bb/61/78c7b3851add1481b048b5fdc29067397a1784e2910592bc81bb3f608635/fsspec-2025.5.1-py3-none-any.whl (199 kB) Collecting nvidia-cuda-nvrtc-cu12==12.6.77 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/75/2e/46030320b5a80661e88039f59060d1790298b4718944a65a7f2aeda3d9e9/nvidia_cuda_nvrtc_cu12-12.6.77-py3-none-manylinux2014_x86_64.whl (23.7 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 23.7/23.7 MB 1.1 MB/s eta 0:00:00 Collecting nvidia-cuda-runtime-cu12==12.6.77 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/e1/23/e717c5ac26d26cf39a27fbc076240fad2e3b817e5889d671b67f4f9f49c5/nvidia_cuda_runtime_cu12-12.6.77-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (897 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 897.7/897.7 kB 1.7 MB/s eta 0:00:00 Collecting nvidia-cuda-cupti-cu12==12.6.80 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/49/60/7b6497946d74bcf1de852a21824d63baad12cd417db4195fc1bfe59db953/nvidia_cuda_cupti_cu12-12.6.80-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (8.9 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.9/8.9 MB 1.1 MB/s eta 0:00:00 Collecting nvidia-cudnn-cu12==9.5.1.17 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/2a/78/4535c9c7f859a64781e43c969a3a7e84c54634e319a996d43ef32ce46f83/nvidia_cudnn_cu12-9.5.1.17-py3-none-manylinux_2_28_x86_64.whl (571.0 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 571.0/571.0 MB 1.1 MB/s eta 0:00:00 Collecting nvidia-cublas-cu12==12.6.4.1 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/af/eb/ff4b8c503fa1f1796679dce648854d58751982426e4e4b37d6fce49d259c/nvidia_cublas_cu12-12.6.4.1-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (393.1 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 393.1/393.1 MB 889.2 kB/s eta 0:00:00 Collecting nvidia-cufft-cu12==11.3.0.4 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/8f/16/73727675941ab8e6ffd86ca3a4b7b47065edcca7a997920b831f8147c99d/nvidia_cufft_cu12-11.3.0.4-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (200.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 200.2/200.2 MB 761.5 kB/s eta 0:00:00 Collecting nvidia-curand-cu12==10.3.7.77 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/73/1b/44a01c4e70933637c93e6e1a8063d1e998b50213a6b65ac5a9169c47e98e/nvidia_curand_cu12-10.3.7.77-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (56.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 56.3/56.3 MB 1.1 MB/s eta 0:00:00 Collecting nvidia-cusolver-cu12==11.7.1.2 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/f0/6e/c2cf12c9ff8b872e92b4a5740701e51ff17689c4d726fca91875b07f655d/nvidia_cusolver_cu12-11.7.1.2-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (158.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 158.2/158.2 MB 881.4 kB/s eta 0:00:00 Collecting nvidia-cusparse-cu12==12.5.4.2 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/06/1e/b8b7c2f4099a37b96af5c9bb158632ea9e5d9d27d7391d7eb8fc45236674/nvidia_cusparse_cu12-12.5.4.2-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (216.6 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 216.6/216.6 MB 1.4 MB/s eta 0:00:00 Collecting nvidia-cusparselt-cu12==0.6.3 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/3b/9a/72ef35b399b0e183bc2e8f6f558036922d453c4d8237dab26c666a04244b/nvidia_cusparselt_cu12-0.6.3-py3-none-manylinux2014_x86_64.whl (156.8 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 156.8/156.8 MB 887.6 kB/s eta 0:00:00 Collecting nvidia-nccl-cu12==2.26.2 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/67/ca/f42388aed0fddd64ade7493dbba36e1f534d4e6fdbdd355c6a90030ae028/nvidia_nccl_cu12-2.26.2-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (201.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 201.3/201.3 MB 1.1 MB/s eta 0:00:00 Collecting nvidia-nvtx-cu12==12.6.77 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/56/9a/fff8376f8e3d084cd1530e1ef7b879bb7d6d265620c95c1b322725c694f4/nvidia_nvtx_cu12-12.6.77-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (89 kB) Collecting nvidia-nvjitlink-cu12==12.6.85 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/9d/d7/c5383e47c7e9bf1c99d5bd2a8c935af2b6d705ad831a7ec5c97db4d82f4f/nvidia_nvjitlink_cu12-12.6.85-py3-none-manylinux2010_x86_64.manylinux_2_12_x86_64.whl (19.7 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 19.7/19.7 MB 1.9 MB/s eta 0:00:00 Collecting nvidia-cufile-cu12==1.11.1.6 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/b2/66/cc9876340ac68ae71b15c743ddb13f8b30d5244af344ec8322b449e35426/nvidia_cufile_cu12-1.11.1.6-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (1.1 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 1.9 MB/s eta 0:00:00 Collecting triton==3.3.1 (from torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/8d/a9/549e51e9b1b2c9b854fd761a1d23df0ba2fbc60bd0c13b489ffa518cfcb7/triton-3.3.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (155.6 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 155.6/155.6 MB 758.4 kB/s eta 0:00:00 Collecting setuptools>=40.8.0 (from triton==3.3.1->torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/a3/dc/17031897dae0efacfea57dfd3a82fdd2a2aeb58e0ff71b77b87e44edc772/setuptools-80.9.0-py3-none-any.whl (1.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 872.9 kB/s eta 0:00:00 Collecting mpmath<1.4,>=1.1.0 (from sympy>=1.13.3->torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/43/e3/7d92a15f894aa0c9c4b49b8ee9ac9850d6e63b03c9c32c0367a13ae62209/mpmath-1.3.0-py3-none-any.whl (536 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 536.2/536.2 kB 919.5 kB/s eta 0:00:00 Collecting MarkupSafe>=2.0 (from jinja2->torch->selective_scan==0.0.2) Downloading https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/22/35/137da042dfb4720b638d2937c38a9c2df83fe32d20e8c8f3185dbfef05f7/MarkupSafe-3.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (20 kB) Building wheels for collected packages: selective_scan DEPRECATION: Building 'selective_scan' using the legacy setup.py bdist_wheel mechanism, which will be removed in a future version. pip 25.3 will enforce this behaviour change. A possible replacement is to use the standardized build interface by setting the `--use-pep517` option, (possibly combined with `--no-build-isolation`), or adding a `pyproject.toml` file to the source tree of 'selective_scan'. Discussion can be found at https://github.com/pypa/pip/issues/6334 Building wheel for selective_scan (setup.py): started Running command python setup.py bdist_wheel A module that was compiled using NumPy 1.x cannot be run in NumPy 2.2.6 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2. Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 35, in <module> File "/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/setup.py", line 17, in <module> import torch File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/__init__.py", line 1471, in <module> from .functional import * # noqa: F403 File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/functional.py", line 9, in <module> import torch.nn.functional as F File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/nn/__init__.py", line 1, in <module> from .modules import * # noqa: F403 File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/nn/modules/__init__.py", line 35, in <module> from .transformer import TransformerEncoder, TransformerDecoder, \ File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/nn/modules/transformer.py", line 20, in <module> device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'), /home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/nn/modules/transformer.py:20: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at ../torch/csrc/utils/tensor_numpy.cpp:84.) device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'), torch.__version__ = 2.2.0+cu118 CUDA_HOME = /home/lenovo/anaconda3/envs/li CUDA version: 11.8 /home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated. !! ******************************************************************************** Please consider removing the following classifiers in favor of a SPDX license expression: License :: OSI Approved :: BSD License See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details. ******************************************************************************** !! self._finalize_license_expression() running bdist_wheel running build running build_ext /home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/utils/cpp_extension.py:425: UserWarning: There are no g++ version bounds defined for CUDA version 11.8 warnings.warn(f'There are no {compiler_name} version bounds defined for CUDA version {cuda_str_version}') building 'selective_scan_cuda_core' extension creating /media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/build/temp.linux-x86_64-cpython-310/csrc/selective_scan/cus Emitting ninja build file /media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/build/temp.linux-x86_64-cpython-310/build.ninja... Compiling objects... Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N) [1/3] c++ -MMD -MF '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/build/temp.linux-x86_64-cpython-310/csrc/selective_scan/cus/selective_scan.o'.d -pthread -B /home/lenovo/anaconda3/envs/li/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/lenovo/anaconda3/envs/li/include -fPIC -O2 -isystem /home/lenovo/anaconda3/envs/li/include -fPIC '-I/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/csrc/selective_scan' -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/TH -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/THC -I/home/lenovo/anaconda3/envs/li/include -I/home/lenovo/anaconda3/envs/li/include/python3.10 -c -c '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/csrc/selective_scan/cus/selective_scan.cpp' -o '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/build/temp.linux-x86_64-cpython-310/csrc/selective_scan/cus/selective_scan.o' -O3 -std=c++17 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=selective_scan_cuda_core -D_GLIBCXX_USE_CXX11_ABI=0 FAILED: /media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/build/temp.linux-x86_64-cpython-310/csrc/selective_scan/cus/selective_scan.o c++ -MMD -MF '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/build/temp.linux-x86_64-cpython-310/csrc/selective_scan/cus/selective_scan.o'.d -pthread -B /home/lenovo/anaconda3/envs/li/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/lenovo/anaconda3/envs/li/include -fPIC -O2 -isystem /home/lenovo/anaconda3/envs/li/include -fPIC '-I/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/csrc/selective_scan' -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/TH -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/THC -I/home/lenovo/anaconda3/envs/li/include -I/home/lenovo/anaconda3/envs/li/include/python3.10 -c -c '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/csrc/selective_scan/cus/selective_scan.cpp' -o '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/build/temp.linux-x86_64-cpython-310/csrc/selective_scan/cus/selective_scan.o' -O3 -std=c++17 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=selective_scan_cuda_core -D_GLIBCXX_USE_CXX11_ABI=0 In file included from /home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/ATen/cuda/CUDAContext.h:3, from /media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/csrc/selective_scan/cus/selective_scan.cpp:5: /home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/ATen/cuda/CUDAContextLight.h:6:10: fatal error: cuda_runtime_api.h: 没有那个文件或目录 6 | #include <cuda_runtime_api.h> | ^~~~~~~~~~~~~~~~~~~~ compilation terminated. [2/3] /home/lenovo/anaconda3/envs/li/bin/nvcc --generate-dependencies-with-compile --dependency-output '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/build/temp.linux-x86_64-cpython-310/csrc/selective_scan/cus/selective_scan_core_fwd.o'.d '-I/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/csrc/selective_scan' -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/TH -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/THC -I/home/lenovo/anaconda3/envs/li/include -I/home/lenovo/anaconda3/envs/li/include/python3.10 -c -c '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/csrc/selective_scan/cus/selective_scan_core_fwd.cu' -o '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/build/temp.linux-x86_64-cpython-310/csrc/selective_scan/cus/selective_scan_core_fwd.o' -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -O3 -std=c++17 -U__CUDA_NO_HALF_OPERATORS__ -U__CUDA_NO_HALF_CONVERSIONS__ -U__CUDA_NO_BFLOAT16_OPERATORS__ -U__CUDA_NO_BFLOAT16_CONVERSIONS__ -U__CUDA_NO_BFLOAT162_OPERATORS__ -U__CUDA_NO_BFLOAT162_CONVERSIONS__ --expt-relaxed-constexpr --expt-extended-lambda --use_fast_math --ptxas-options=-v -lineinfo -arch=sm_86 --threads 4 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=selective_scan_cuda_core -D_GLIBCXX_USE_CXX11_ABI=0 FAILED: /media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/build/temp.linux-x86_64-cpython-310/csrc/selective_scan/cus/selective_scan_core_fwd.o /home/lenovo/anaconda3/envs/li/bin/nvcc --generate-dependencies-with-compile --dependency-output '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/build/temp.linux-x86_64-cpython-310/csrc/selective_scan/cus/selective_scan_core_fwd.o'.d '-I/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/csrc/selective_scan' -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/TH -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/THC -I/home/lenovo/anaconda3/envs/li/include -I/home/lenovo/anaconda3/envs/li/include/python3.10 -c -c '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/csrc/selective_scan/cus/selective_scan_core_fwd.cu' -o '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/build/temp.linux-x86_64-cpython-310/csrc/selective_scan/cus/selective_scan_core_fwd.o' -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -O3 -std=c++17 -U__CUDA_NO_HALF_OPERATORS__ -U__CUDA_NO_HALF_CONVERSIONS__ -U__CUDA_NO_BFLOAT16_OPERATORS__ -U__CUDA_NO_BFLOAT16_CONVERSIONS__ -U__CUDA_NO_BFLOAT162_OPERATORS__ -U__CUDA_NO_BFLOAT162_CONVERSIONS__ --expt-relaxed-constexpr --expt-extended-lambda --use_fast_math --ptxas-options=-v -lineinfo -arch=sm_86 --threads 4 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=selective_scan_cuda_core -D_GLIBCXX_USE_CXX11_ABI=0 <command-line>: fatal error: cuda_runtime.h: 没有那个文件或目录 compilation terminated. <command-line>: fatal error: cuda_runtime.h: 没有那个文件或目录 compilation terminated. fatal : Could not open input file /tmp/tmpxft_00005756_00000000-7_selective_scan_core_fwd.cpp1.ii [3/3] /home/lenovo/anaconda3/envs/li/bin/nvcc --generate-dependencies-with-compile --dependency-output '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/build/temp.linux-x86_64-cpython-310/csrc/selective_scan/cus/selective_scan_core_bwd.o'.d '-I/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/csrc/selective_scan' -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/TH -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/THC -I/home/lenovo/anaconda3/envs/li/include -I/home/lenovo/anaconda3/envs/li/include/python3.10 -c -c '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/csrc/selective_scan/cus/selective_scan_core_bwd.cu' -o '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/build/temp.linux-x86_64-cpython-310/csrc/selective_scan/cus/selective_scan_core_bwd.o' -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -O3 -std=c++17 -U__CUDA_NO_HALF_OPERATORS__ -U__CUDA_NO_HALF_CONVERSIONS__ -U__CUDA_NO_BFLOAT16_OPERATORS__ -U__CUDA_NO_BFLOAT16_CONVERSIONS__ -U__CUDA_NO_BFLOAT162_OPERATORS__ -U__CUDA_NO_BFLOAT162_CONVERSIONS__ --expt-relaxed-constexpr --expt-extended-lambda --use_fast_math --ptxas-options=-v -lineinfo -arch=sm_86 --threads 4 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=selective_scan_cuda_core -D_GLIBCXX_USE_CXX11_ABI=0 FAILED: /media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/build/temp.linux-x86_64-cpython-310/csrc/selective_scan/cus/selective_scan_core_bwd.o /home/lenovo/anaconda3/envs/li/bin/nvcc --generate-dependencies-with-compile --dependency-output '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/build/temp.linux-x86_64-cpython-310/csrc/selective_scan/cus/selective_scan_core_bwd.o'.d '-I/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/csrc/selective_scan' -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/TH -I/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/include/THC -I/home/lenovo/anaconda3/envs/li/include -I/home/lenovo/anaconda3/envs/li/include/python3.10 -c -c '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/csrc/selective_scan/cus/selective_scan_core_bwd.cu' -o '/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/build/temp.linux-x86_64-cpython-310/csrc/selective_scan/cus/selective_scan_core_bwd.o' -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -O3 -std=c++17 -U__CUDA_NO_HALF_OPERATORS__ -U__CUDA_NO_HALF_CONVERSIONS__ -U__CUDA_NO_BFLOAT16_OPERATORS__ -U__CUDA_NO_BFLOAT16_CONVERSIONS__ -U__CUDA_NO_BFLOAT162_OPERATORS__ -U__CUDA_NO_BFLOAT162_CONVERSIONS__ --expt-relaxed-constexpr --expt-extended-lambda --use_fast_math --ptxas-options=-v -lineinfo -arch=sm_86 --threads 4 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=selective_scan_cuda_core -D_GLIBCXX_USE_CXX11_ABI=0 <command-line>: fatal error: cuda_runtime.h: 没有那个文件或目录 compilation terminated. <command-line>: fatal error: cuda_runtime.h: 没有那个文件或目录 compilation terminated. fatal : Could not open input file /tmp/tmpxft_00005755_00000000-7_selective_scan_core_bwd.cpp1.ii ninja: build stopped: subcommand failed. Traceback (most recent call last): File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 2096, in _run_ninja_build subprocess.run( File "/home/lenovo/anaconda3/envs/li/lib/python3.10/subprocess.py", line 526, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1. The above exception was the direct cause of the following exception: Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 35, in <module> File "/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/setup.py", line 146, in <module> setup( File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/__init__.py", line 117, in setup return distutils.core.setup(**attrs) File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 186, in setup return run_commands(dist) File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 202, in run_commands dist.run_commands() File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1002, in run_commands self.run_command(cmd) File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/dist.py", line 1104, in run_command super().run_command(command) File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command cmd_obj.run() File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/command/bdist_wheel.py", line 370, in run self.run_command("build") File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 357, in run_command self.distribution.run_command(command) File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/dist.py", line 1104, in run_command super().run_command(command) File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command cmd_obj.run() File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 135, in run self.run_command(cmd_name) File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 357, in run_command self.distribution.run_command(command) File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/dist.py", line 1104, in run_command super().run_command(command) File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command cmd_obj.run() File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 99, in run _build_ext.run(self) File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 368, in run self.build_extensions() File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 871, in build_extensions build_ext.build_extensions(self) File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 484, in build_extensions self._build_extensions_serial() File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 510, in _build_extensions_serial self.build_extension(ext) File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 264, in build_extension _build_ext.build_extension(self, ext) File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 565, in build_extension objects = self.compiler.compile( File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 684, in unix_wrap_ninja_compile _write_ninja_file_and_compile_objects( File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1774, in _write_ninja_file_and_compile_objects _run_ninja_build( File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 2112, in _run_ninja_build raise RuntimeError(message) from e RuntimeError: Error compiling objects for extension error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. full command: /home/lenovo/anaconda3/envs/li/bin/python3.10 -u -c ' exec(compile('"'"''"'"''"'"' # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py # # - It imports setuptools before invoking setup.py, to enable projects that directly # import from `distutils.core` to work with newer packaging standards. # - It provides a clear error message when setuptools is not installed. # - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so # setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning: # manifest_maker: standard file '"'"'-c'"'"' not found". # - It generates a shim setup.py, for handling setup.cfg-only projects. import os, sys, tokenize, traceback try: import setuptools except ImportError: print( "ERROR: Can not execute `setup.py` since setuptools failed to import in " "the build environment with exception:", file=sys.stderr, ) traceback.print_exc() sys.exit(1) __file__ = %r sys.argv[0] = __file__ if os.path.exists(__file__): filename = __file__ with tokenize.open(__file__) as f: setup_py_code = f.read() else: filename = "<auto-generated setuptools caller>" setup_py_code = "from setuptools import setup; setup()" exec(compile(setup_py_code, filename, "exec")) '"'"''"'"''"'"' % ('"'"'/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' bdist_wheel -d /tmp/pip-wheel-fm2tmb40 cwd: /media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/ Building wheel for selective_scan (setup.py): finished with status 'error' ERROR: Failed building wheel for selective_scan Running setup.py clean for selective_scan Running command python setup.py clean A module that was compiled using NumPy 1.x cannot be run in NumPy 2.2.6 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2. Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 35, in <module> File "/media/lenovo/PHILIPS/Mamba_20250409_ torch22_cuda118/VMamba-main/kernels/selective_scan/setup.py", line 17, in <module> import torch File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/__init__.py", line 1471, in <module> from .functional import * # noqa: F403 File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/functional.py", line 9, in <module> import torch.nn.functional as F File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/nn/__init__.py", line 1, in <module> from .modules import * # noqa: F403 File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/nn/modules/__init__.py", line 35, in <module> from .transformer import TransformerEncoder, TransformerDecoder, \ File "/home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/nn/modules/transformer.py", line 20, in <module> device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'), /home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/torch/nn/modules/transformer.py:20: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at ../torch/csrc/utils/tensor_numpy.cpp:84.) device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'), torch.__version__ = 2.2.0+cu118 CUDA_HOME = /home/lenovo/anaconda3/envs/li CUDA version: 11.8 /home/lenovo/anaconda3/envs/li/lib/python3.10/site-packages/setuptools/dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated. !! ******************************************************************************** Please consider removing the following classifiers in favor of a SPDX license expression: License :: OSI Approved :: BSD License See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details. ******************************************************************************** !! self._finalize_license_expression() running clean removing 'build/temp.linux-x86_64-cpython-310' (and everything under it) 'build/lib.linux-x86_64-cpython-310' does not exist -- can't clean it 'build/bdist.linux-x86_64' does not exist -- can't clean it 'build/scripts-3.10' does not exist -- can't clean it removing 'build' Failed to build selective_scan ERROR: Failed to build installable wheels for some pyproject.toml based projects (selective_scan)
07-04
RuntimeError: SetPrecisionMode:build/CMakeFiles/torch_npu.dir/compiler_depend.ts:155 NPU function error: at_npu::native::AclSetCompileopt(aclCompileOpt::ACL_PRECISION_MODE, precision_mode), error code is 500001 [ERROR] 2025-07-07-15:58:56 (PID:4001235, Device:0, RankID:-1) ERR00100 PTA call acl api failed [Error]: The internal ACL of the system is incorrect. Rectify the fault based on the error information in the ascend log. EC0010: [PID: 4001235] 2025-07-07-15:58:56.704.356 Failed to import Python module [AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead..]. Solution: Check that all required components are properly installed and the specified Python path matches the Python installation directory. (If the path does not match the directory, run set_env.sh in the installation package.) TraceBack (most recent call last): AOE Failed to call InitCannKB[FUNC:Initialize][FILE:python_adapter_manager.cc][LINE:47] Failed to initialize TeConfigInfo. [GraphOpt][InitializeInner][InitTbeFunc] Failed to init tbe.[FUNC:InitializeTeFusion][FILE:tbe_op_store_adapter.cc][LINE:1889] [GraphOpt][InitializeInner][InitTeFusion]: Failed to initialize TeFusion.[FUNC:InitializeInner][FILE:tbe_op_store_adapter.cc][LINE:1856] [SubGraphOpt][PreCompileOp][InitAdapter] InitializeAdapter adapter [tbe_op_adapter] failed! Ret [4294967295][FUNC:InitializeAdapter][FILE:op_store_adapter_manager.cc][LINE:79] [SubGraphOpt][PreCompileOp][Init] Initialize op store adapter failed, OpsStoreName[tbe-custom].[FUNC:Initialize][FILE:op_store_adapter_manager.cc][LINE:120] [FusionMngr][Init] Op store adapter manager init failed.[FUNC:Initialize][FILE:fusion_manager.cc][LINE:115] PluginManager InvokeAll failed.[FUNC:Initialize][FILE:ops_kernel_manager.cc][LINE:83] OpsManager initialize failed.[FUNC:InnerInitialize][FILE:gelib.cc][LINE:259] GELib::InnerInitialize failed.[FUNC:Initialize][FILE:gelib.cc][LINE:184] GEInitialize failed.[FUNC:GEInitialize][FILE:ge_api.cc][LINE:371] [Initialize][Ge]GEInitialize failed. ge result = 4294967295[FUNC:ReportCallError][FILE:log_inner.cpp][LINE:161] [Init][Compiler]Init compiler failed[FUNC:ReportInnerError][FILE:log_inner.cpp][LINE:145] [Set][Options]OpCompileProcessor init failed![FUNC:ReportInnerError][FILE:log_inner.cpp][LINE:145]
最新发布
07-08
<think>我们正在解决一个复杂的PyTorch NPU使用问题,涉及多个错误: 1. RuntimeError: SetPrecisionMode ACL_PRECISION_MODE error code 500001 2. 可能相关的numpy版本问题(AttributeError: module 'numpy' has no attribute 'float_',因为numpy 2.0移除了numpy.float_) 3. 以及ACL初始化失败 根据用户描述,错误信息包括: - RuntimeError SetPrecisionMode ACL_PRECISION_MODE error code 500001 - 提到numpy 2.0移除了numpy.float_,导致AttributeError 另外,用户提供的引用中提到了numpy的integer属性错误(引用[1])和tensorflow/pytorch环境设置(引用[2][3]),但这些引用仅供参考,我们需要聚焦于用户当前的问题。 分析: 1. ACL (Ascend Computing Language) 是华为昇腾NPU的编程接口。错误代码500001通常表示ACL内部错误,可能与配置、驱动版本或数据类型有关。 2. 在numpy 2.0中,`numpy.float_`被移除,而PyTorch的NPU支持可能还在使用这个属性,导致AttributeError。 因此,我们需要: - 确保numpy版本兼容(降级到1.x版本,因为2.0移除了float_) - 检查PyTorch NPU版本和驱动环境(包括CANN toolkit)是否匹配 - 检查ACL初始化是否正确 步骤: 步骤1:降级numpy版本 由于numpy 2.0移除了float_,我们可以降级到numpy 1.x版本(例如1.23.5或1.21.6等稳定版本)。 执行命令: pip install numpy==1.23.5 步骤2:检查PyTorch NPU版本和CANN toolkit版本兼容性 用户使用的是PyTorch NPU(可能是华为维护的分支),需要确保安装的版本与CANN toolkit版本匹配。 参考华为官方文档:https://gitee.com/ascend/pytorch 例如,常见的匹配关系: PyTorch 1.8.1 + CANN 5.0.2 或 PyTorch 2.0.1 + CANN 7.0 用户提到使用了torch==2.2.1+cu121(引用[3]),但注意这是CUDA版本,而NPU版本应该是不同的。用户需要安装针对NPU编译的PyTorch。 正确的安装命令应来自昇腾社区,例如: pip install torch==2.0.1+ascend -f https://gitee.com/ascend/pytorch/releases 注意:用户需要根据自己安装的CANN版本选择对应的PyTorch NPU版本。 步骤3:检查ACL初始化 在代码中,确保在使用NPU之前正确初始化ACL环境。通常,PyTorch NPU会自动初始化,但如果出现错误,可以尝试手动初始化(根据文档)。 示例代码: import torch import torch_npu # 初始化ACL torch.npu.init() # 设置设备 device = torch.device('npu:0') 注意:如果初始化失败,可能是驱动或CANN toolkit安装问题。 步骤4:检查SetPrecisionMode错误 这个错误可能是由于设置了不支持的精度模式。在昇腾NPU上,支持的精度模式有: allow_fp32_to_fp16(默认): 允许FP32转FP16 must_keep_origin_dtype: 保持原始精度 allow_mix_precision: 混合精度 可以通过环境变量设置: export ACL_PRECISION_MODE=allow_mix_precision 或者在代码中设置: torch.npu.set_precision_mode('allow_mix_precision') 尝试不同的模式看是否解决问题。 步骤5:检查环境变量 确保环境变量设置正确,包括: LD_LIBRARY_PATH:包含CANN库的路径 PYTHONPATH:包含PyTorch NPU的路径 ASCEND_GLOBAL_LOG_LEVEL=3 # 设置日志级别,方便调试 步骤6:查看昇腾日志 昇腾工具会生成日志,位于/var/log/npu/。查看最新的日志文件(例如profiling/*.log, slog/*)以获取详细错误信息。 总结解决方案: 1. 降级numpy到1.x版本(如1.23.5) 2. 确保安装的PyTorch NPU版本与CANN toolkit版本匹配 3. 在代码中初始化ACL:`torch.npu.init()` 4. 尝试设置不同的精度模式(通过环境变量或代码) 5. 检查环境变量和日志 如果以上步骤不能解决,可能需要重新安装驱动和CANN toolkit。 相关问题: 1. 如何检查昇腾NPU驱动和CANN toolkit的版本? 2. 如何在PyTorch中使用混合精度训练(NPU)? 3. 如何解决昇腾NPU环境下的其他常见错误?</think>### 解决PyTorch NPU的SetPrecisionMode错误与ACL初始化问题 #### 问题分析 1. **核心错误**: - `RuntimeError: SetPrecisionMode ACL_PRECISION_MODE error code 500001`:表明昇腾NPU的ACL库在设置精度模式时失败,通常由环境配置不匹配或数据类型冲突引发。 - `AttributeError: module 'numpy' has no attribute 'float_'`:因NumPy 2.0移除了`numpy.float_`等旧类型([NumPy 2.0迁移指南](https://numpy.org/devdocs/numpy_2_0_migration_guide.html)),而PyTorch NPU可能依赖这些类型[^1]。 2. **关联问题**: - ACL初始化失败:驱动/CANN版本不兼容或环境变量缺失。 - 数据类型冲突:NumPy 2.0与PyTorch NPU的兼容性问题。 --- #### 解决方案 ##### 步骤1:修复NumPy兼容性问题 ```bash # 降级NumPy到兼容版本(1.x系列) pip uninstall -y numpy pip install numpy==1.23.5 # 推荐稳定版本 ``` **说明**:NumPy 1.x保留`numpy.float_`等类型,避免AttributeError[^1]。 ##### 步骤2:检查PyTorch NPU环境 1. **验证驱动与CANN版本**: ```bash # 检查NPU驱动 npu-smi info # 检查CANN Toolkit版本(默认路径) cat /usr/local/Ascend/ascend-toolkit/latest/acllib.version ``` **要求**:PyTorch NPU版本必须与CANN严格匹配([华为官方版本对照表](https://gitee.com/ascend/pytorch))。 2. **重装匹配的PyTorch NPU**: ```bash # 示例:安装CANN 7.0对应的PyTorch 2.0.1 pip install torch==2.0.1+ascend -f https://gitee.com/ascend/pytorch/releases ``` ##### 步骤3:修复ACL初始化与精度模式错误 1. **设置精度模式环境变量**: ```bash # 在代码运行前配置(二选一) export ACL_PRECISION_MODE=allow_fp32_to_fp16 # 默认模式 export ACL_PRECISION_MODE=must_keep_origin_dtype # 严格保持原类型 ``` 2. **代码中显式初始化ACL**: ```python import torch import torch_npu # 初始化ACL环境 torch.npu.init() torch.npu.set_device(0) # 指定NPU设备 # 可选:手动设置精度模式 torch.npu.set_precision_mode("allow_fp32_to_fp16") ``` ##### 步骤4:验证环境完整性 ```python # 测试脚本 test_npu.py import torch import numpy as np print("NumPy version:", np.__version__) # 应为1.x print("PyTorch NPU支持:", torch.npu.is_available()) # 应返回True x = torch.tensor([1.0], device="npu:0") y = torch.tensor([2.0], device="npu:0") print("NPU计算验证:", x + y) # 应输出tensor([3.], device='npu:0') ``` **预期结果**:所有检查通过且无错误。 --- #### 关键排查点 1. **环境变量**: - 确保`LD_LIBRARY_PATH`包含CANN库路径: ```bash export LD_LIBRARY_PATH=/usr/local/Ascend/ascend-toolkit/latest/lib64:$LD_LIBRARY_PATH ``` 2. **日志分析**: - 查看ACL错误日志: ```bash cat /var/log/npu/slog/host-0/*.log | grep "error" ``` 3. **升级备选方案**: - 若需使用NumPy 2.0,需等待PyTorch NPU适配更新(跟踪[华为昇腾社区](https://ascend.huawei.com)公告)。 --- #### 相关问题 1. 如何检查昇腾NPU驱动与CANN工具包的兼容性? 2. PyTorch NPU如何进行混合精度训练? 3. 除`numpy.float_`外,NumPy 2.0还有哪些重大变更会影响深度学习框架?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值