HugAILab/HugNLP

安装后无法正常运行啊

Closed this issue · 6 comments

按要求安装后

$ git clone https://github.com/HugAILab/HugNLP.git
$ cd HugNLP
$ python3 setup.py install

提示有一个不兼容:

Installed ~/anaconda3/envs/hugnlp/lib/python3.9/site-packages/rjieba-0.1.11-py3.9-linux-x86_64.egg
error: torch 1.12.1 is installed but torch>=1.13.0 is required by {'peft'}

运行

from applications.information_extraction.HugIE.api_test import HugIEAPI
model_type = "bert"
hugie_model_name_or_path = "wjn1996/wjn1996-hugnlp-hugie-large-zh"
hugie = HugIEAPI("bert", hugie_model_name_or_path)
text = "央广网北京2月23日消息 据**地震台网正式测定,2月23日8时37分在塔吉克斯坦发生7.2级地震,震源深度10公里,震中位于北纬37.98度,东经73.29度,距我国边境线最近约82公里,地震造成**喀什等地震感强烈。"

entity = "塔吉克斯坦地震"
relation = "震源位置"
predictions, topk_predictions = hugie.request(text, entity, relation=relation)
print("entity:{}, relation:{}".format(entity, relation))
print("predictions:\n{}".format(predictions))
print("topk_predictions:\n{}".format(predictions))
print("\n\n")

先是提示:

ModuleNotFoundError: No module named 'urllib3'

安装后urllib3后又提示:

❯ pip install urllib3
Collecting urllib3
  Using cached urllib3-2.0.2-py3-none-any.whl (123 kB)
Installing collected packages: urllib3
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
requests 2.31.0 requires certifi>=2017.4.17, which is not installed.
requests 2.31.0 requires charset-normalizer<4,>=2, which is not installed.
requests 2.31.0 requires idna<4,>=2.5, which is not installed.
huggingface-hub 0.14.1 requires fsspec, which is not installed.
torchvision 0.15.2 requires pillow!=8.3.*,>=5.3.0, which is not installed.
torchvision 0.15.2 requires torch==2.0.1, but you have torch 1.12.1 which is incompatible.

把这些安装完后,又提示有更多的包没安装...

您好,可能requirements.txt漏加上这个urllib3包了,欢迎提出PR~
另外如果版本冲突可以忽略,默认torch版本时1.12,但是可能会与urllib3、peft等存在版本冲突,可以先忽略,如果有程序运行报错请继续贴出来~

蛮干了一个多小时, test->安装缺失的包->test again ->再次安装缺失的包... (为啥会缺这么多包都没包含在requirement.txt里❓)

# ModuleNotFoundError: No module named 'urllib3'
conda install urllib3
# ModuleNotFoundError: No module named 'chardet'
conda install chardet
#ModuleNotFoundError: No module named 'charset_normalizer'
conda install charset-normalizer
# ModuleNotFoundError: No module named 'cpuinfo'
conda install py-cpuinfo
# ModuleNotFoundError: No module named 'hjson'
#😍conda 安装不上❓,改用pip装
pip install hjson
---
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
deepspeed 0.8.3 requires ninja, which is not installed.
deepspeed 0.8.3 requires pydantic, which is not installed.
---

conda install ninja pydantic
# ModuleNotFoundError: No module named 'google'
conda install google-api-python-client

# ModuleNotFoundError: No module named 'sqlparse'
conda install sqlparse

# ModuleNotFoundError: No module named 'databricks_cli'
conda install databricks-cli
# ModuleNotFoundError: No module named 'pytz'
conda install pytz
# ModuleNotFoundError: No module named 'entrypoints'
conda install entrypoints
# ModuleNotFoundError: No module named 'importlib_metadata'
conda install importlib-metadata

这次运行是代码报错

File ~/project/testscratch/python/hello-world/hugging-face/HugNLP-main/models/__init__.py:8
      1 # -*- coding: utf-8 -*-
      2 # @Time    : 2021/12/6 3:35 下午
      3 # @Author  : JianingWang
   (...)
      6 
      7 # from models.chid_mlm import BertForChidMLM
----> 8 from models.multiple_choice.duma import BertDUMAForMultipleChoice, AlbertDUMAForMultipleChoice, MegatronDumaForMultipleChoice
      9 from models.span_extraction.global_pointer import BertForEffiGlobalPointer, RobertaForEffiGlobalPointer, RoformerForEffiGlobalPointer, MegatronForEffiGlobalPointer
     10 from transformers import AutoModelForTokenClassification, AutoModelForSequenceClassification, AutoModelForMaskedLM, AutoModelForMultipleChoice, BertTokenizer, \
     11     AutoModelForQuestionAnswering, AutoModelForCausalLM
...
    260         # store model id instead of run_id and path to avoid confusion when model gets exported
    261         if run_id:
    262             self.run_id = run_id

AttributeError: partially initialized module 'mlflow' has no attribute 'version' (most likely due to a circular import)

现在就卡在这了🤡

@wjn1996 能提供一个可以基本正常安装运行的版本不?

我是用docker开发的,你是用docker的还是conda虚拟环境?按理说不会出现这种情况。你尝试用docker安装一下试试。

您好,想请教下,安装执行之后想要运行下hugchat.py,但是会报错以下提示,请问这个怎么解决呀,或者您方便给一个docker版本的安装命令吗,谢谢~!

(base) root@:~/HugNLP# python3 applications/instruction_prompting/HugChat/hugchat.py
Traceback (most recent call last):
  File "/root/HugNLP/applications/instruction_prompting/HugChat/hugchat.py", line 15, in <module>
    from models import PRETRAIN_MODEL_CLASSES
  File "<frozen zipimport>", line 259, in load_module
  File "/root/miniconda3/lib/python3.9/site-packages/hugnlp-0.0.1-py3.9.egg/models/__init__.py", line 8, in <module>
ModuleNotFoundError: No module named 'models.multiple_choice'

error: torch 1.12.1 is installed but torch>=1.13.0 is required by {'peft'}
所以这条报错不需要管吗,没有影响?

最后,再安装了这些包

pip install fsspec dill multiprocess responses==0.18 xxhash

终于能运行了