Linux环境下Log4cpp-1.1.1 的下载、安装、配置

本文详细介绍了如何从源代码下载、编译、安装log4cpp日志库,并提供了一个简单的示例来展示如何在代码中使用它进行日志记录。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Log4cpp的主页为:http://sourceforge.net/projects/log4cpp/

       下载log4cpp-1.1.1. tar.gz    tar zxvf log4cpp-1.1.1 tar.gz  -C  /usr/local 解压到该目下
          
          安装:打开终端,在/usr/local/log4cpp/
          输入以下命令,
          ./configure
          make
          make check
          make install
          这里已经安装成功,默认的路径lib库路径是/usr/local/lib/,
          头文件的位置:/usr/local/include/log4cpp
          将/usr/local/lib下的和log4cpp相关的库都拷贝到/usr/lib,
          强调:使用log4cpp时,要加上# g++ log4test.cpp -llog4cpp -lpthread,才能顺利的编译通过
         
          Makefile中包含静态库或-llog4cpp动态库
          以管理员身份登录,将自己的库所在路径/usr/local/lib添加到/etc/ld.so.conf文件中。但一般这个文件中的内容都是一句“include /etc/ld.so.conf.d/*.conf”,因此最好在/etc/目录下新建一个文件 , 如“xxx.conf”,然后将自己的库所在路径添加到这个conf文件中

   修改完文件后,以root身份运行  /sbin/ldconfig -v   。这一步必不可少,别丢了。


         测试文档下:
</pre><pre name="code" class="cpp">#include <stdio.h>
#include <log4cpp/Category.hh>
#include <log4cpp/FileAppender.hh>
#include <log4cpp/SimpleLayout.hh>

#define LOGFILE "./test.log"

int main() {
    /*Setting up Appender, layout and Category*/
    log4cpp::Appender *appender = new log4cpp::FileAppender("FileAppender",LOGFILE);//第一个参数是appender的名字,第二个是log文件的名字
    log4cpp::Layout *layout = new log4cpp::SimpleLayout();
    //log4cpp::Layout *layout = new log4cpp::BasicLayout();
    log4cpp::Category& category = log4cpp::Category::getInstance("abc");

    appender->setLayout(layout);
    category.setAppender(appender);
    category.setPriority(log4cpp::Priority::INFO);

    /*The actual logging*/
    category.info("This is for tracing the flow");
    category.notice("This is to notify certain events");
    category.warn("This is to generate certain warnings");



