Repository: open-compass/opencompass
Issue: [Bug] 使用leval测评时报错，求助
Root cause: Environment Incompatibility

### 先决条件

- [X] 我已经搜索过 [问题](https://github.com/open-compass/opencompass/issues/) 和 [讨论](https://github.com/open-compass/opencompass/discussions) 但未得到预期的帮助。
- [X] 错误在 [最新版本](https://github.com/open-compass/opencompass) 中尚未被修复。

### 问题类型

我正在使用官方支持的任务/模型/数据集进行评估。

### 环境

{'CUDA available': True,
'CUDA_HOME': '/usr/local/cuda',
'GCC': 'gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0',
'GPU 0,1,2,3': 'NVIDIA A800-SXM4-40GB',
'MMEngine': '0.10.5',
'MUSA available': False,
'NVCC': 'Cuda compilation tools, release 12.4, V12.4.131',
'OpenCV': '4.9.0',
'PyTorch': '2.5.1+cu124',
'PyTorch compiling details': 'PyTorch built with:\n'
' - GCC 9.3\n'
' - C++ Version: 201703\n'
' - Intel(R) oneAPI Math Kernel Library Version '
'2024.2-Product Build 20240605 for Intel(R) 64 '
'architecture applications\n'
' - Intel(R) MKL-DNN v3.5.3 (Git Hash '
'66f0cb9eb66affd2da3bf5f8d897376f04aae6af)\n'
' - OpenMP 201511 (a.k.a. OpenMP 4.5)\n'
' - LAPACK is enabled (usually provided by '
'MKL)\n'
' - NNPACK is enabled\n'
' - CPU capability usage: AVX2\n'
' - CUDA Runtime 12.4\n'
' - NVCC architecture flags: '
'-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_90,code=sm_90\n'
' - CuDNN 90.1\n'
' - Magma 2.6.1\n'
' - Build settings: BLAS_INFO=mkl, '
'BUILD_TYPE=Release, CUDA_VERSION=12.4, '
'CUDNN_VERSION=9.1.0, '
'CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, '
'CXX_FLAGS= -D_GLIBCXX_USE_CXX11_ABI=0 '
'-fabi-version=11 -fvisibility-inlines-hidden '
'-DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO '
'-DLIBKINETO_NOROCTRACER -DLIBKINETO_NOXPUPTI=ON '
'-DUSE_FBGEMM -DUSE_PYTORCH_QNNPACK '
'-DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE '
'-O2 -fPIC -Wall -Wextra -Werror=return-type '
'-Werror=non-virtual-dtor -Werror=bool-operation '
'-Wnarrowing -Wno-missing-field-initializers '
'-Wno-type-limits -Wno-array-bounds '
'-Wno-unknown-pragmas -Wno-unused-parameter '
'-Wno-strict-overflow -Wno-strict-aliasing '
'-Wno-stringop-overflow -Wsuggest-override '
'-Wno-psabi -Wno-error=old-style-cast '
'-Wno-missing-braces -fdiagnostics-color=always '
'-faligned-new -Wno-unused-but-set-variable '
'-Wno-maybe-uninitialized -fno-math-errno '
'-fno-trapping-math -Werror=format '
'-Wno-stringop-overflow, LAPACK_INFO=mkl, '
'PERF_WITH_AVX=1, PERF_WITH_AVX2=1, '
'TORCH_VERSION=2.5.1, USE_CUDA=ON, USE_CUDNN=ON, '
'USE_CUSPARSELT=1, USE_EXCEPTION_PTR=1, '
'USE_GFLAGS=OFF, USE_GLOG=OFF, USE_GLOO=ON, '
'USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, '
'USE_NCCL=1, USE_NNPACK=ON, USE_OPENMP=ON, '
'USE_ROCM=OFF, USE_ROCM_KERNEL_ASSERT=OFF, \n',
'Python': '3.10.16 | packaged by conda-forge | (main, Dec 5 2024, 14:16:10) '
'[GCC 13.3.0]',
'TorchVision': '0.20.1+cu124',
'lmdeploy': '0.2.2',
'numpy_random_seed': 2147483648,
'opencompass': '0.3.9+7f2aeef',
'sys.platform': 'linux',
'transformers': '4.48.0'}

### 重现问题 - 代码/配置示例

python -m vllm.entrypoints.openai.api_server \
    --model /workspace/mnt/cm-nfx/model/Falcon3-Mamba-7B-Instruct \
    --served-model-name mamba \
    --host 0.0.0.0 \
    --port 6606 \
    --tensor-parallel-size 2 \
    --max-model-len 32768

### 重现问题 - 命令或脚本

from mmengine.config import read_base
from opencompass.models import OpenAISDK

with read_base():
    # from opencompass.configs.datasets.humaneval.humaneval_gen_8e312c import humaneval_datasets  # noqa: F401, F403
    # from opencompass.configs.datasets.ARC_c.ARC_c_gen import ARC_c_datasets  # noqa: F401, F403
    # from opencompass.configs.datasets.longbench.longbench import longbench_datasets
    from opencompass.configs.datasets.leval.leval import leval_datasets
    #from opencompass.configs.datasets.needlebench.needlebench_4k.needlebench_4k import needlebench_datasets
    #from .summarizers.needlebench import needlebench_4k_summarizer as summarizer

datasets = leval_datasets

api_meta_template = dict(
    round=[
        dict(role='HUMAN', api_role='HUMAN'),
        dict(role='BOT', api_role='BOT', generate=True),
    ],
    reserved_roles=[dict(role='SYSTEM', api_role='SYSTEM')],
)

models = [
    dict(
        abbr='mamba',
        type=OpenAISDK,
        key='EMPTY', # API key
        openai_api_base='http://0.0.0.0:6606/v1', # 服务地址
        path='mamba', # 请求服务时的 model name
        tokenizer_path='/workspace/mnt/cm-nfx/model/Falcon3-Mamba-7B-Instruct', # 请求服务时的 tokenizer name 或 path, 为None时使用默认tokenizer gpt-4
        rpm_verbose=True, # 是否打印请求速率
        meta_template=api_meta_template, # 服务请求模板
        query_per_second=1, # 服务请求速率
        max_out_len=512, # 最大输出长度
        max_seq_len=32768, # 最大输入长度
        temperature=0.01, # 生成温度
        batch_size=8, # 批处理大小
    )
]


### 重现问题 - 错误信息

/workspace/mnt/cm-nfx/opencompass/opencompass/init.py:19: UserWarning: Starting from v0.4.0, all AMOTIC configuration files currently located in ./configs/datasets, ./configs/models, and ./configs/summarizers will be migrated to the opencompass/configs/ package. Please update your configuration file paths accordingly.
_warn_about_config_migration()
2025-01-15 15:29:30.268607: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2025-01-15 15:29:30.414413: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/nvidia/lib:/usr/local/nvidia/lib64
2025-01-15 15:29:30.414460: I tensorflow/compiler/xla/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2025-01-15 15:29:31.060214: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/nvidia/lib:/usr/local/nvidia/lib64
2025-01-15 15:29:31.060303: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/nvidia/lib:/usr/local/nvidia/lib64
2025-01-15 15:29:31.060311: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
01/15 15:29:41 - OpenCompass - INFO - Current exp folder: outputs/default/20250115_152941
01/15 15:29:42 - OpenCompass - WARNING - SlurmRunner is not used, so the partition argument is ignored.
Traceback (most recent call last):
File "/workspace/mnt/cm-nfx/opencompass/run.py", line 4, in
main()
File "/workspace/mnt/cm-nfx/opencompass/opencompass/cli/main.py", line 299, in main
tasks = partitioner(cfg)
File "/workspace/mnt/cm-nfx/opencompass/opencompass/partitioners/base.py", line 83, in call
tasks = self.partition(**model_and_dataset_args,
File "/workspace/mnt/cm-nfx/opencompass/opencompass/partitioners/num_worker.py", line 69, in partition
dataset_size = self.get_size(dataset)
File "/workspace/mnt/cm-nfx/opencompass/opencompass/partitioners/num_worker.py", line 141, in get_size
dataset = build_dataset_from_cfg(dataset)
File "/workspace/mnt/cm-nfx/opencompass/opencompass/utils/build.py", line 13, in build_dataset_from_cfg
return LOAD_DATASET.build(dataset_cfg)
File "/opt/conda/envs/swift3/lib/python3.10/site-packages/mmengine/registry/registry.py", line 570, in build
return self.build_func(cfg, *args, **kwargs, registry=self)
File "/opt/conda/envs/swift3/lib/python3.10/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
obj = obj_cls(**args) # type: ignore
File "/workspace/mnt/cm-nfx/opencompass/opencompass/datasets/base.py", line 12, in init
self.dataset = self.load(**kwargs)
File "/workspace/mnt/cm-nfx/opencompass/opencompass/datasets/leval/leval_natural_question.py", line 17, in load
dataset = load_dataset(**kwargs)
File "/opt/conda/envs/swift3/lib/python3.10/site-packages/datasets/load.py", line 2074, in load_dataset
builder_instance = load_dataset_builder(
File "/opt/conda/envs/swift3/lib/python3.10/site-packages/datasets/load.py", line 1832, in load_dataset_builder
builder_instance: DatasetBuilder = builder_cls(
TypeError: 'NoneType' object is not callable

### 其他信息

https://github.com/open-compass/opencompass/discussions/1822。不知道如何解决

看起来是`dataset = load_dataset(**kwargs)`读取数据集的问题，可能是 datasets 版本问题，尝试下直接从 HF 官网下载该数据集会不会报错(https://huggingface.co/datasets/L4NLP/LEval)

<img width="901" alt="Image" src="https://github.com/user-attachments/assets/f55fb10a-0979-4223-9f58-6b9cbe24d1a8" />

@MaiziXiao 大海捞针测评，为什么出现这种情况？有部分数据有结果，部分没有

这个数据集，我遇到过类似的‘NoneType’问题，但我是环境内网络访问不了huggingface.co，下载不了数据集，我在有网的环境通过 datasets 库下载数据集到 ~/.cache/huggingface/ 下后，把整个目录转到 compass 的环境的 ~/.cache/huggingface 下后可以了。使用datasets下载时参照 opencompass/datasets/leval/xxx.py 中的 load() 函数

> 这个数据集，我遇到过类似的‘NoneType’问题，但我是环境内网络访问不了huggingface.co，下载不了数据集，我在有网的环境通过 datasets 库下载数据集到 ~/.cache/huggingface/ 下后，把整个目录转到 compass 的环境的 ~/.cache/huggingface 下后可以了。使用datasets下载时参照 opencompass/datasets/leval/xxx.py 中的 load() 函数

@Redias from datasets import load_dataset

ds = load_dataset("L4NLP/LEval", "codeU")

也是TypeError: 'NoneType' object is not callable，怎么回事

```
from datasets import load_dataset, disable_caching


disable_caching()
for name in [
        'natural_question',
        'narrative_qa',
        'multidoc_qa',
        'coursera',
        'tpo',
        'quality',
        'gsm100',
        'topic_retrieval_longchat',
        'gov_report_summ',
        'coursera',
        'legal_contract_qa',
        'meeting_summ',
        'news_summ',
        'paper_assistant',
        'patent_summ',
        'tv_show_summ',
        'scientific_qa',
        'review_summ',
        'financial_qa'
        ]:
    data = load_dataset('L4NLP/LEval', name, split='test', )
```

这是完整的数据集，想了下，这个NoneType的报错是因为访问不到huggingface.co，导致datasets这个库的load.py无法解析到正确的 dataset_name 变量，你在你的环境里 ping huggingface.co 试试

@Redias 为什么移到对应目录下还是这样的？

我的脚本：
export CUDA_VISIBLE_DEVICES=0,1,2,3

python run.py --datasets leval \
    --hf-type chat \
    --hf-path /workspace/mnt/cm-nfx/model/Qwen2.5-1.5B-Instruct \
    --max-out-len 2048 \
    --max-seq-len 32768 \
    --hf-num-gpus 4 \
    --generation-kwargs do_sample=False temperature=0.0000001 \
    --batch-size 1 \
    --debug

<img width="897" alt="Image" src="https://github.com/user-attachments/assets/248008ec-ce78-4818-95a8-a820c33925a8" />

<img width="902" alt="Image" src="https://github.com/user-attachments/assets/5aa6dd97-cf26-4f11-b940-14b7f3fca7a3" />

![Image](https://github.com/user-attachments/assets/498982b8-141b-491d-89cc-5de80126cf1e)

![Image](https://github.com/user-attachments/assets/c9d0a1a3-88fc-4777-a95d-6277295ae7fa)

2个建议：
1、对比下你下载数据集的文件路径结构和你运行时的数据集文件路径结构，确认下路径是对应的；
2、分别在两个环境的 datasets/load.py 中用print加几个断点，确定关键变量的值是否有所不同并处理掉。

@Redias 非常感谢，已经解决了，我忘记把module里的内容一起复制了导致没有找到数据集路径。