Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'Option' from 'typer' #3081

Closed
1 task done
ConniePK opened this issue Apr 1, 2024 · 2 comments
Closed
1 task done

ImportError: cannot import name 'Option' from 'typer' #3081

ConniePK opened this issue Apr 1, 2024 · 2 comments
Labels
solved This problem has been already solved

Comments

@ConniePK
Copy link

ConniePK commented Apr 1, 2024

Reminder

  • I have read the README and searched the existing issues.

Reproduction

最新的代码,运行如下命令:
CUDA_VISIBLE_DEVICES=3,4 accelerate launch --config_file fsdp_config.yaml src/cli_demo.py
--model_name_or_path '/root/.cache/modelscope/hub/qwen/Qwen-72B-Chat/'
--template qwen

出现如下报错:

Traceback (most recent call last):
  File "src/cli_demo.py", line 1, in <module>
    from llmtuner import ChatModel
  File "/home/work/bin/ChatGLM-For-Rerank/llama-factory/src/llmtuner/__init__.py", line 7, in <module>
    from .webui import create_ui, create_web_demo
  File "/home/work/bin/ChatGLM-For-Rerank/llama-factory/src/llmtuner/webui/__init__.py", line 1, in <module>
    from .interface import create_ui, create_web_demo
  File "/home/work/bin/ChatGLM-For-Rerank/llama-factory/src/llmtuner/webui/interface.py", line 1, in <module>
    import gradio as gr
  File "/usr/local/lib/python3.8/dist-packages/gradio/__init__.py", line 10, in <module>
    from gradio.cli import deploy
  File "/usr/local/lib/python3.8/dist-packages/gradio/cli/__init__.py", line 1, in <module>
    from .cli import cli, deploy
  File "/usr/local/lib/python3.8/dist-packages/gradio/cli/cli.py", line 4, in <module>
    from gradio_client.cli import deploy_discord  # type: ignore
  File "/usr/local/lib/python3.8/dist-packages/gradio_client/cli/__init__.py", line 1, in <module>
    from gradio_client.cli import deploy_discord
  File "/usr/local/lib/python3.8/dist-packages/gradio_client/cli/deploy_discord.py", line 3, in <module>
    from typer import Option
ImportError: cannot import name 'Option' from 'typer' (unknown location)

看起来是gradio相关的问题?

yaml配置为:
compute_environment: LOCAL_MACHINE
debug: false
distributed_type: FSDP
downcast_bf16: 'no'
fsdp_config:
fsdp_auto_wrap_policy: TRANSFORMER_BASED_WRAP
fsdp_backward_prefetch: BACKWARD_PRE
fsdp_cpu_ram_efficient_loading: true
fsdp_forward_prefetch: false
fsdp_offload_params: true
fsdp_sharding_strategy: FULL_SHARD
fsdp_state_dict_type: FULL_STATE_DICT
fsdp_sync_module_states: true
fsdp_use_orig_params: false
machine_rank: 0
main_training_function: main
mixed_precision: fp16
num_machines: 1
num_processes: 2
rdzv_backend: static
same_network: true
tpu_env: []
tpu_use_cluster: false
tpu_use_sudo: false
use_cpu: false
main_process_port: 29501
main_process_ip: 48009

Expected behavior

最新代码在使用fsdp中遇到的问题

System Info