(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
<think>我们正在尝试安装一个名为`selective_scan`的包,但遇到了编译错误和NumPy兼容性问题。根据引用[2]和[4],我们可以推断:1.该包可能是`mamba_ssm`的一部分,因为引用[1]和[4]都提到了安装`mamba_ssm`。 2.编译错误可能与CUDA版本有关,需要确保PyTorch的CUDA版本与系统CUDA工具包一致。3.NumPy兼容性问题可能是由于该包要求旧版本的NumPy(如1.x)而当前环境是NumPy2.x。根据引用[4],一个推荐的安装顺序是:```bashcondacreate -n mamba_envpython=3.10.13condaactivate mamba_envconda installcudatoolkit==11.8 -c nvidiapip installtorch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 --index-urlhttps://download.pytorch.org/whl/cu118condainstall -c "nvidia/label/cuda-11.8.0"cuda-nvcccondainstall packagingpipinstall causal-conv1d==1.1.1pipinstall mamba-ssm```但是,我们当前的问题是在安装`selective_scan`时出现的,而它可能是`mamba-ssm`的依赖。因此,我们按照以下步骤解决:###步骤1:创建并激活Conda环境(确保Python版本为3.10)```bashconda create-nmamba_env python=3.10.13conda activatemamba_env``` ###步骤2:安装匹配的CUDA工具包和PyTorch```bashcondainstall cudatoolkit=11.8-cnvidiapipinstall torch==2.1.1torchvision==0.16.1torchaudio==2.1.1--index-url https://download.pytorch.org/whl/cu118```###步骤3:安装编译所需的NVCC```bashconda install-c"nvidia/label/cuda-11.8.0"cuda-nvcc``` ###步骤4安装其他依赖```bashconda installpackaging``` ###步骤5:安装causal-conv1d和mamba-ssm```bashpip installcausal-conv1d==1.1.1pip installmamba-ssm``` ###处理NumPy兼容性问题如果安装过程中出现NumPy版本不兼容(例如要求NumPy<2.0),我们可以先安装兼容的NumPy版本: ```bashpip install"numpy<2.0"``` 然后再尝试安装`mamba-ssm`。###替代方案:使用预编译的wheel如果上述步骤仍然失败,我们可以尝试使用预编译的wheel(如引用[1]所示):```bashpipinstall causal_conv1d-1.0.0+cu118torch2.1cxx11abiFALSE-cp310-cp310-linux_x86_64.whlpip installmamba_ssm-1.0.1+cu118torch2.1cxx11abiFALSE-cp310-cp310-linux_x86_64.whl```注意:这些wheel文件需要从项目发布页面下载,并且确保与你的系统(Linux)、Python版本(cp310)和CUDA版本(cu118)匹配。###如果仍然遇到编译错误1. **确保编译环境完整**:在Linux上,安装build-essential:```bashsudo aptupdate &&sudo aptinstall build-essential``` 2. **强制重新编译**:设置环境变量强制重新编译:```bashexportCAUSAL_CONV1D_FORCE_BUILD=TRUEexport SELECTIVE_SCAN_FORCE_BUILD=TRUEpip install--no-cache-dir--force-reinstallcausal-conv1d mamba-ssm``` 3. **检查CUDA架构**:如果错误提到不支持的GPU架构(如`compute_89`),则需要设置环境变量指定支持的架构(例如RTX4090需要8.9,但CUDA11.8可能不支持,可尝试使用CUDA12.1):```bashexportTORCH_CUDA_ARCH_LIST="8.6"#例如,使用8.6代替8.9``` ###验证安装```pythonimporttorchfrom mamba_ssmimport Mambaprint(torch.__version__) print(torch.cuda.is_available()) #测试Mamba模块model =Mamba(d_model=64,d_state=16,d_conv=4,expand=2)print(model)``` ###注意事项-如果使用Windows,请确保在VisualStudio的命令提示符(如x64Native ToolsCommand Prompt)中执行安装,并安装C++构建工具[^3]。-如果使用Docker,建议使用NVIDIA官方提供的PyTorch镜像作为基础镜像。 §§相关问题§§1.如何查询显卡的计算能力(compute capability)?2.PyTorch不同版本对应的CUDA版本映射关系是什么? 3. Docker中如何配置支持CUDA的Python环境4.如何为开源项目添加跨平台编译支持?</think>### 解决 selective_scan 安装问题的完整指南 #### 核心问题分析 1. **CUDA 版本不匹配**: - PyTorch 的 CUDA 版本与系统 CUDA 工具包不一致(常见于 RTX 40 系列显卡) - 错误表现:`nvcc fatal: Unsupported gpu architecture 'compute_89'`[^2] 2. **NumPy 2.x 兼容性问题**: - selective_scan 依赖旧版 NumPy API(1.x),与 NumPy 2.x 不兼容 - 错误表现:`undefined symbol: PyArray_Type` 或导入错误 3. **编译环境缺失**: - Linux:缺少基础编译工具(build-essential) - Windows:缺少 MSVC 编译工具链[^3] --- ### 分步解决方案 #### 步骤1:创建专用虚拟环境(关键) ```bash conda create -n mamba_env python=3.10.13 # 使用兼容的Python版本[^4] conda activate mamba_env ``` #### 步骤2:安装匹配的 CUDA 工具链 ```bash # 安装 CUDA 11.8 工具包 conda install -c "nvidia/label/cuda-11.8.0" cuda-toolkit cuda-nvcc # 安装匹配的 PyTorch pip install torch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 \ --index-url https://download.pytorch.org/whl/cu118[^4] ``` #### 步骤3:解决 NumPy 兼容性问题 ```bash # 强制安装 NumPy 1.x (兼容版本) pip install "numpy<2.0" --force-reinstall ``` #### 步骤4安装编译依赖 ```bash # Linux 系统 sudo apt update && sudo apt install build-essential ninja-build # Windows 系统 安装 Visual Studio 2022,选择 "使用C++的桌面开发"[^3] ``` #### 步骤5:安装 selective_scan 组件 ```bash # 先安装依赖组件 pip install causal-conv1d==1.1.1 packaging # 确保版本匹配[^4] # 强制重新编译安装 export SELECTIVE_SCAN_FORCE_BUILD=TRUE # Linux/Mac # Windows 使用: set SELECTIVE_SCAN_FORCE_BUILD=TRUE [^3] pip install --no-cache-dir --force-reinstall mamba-ssm ``` #### 替代方案:使用预编译 wheel(推荐) ```bash # 下载匹配的预编译包(示例URL需替换为实际) pip install https://example.com/mamba_ssm-1.0.1+cu118torch2.1.1-cp310-cp310-linux_x86_64.whl[^1] ``` --- ### 常见错误处理 **错误1:CUDA 架构不支持** ```log nvcc fatal: Unsupported gpu architecture 'compute_89' ``` **解决**: ```bash # 指定支持的架构(RTX 30系用8.6,RTX 40系需CUDA>=11.8) export TORCH_CUDA_ARCH_LIST="8.6" pip install --force-reinstall mamba-ssm ``` **错误2:NumPy 兼容性问题** ```log ImportError: numpy.core.multiarray failed to import ``` **解决**: ```bash pip uninstall -y numpy pip install "numpy==1.23.5" # 确认兼容版本 ``` **错误3:MSVC 缺失(Windows)** ```log error: Microsoft Visual C++ 14.0 or greater is required ``` **解决**: 1. 安装 [Visual Studio Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) 2. 在 **x64 Native Tools Command Prompt** 中执行安装[^3] --- ### 验证安装成功 ```python import torch from mamba_ssm import Mamba print(torch.cuda.is_available()) # 应返回 True # 测试模型 model = Mamba( d_model=256, d_state=16, d_conv=4, expand=2 ) print(model) # 应显示模型结构 ``` > **关键提示**:对于 RTX 40 系列显卡(计算能力8.9+),必须使用 CUDA ≥ 11.8 和 PyTorch ≥ 2.1.1。若持续失败,建议使用 Docker 环境: > ```dockerfile > FROM nvcr.io/nvidia/pytorch:23.10-py3 > RUN pip install mamba-ssm > ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

For_dongyang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值