THUDM / CogVLM2

GPT4V-level open-source multi-modal model based on Llama3-8B
Apache License 2.0
2.12k stars 145 forks source link

cli_demo.py is broken tested on ubuntu pip freeze included - AttributeError: 'str' object has no attribute 'shape' #170

Closed FurkanGozukara closed 3 months ago

FurkanGozukara commented 3 months ago

The error is as below. I am using official cli_demo.py unmodified

(venv) Ubuntu@0059-kci-prxmx10006:~/Desktop/cog_vlm_v2/CogVLM2/basic_demo$ python3 cli_demo.py --quant 4
Loading checkpoint shards: 100%|██████████████████| 8/8 [00:11<00:00,  1.39s/it]
image path >>>>> /home/Ubuntu/Downloads/a.jpg
Human:describe image in details
Traceback (most recent call last):
  File "/home/Ubuntu/Desktop/cog_vlm_v2/CogVLM2/basic_demo/cli_demo.py", line 102, in <module>
    outputs = model.generate(**inputs, **gen_kwargs)
  File "/home/Ubuntu/Desktop/cog_vlm_v2/CogVLM2/venv/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
  File "/home/Ubuntu/Desktop/cog_vlm_v2/CogVLM2/venv/lib/python3.10/site-packages/transformers/generation/utils.py", line 1989, in generate
    result = self._sample(
  File "/home/Ubuntu/Desktop/cog_vlm_v2/CogVLM2/venv/lib/python3.10/site-packages/transformers/generation/utils.py", line 2932, in _sample
    outputs = self(**model_inputs, return_dict=True)
  File "/home/Ubuntu/Desktop/cog_vlm_v2/CogVLM2/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/Ubuntu/Desktop/cog_vlm_v2/CogVLM2/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/Ubuntu/Desktop/cog_vlm_v2/CogVLM2/venv/lib/python3.10/site-packages/accelerate/hooks.py", line 169, in new_forward
    output = module._old_forward(*args, **kwargs)
  File "/home/Ubuntu/.cache/huggingface/modules/transformers_modules/THUDM/cogvlm2-llama3-chat-19B/2bf7de6892877eb50142395af14847519ba95998/modeling_cogvlm.py", line 649, in forward
    outputs = self.model(
  File "/home/Ubuntu/Desktop/cog_vlm_v2/CogVLM2/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/Ubuntu/Desktop/cog_vlm_v2/CogVLM2/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/Ubuntu/Desktop/cog_vlm_v2/CogVLM2/venv/lib/python3.10/site-packages/accelerate/hooks.py", line 169, in new_forward
    output = module._old_forward(*args, **kwargs)
  File "/home/Ubuntu/.cache/huggingface/modules/transformers_modules/THUDM/cogvlm2-llama3-chat-19B/2bf7de6892877eb50142395af14847519ba95998/modeling_cogvlm.py", line 403, in forward
    return self.llm_forward(
  File "/home/Ubuntu/.cache/huggingface/modules/transformers_modules/THUDM/cogvlm2-llama3-chat-19B/2bf7de6892877eb50142395af14847519ba95998/modeling_cogvlm.py", line 452, in llm_forward
    past_key_values_length = past_key_values[0][0].shape[2]
AttributeError: 'str' object has no attribute 'shape'

The pip freeze is as below

venv) Ubuntu@0059-kci-prxmx10006:~/Desktop/cog_vlm_v2/CogVLM2/basic_demo$ pip freeze
accelerate==0.33.0
aiofiles==23.2.1
aiohttp==3.9.5
aiosignal==1.3.1
altair==5.3.0
annotated-types==0.7.0
anyio==3.7.1
anykeystore==0.2
apex==0.9.10.dev0
async-timeout==4.0.3
asyncer==0.0.2
attrs==23.2.0
bidict==0.23.1
bitsandbytes==0.43.2
blinker==1.8.2
blis==0.7.11
boto3==1.34.149
botocore==1.34.149
braceexpand==0.1.7
cachetools==5.4.0
catalogue==2.0.10
certifi==2024.7.4
chainlit==1.1.306
charset-normalizer==3.3.2
chevron==0.14.0
click==8.1.7
cloudpathlib==0.18.1
confection==0.1.5
contourpy==1.2.1
cpm-kernels==1.0.11
cryptacular==1.6.2
cycler==0.12.1
cymem==2.0.8
dataclasses-json==0.5.14
datasets==2.20.0
deepspeed==0.14.4
defusedxml==0.7.1
Deprecated==1.2.14
dill==0.3.8
distro==1.9.0
dnspython==2.6.1
einops==0.8.0
email_validator==2.2.0
exceptiongroup==1.2.2
fastapi==0.110.3
fastapi-cli==0.0.4
ffmpy==0.3.2
filelock==3.13.1
filetype==1.2.0
fonttools==4.53.1
frozenlist==1.4.1
fsspec==2024.2.0
gitdb==4.0.11
GitPython==3.1.43
googleapis-common-protos==1.63.2
gradio==4.39.0
gradio_client==1.1.1
greenlet==3.0.3
grpcio==1.65.1
h11==0.14.0
hjson==3.1.0
httpcore==1.0.5
httptools==0.6.1
httpx==0.27.0
huggingface-hub==0.24.2
hupper==1.12.1
idna==3.7
importlib_metadata==8.0.0
importlib_resources==6.4.0
Jinja2==3.1.3
jmespath==1.0.1
jsonlines==4.0.0
jsonschema==4.23.0
jsonschema-specifications==2023.12.1
kiwisolver==1.4.5
langcodes==3.4.0
language_data==1.2.0
Lazify==0.4.0
literalai==0.0.607
loguru==0.7.2
marisa-trie==1.2.0
markdown-it-py==3.0.0
MarkupSafe==2.1.5
marshmallow==3.21.3
matplotlib==3.9.1
mdurl==0.1.2
mpmath==1.3.0
multidict==6.0.5
multiprocess==0.70.16
murmurhash==1.0.10
mypy-extensions==1.0.0
nest-asyncio==1.6.0
networkx==3.2.1
ninja==1.11.1.1
numpy==1.26.3
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==9.1.0.70
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-ml-py==12.555.43
nvidia-nccl-cu12==2.20.5
nvidia-nvjitlink-cu12==12.1.105
nvidia-nvtx-cu12==12.1.105
oauthlib==3.2.2
openai==1.37.1
opentelemetry-api==1.26.0
opentelemetry-exporter-otlp==1.26.0
opentelemetry-exporter-otlp-proto-common==1.26.0
opentelemetry-exporter-otlp-proto-grpc==1.26.0
opentelemetry-exporter-otlp-proto-http==1.26.0
opentelemetry-instrumentation==0.47b0
opentelemetry-proto==1.26.0
opentelemetry-sdk==1.26.0
opentelemetry-semantic-conventions==0.47b0
orjson==3.10.6
packaging==23.2
pandas==2.2.2
PasteDeploy==3.1.0
pbkdf2==1.3
pillow==10.2.0
plaster==1.1.2
plaster-pastedeploy==1.0.1
preshed==3.0.9
protobuf==4.25.4
psutil==6.0.0
py-cpuinfo==9.0.0
pyarrow==17.0.0
pyarrow-hotfix==0.6
pydantic==2.8.2
pydantic_core==2.20.1
pydeck==0.9.1
pydub==0.25.1
Pygments==2.18.0
PyJWT==2.8.0
pyparsing==3.1.2
pyramid==2.0.2
pyramid-mailer==0.15.1
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
python-engineio==4.9.1
python-multipart==0.0.9
python-socketio==5.11.3
python3-openid==3.2.0
pytz==2024.1
PyYAML==6.0.1
referencing==0.35.1
regex==2024.7.24
repoze.sendmail==4.4.1
requests==2.32.3
requests-oauthlib==2.0.0
rich==13.7.1
rpds-py==0.19.1
ruff==0.5.5
s3transfer==0.10.2
safetensors==0.4.3
seaborn==0.13.2
semantic-version==2.10.0
sentencepiece==0.2.0
shellingham==1.5.4
simple-websocket==1.0.0
six==1.16.0
smart-open==7.0.4
smmap==5.0.1
sniffio==1.3.1
spacy==3.7.5
spacy-legacy==3.0.12
spacy-loggers==1.0.5
SQLAlchemy==2.0.31
srsly==2.4.8
sse-starlette==2.1.2
starlette==0.37.2
streamlit==1.37.0
SwissArmyTransformer==0.4.11
sympy==1.12
syncer==2.0.3
tenacity==8.5.0
tensorboardX==2.6.2.2
thinc==8.2.5
timm==1.0.7
tokenizers==0.19.1
toml==0.10.2
tomli==2.0.1
tomlkit==0.12.0
toolz==0.12.1
torch==2.4.0+cu121
torchaudio==2.4.0+cu121
torchvision==0.19.0+cu121
tornado==6.4.1
tqdm==4.66.4
transaction==4.0
transformers==4.43.2
translationstring==1.4
triton==3.0.0
typer==0.12.3
typing-inspect==0.9.0
typing_extensions==4.9.0
tzdata==2024.1
uptrace==1.26.0
urllib3==2.2.2
uvicorn==0.25.0
uvloop==0.19.0
velruse==1.1.1
venusian==3.1.0
wasabi==1.1.3
watchdog==4.0.1
watchfiles==0.20.0
weasel==0.4.1
webdataset==0.2.86
WebOb==1.8.7
websockets==11.0.3
wrapt==1.16.0
wsproto==1.2.0
WTForms==3.1.2
wtforms-recaptcha==0.3.2
xformers==0.0.27.post1
xxhash==3.4.1
yarl==1.9.4
zipp==3.19.2
zope.deprecation==5.0
zope.interface==6.4.post2
zope.sqlalchemy==3.1
(venv) Ubuntu@0059-kci-prxmx10006:~/Desktop/cog_vlm_v2/CogVLM2/basic_demo$ 
FurkanGozukara commented 3 months ago

I am also trying to make my gradio app working getting same error. If you have gradio demo I would appreciate very much

I hope you can help @zRzRzRzRzRzRzR @Sleepychord @huangshiyu13

FurkanGozukara commented 3 months ago

ok it was transformers version works perfect on massed compute

uses 40.2 GB VRAM with 16-bit precision

now only thing left is Windows

screencapture-b8e2b8c106c1611a44-gradio-live-2024-07-26-04_00_25