gradio 4.21.0
gradio_client 0.12.0
absl-py 1.4.0
accelerate 0.28.0
addict 2.4.0
aiofiles 23.2.1
aiohttp 3.9.1
aiosignal 1.3.1
aliyun-python-sdk-core 2.14.0
aliyun-python-sdk-kms 2.16.2
altair 5.2.0
annotated-types 0.6.0
anyio 3.7.1
apex 0.1
appdirs 1.4.4
argcomplete 1.12.3
argilla 0.0.1
argon2-cffi 21.3.0
argon2-cffi-bindings 21.2.0
asttokens 2.2.1
astunparse 1.6.3
async-timeout 4.0.3
attrs 23.1.0
audioread 3.0.0
auto-gptq 0.6.0
backcall 0.2.0
backports.zoneinfo 0.2.1
beautifulsoup4 4.11.2
bitsandbytes 0.43.0
bleach 6.0.0
blinker 1.6.2
blis 0.7.9
Brotli 1.0.9
cachetools 5.2.0
catalogue 2.0.8
certifi 2023.11.17
cffi 1.16.0
charset-normalizer 3.3.2
click 8.1.7
cloudpickle 2.2.0
cmake 3.24.1.1
colorama 0.4.6
coloredlogs 15.0.1
comm 0.1.2
confection 0.0.4
contourpy 1.1.1
cpm-kernels 1.0.11
crcmod 1.7
cryptography 41.0.7
cubinlinker 0.2.2+2.g8e13447
cuda-python 12.1.0rc1+1.g9e30ea2.dirty
cudf 22.12.0
cugraph 22.12.0
cugraph-dgl 22.12.0
cugraph-service-client 22.12.0
cugraph-service-server 22.12.0
cuml 22.12.0
cupy-cuda12x 12.1.0
cycler 0.12.1
cymem 2.0.7
Cython 0.29.33
dask 2022.11.1
dask-cuda 22.12.0
dask-cudf 22.12.0
dataclasses-json 0.5.7
datasets 2.16.0
debugpy 1.6.6
decorator 5.1.1
defusedxml 0.7.1
dill 0.3.7
diskcache 5.6.3
distributed 2022.11.1
docker-pycreds 0.4.0
docstring-parser 0.15
duckduckgo-search 3.8.3
einops 0.7.0
et-xmlfile 1.1.0
exceptiongroup 1.2.0
execnet 1.9.0
executing 1.2.0
expecttest 0.1.3
faiss-cpu 1.7.4
fastapi 0.105.0
fastjsonschema 2.16.2
fastllm-pytools 0.0.1
fastrlock 0.8.1
ffmpy 0.3.1
filelock 3.13.1
fire 0.5.0
FlagEmbedding 1.1.0
fonttools 4.47.0
frozenlist 1.4.1
fschat 0.2.3
fsspec 2023.10.0
galaxy-fds-sdk 1.4.39
gast 0.5.4
gekko 1.0.6
gitdb 4.0.10
GitPython 3.1.31
google-auth 2.16.0
google-auth-oauthlib 0.4.6
gradio 4.21.0
gradio_client 0.12.0
graphsurgeon 0.4.6
greenlet 2.0.2
grpcio 1.51.1
h11 0.14.0
h2 4.1.0
HeapDict 1.0.1
hpack 4.0.0
httpcore 1.0.2
httptools 0.6.1
httpx 0.26.0
huggingface-hub 0.20.1
humanfriendly 10.0
hyperframe 6.0.1
hypothesis 5.35.1
idna 3.6
importlib-metadata 7.0.1
importlib-resources 6.1.1
iniconfig 2.0.0
intel-openmp 2021.4.0
interegular 0.3.3
ipykernel 6.21.1
ipython 8.9.0
ipython-genutils 0.2.0
jedi 0.18.2
jieba 0.42.1
Jinja2 3.1.2
jmespath 0.10.0
joblib 1.3.2
json5 0.9.11
jsonschema 4.20.0
jsonschema-specifications 2023.11.2
jupyter_client 8.0.2
jupyter_core 5.2.0
jupyter-tensorboard 0.2.0
jupyterlab 2.3.2
jupyterlab-pygments 0.2.2
jupyterlab-server 1.2.0
jupytext 1.14.4
kiwisolver 1.4.5
langchain 0.0.176
langcodes 3.3.0
lark 1.1.9
librosa 0.9.2
linkify-it-py 1.0.3
llvmlite 0.39.1
locket 1.0.0
lxml 4.9.2
Markdown 3.4.1
markdown-it-py 3.0.0
markdown2 2.4.8
MarkupSafe 2.1.3
marshmallow 3.19.0
marshmallow-enum 1.5.1
matplotlib 3.7.4
matplotlib-inline 0.1.6
mdit-py-plugins 0.3.3
mdurl 0.1.2
mistune 2.0.5
mkl 2021.1.1
mkl-devel 2021.1.1
mkl-include 2021.1.1
mock 5.0.1
modelscope 1.10.0
mpmath 1.3.0
msg-parser 1.2.0
msgpack 1.0.4
multidict 6.0.4
multiprocess 0.70.15
murmurhash 1.0.9
mypy-extensions 1.0.0
nbclient 0.7.2
nbconvert 7.2.9
nbformat 5.7.3
nest-asyncio 1.5.6
networkx 3.1
ninja 1.11.1.1
nltk 3.8.1
notebook 6.4.10
numba 0.56.4+1.g772622d0d
numexpr 2.8.4
numpy 1.23.5
nvidia-cublas-cu12 12.1.3.1
nvidia-cuda-cupti-cu12 12.1.105
nvidia-cuda-nvrtc-cu12 12.1.105
nvidia-cuda-runtime-cu12 12.1.105
nvidia-cudnn-cu12 8.9.2.26
nvidia-cufft-cu12 11.0.2.54
nvidia-curand-cu12 10.3.2.106
nvidia-cusolver-cu12 11.4.5.107
nvidia-cusparse-cu12 12.1.0.106
nvidia-dali-cuda110 1.22.0
nvidia-nccl-cu12 2.18.1
nvidia-nvjitlink-cu12 12.3.101
nvidia-nvtx-cu12 12.1.105
nvidia-pyindex 1.0.9
nvtx 0.2.5
oauthlib 3.2.2
olefile 0.46
onnx 1.13.0
openapi-schema-pydantic 1.2.4
opencv 4.6.0
openpyxl 3.1.2
optimum 1.16.2
orjson 3.9.10
oss2 2.18.4
outlines 0.0.37
packaging 23.2
pandas 2.0.3
pandocfilters 1.5.0
parso 0.8.3
partd 1.3.0
pathtools 0.1.2
pathy 0.10.1
pdfminer.six 20221105
peft 0.10.0
pexpect 4.8.0
pickleshare 0.7.5
Pillow 10.1.0
pip 24.0
pkgutil_resolve_name 1.3.10
platformdirs 4.1.0
pluggy 1.0.0
ply 3.11
polygraphy 0.43.1
pooch 1.6.0
preshed 3.0.8
prettytable 3.6.0
prometheus_client 0.20.0
prompt-toolkit 3.0.36
protobuf 3.20.0
psutil 5.9.7
ptxcompiler 0.7.0+27.gd73915e
ptyprocess 0.7.0
pure-eval 0.2.2
pyarrow 14.0.2
pyarrow-hotfix 0.6
pyasn1 0.4.8
pyasn1-modules 0.2.8
pybind11 2.10.3
pycocotools 2.0+nv0.7.1
pycparser 2.21
pycryptodome 3.19.1
pydantic 2.5.3
pydantic_core 2.14.6
pydeck 0.8.0
pydub 0.25.1
Pygments 2.17.2
pylibcugraph 22.12.0
pylibcugraphops 22.12.0
pylibraft 22.12.0
Pympler 1.0.1
pynvml 11.5.0
pypandoc 1.11
pyparsing 3.1.1
pypdf 3.9.1
pyrsistent 0.19.3
pysqlite3 0.5.0
pytest 7.2.1
pytest-rerunfailures 11.0
pytest-shard 0.1.2
pytest-xdist 3.2.0
python-dateutil 2.8.2
python-docx 0.8.11
python-dotenv 1.0.1
python-hostlist 1.23.0
python-magic 0.4.27
python-multipart 0.0.9
python-pptx 0.6.21
pytorch-quantization 2.1.2
pytz 2023.3.post1
pytz-deprecation-shim 0.1.0.post0
PyYAML 6.0.1
pyzmq 25.0.0
raft-dask 22.12.0
ray 2.10.0
referencing 0.32.0
regex 2023.12.25
requests 2.31.0
requests-oauthlib 1.3.1
resampy 0.4.2
rich 13.7.0
rmm 22.12.0
rouge 1.0.1
rouge-chinese 1.0.3
rpds-py 0.15.2
rsa 4.9
ruff 0.3.4
safetensors 0.4.1
scikit-learn 0.24.2
scipy 1.10.1
seaborn 0.12.1
semantic-version 2.10.0
Send2Trash 1.8.0
sentence-transformers 2.2.2
sentencepiece 0.1.99
sentry-sdk 1.25.1
setproctitle 1.3.2
setuptools 69.0.3
shellingham 1.5.4
shortuuid 1.0.11
shtab 1.6.5
simplejson 3.19.2
six 1.16.0
smart-open 6.3.0
smmap 5.0.0
sniffio 1.3.0
socksio 1.0.0
sortedcontainers 2.4.0
soundfile 0.11.0
soupsieve 2.3.2.post1
spacy 3.5.0
spacy-legacy 3.0.12
spacy-loggers 1.0.4
sphinx-glpi-theme 0.3
SQLAlchemy 2.0.16
srsly 2.4.5
sse-starlette 1.8.2
stack-data 0.6.2
starlette 0.27.0
streamlit 1.26.0
strings-udf 22.12.0
svgwrite 1.4.3
sympy 1.12
tbb 2021.8.0
tblib 1.7.0
tenacity 8.2.2
tensorboard 2.9.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.1
tensorrt 8.5.3.1
termcolor 2.4.0
terminado 0.17.1
thinc 8.1.7
threadpoolctl 3.1.0
thriftpy2 0.4.16
tiktoken 0.5.2
tinycss2 1.2.1
tokenizers 0.15.0
toml 0.10.2
tomli 2.0.1
tomlkit 0.12.0
toolz 0.12.0
torch 2.1.2
torch-tensorrt 1.4.0.dev0
torchtext 0.13.0a0+fae8e8c
torchvision 0.15.0a0
tornado 6.1
tqdm 4.66.1
traitlets 5.9.0
transformer-engine 0.5.0
transformers 4.39.1
transformers-stream-generator 0.0.5
treelite 3.0.1
treelite-runtime 3.0.1
triton 2.1.0
trl 0.8.1
typer 0.12.0
typer-cli 0.12.0
typer-slim 0.12.0
typing_extensions 4.9.0
typing-inspect 0.9.0
tyro 0.6.1
tzdata 2023.3
tzlocal 4.3.1
uc-micro-py 1.0.2
ucx-py 22.12.0
uff 0.6.9
unstructured 0.6.5
urllib3 2.1.0
uvicorn 0.25.0
uvloop 0.19.0
validators 0.22.0
vllm 0.3.3
wasabi 1.1.1
watchdog 3.0.0
watchfiles 0.21.0
wavedrom 2.0.3.post3
wcwidth 0.2.6
webencodings 0.5.1
websockets 11.0.3
Werkzeug 2.2.2
wheel 0.42.0
xdoctest 1.0.2
xformers 0.0.23.post1
xgboost 1.7.1
XlsxWriter 3.1.2
xxhash 3.4.1
yapf 0.40.2
yarl 1.9.4
zhon 1.1.5
zict 2.2.0
zipp 3.17.0

Others

d

@hiyouga
Copy link
Owner

hiyouga commented Apr 1, 2024

pip install typer[all]==0.9.0

@hiyouga hiyouga added the pending This problem is yet to be addressed label Apr 1, 2024
@lone17
Copy link

lone17 commented Apr 1, 2024

This happens when you upgrade from an older version of typer to 0.12.0.

Just use an older version, e.g. pip install typer==0.11.1.
If you want to use the latest version (i.e. 0.12.0), you must first completely uninstall typer and then reinstall it.

@hiyouga hiyouga added solved This problem has been already solved and removed pending This problem is yet to be addressed labels Apr 2, 2024
@hiyouga hiyouga closed this as completed Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solved This problem has been already solved
Projects
None yet
Development

No branches or pull requests

3 participants