DeepSpeed-MII 稳定扩散失败,寻找SAFE_WEIGHTS_NAME,

tvokkenx  于 3个月前  发布在  其他
关注(0)|答案(1)|浏览(49)

遇到了一些问题,尝试运行 https://github.com/microsoft/DeepSpeed-MII/tree/main/examples/benchmark/txt2img

  1. 需要设置 PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
  2. ImportError: 无法从 'transformers.utils' 导入名称 'SAFE_WEIGHTS_NAME' (/usr/local/lib/python3.8/dist-packages/transformers/utils/init.py)
    我看不到解决 SAFE_WEIGHTS_NAME 的简单方法。
    要重现并运行 docker run -it --rm --gpus=all --ipc=host -p 127.0.0.1:8888:8888 -v root-cache:/root/.cache --ulimit=memlock=-1 --ulimit=stack=67108864 nvcr.io/nvidia/pytorch:23.02-py3 jupyter lab --allow-root --ip=* --port=8888 --no-browser --NotebookApp.token='' --NotebookApp.allow_origin='*'
    然后运行 pip install pytorch-lightning diffusers transformers scipy safetensors accelerate deepspeed[sd] deepspeed-mii
    这里是错误信息
root@58da005d6d1f:/workspace# PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python python ./cool.py 
Traceback (most recent call last):
  File "./cool.py", line 7, in <module>
    import diffusers
  File "/usr/local/lib/python3.8/dist-packages/diffusers/__init__.py", line 55, in <module>
    from .pipelines import (
  File "/usr/local/lib/python3.8/dist-packages/diffusers/pipelines/__init__.py", line 18, in <module>
    from .dance_diffusion import DanceDiffusionPipeline
  File "/usr/local/lib/python3.8/dist-packages/diffusers/pipelines/dance_diffusion/__init__.py", line 1, in <module>
    from .pipeline_dance_diffusion import DanceDiffusionPipeline
  File "/usr/local/lib/python3.8/dist-packages/diffusers/pipelines/dance_diffusion/pipeline_dance_diffusion.py", line 21, in <module>
    from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline
  File "/usr/local/lib/python3.8/dist-packages/diffusers/pipelines/pipeline_utils.py", line 64, in <module>
    from transformers.utils import SAFE_WEIGHTS_NAME as TRANSFORMERS_SAFE_WEIGHTS_NAME
ImportError: cannot import name 'SAFE_WEIGHTS_NAME' from 'transformers.utils' (/usr/local/lib/python3.8/dist-packages/transformers/utils/__init__.py)

显示版本号

Name: pytorch-lightning
Version: 1.9.4
Summary: PyTorch Lightning is the lightweight PyTorch wrapper for ML researchers. Scale your models. Write less boilerplate.
Home-page: https://github.com/Lightning-AI/lightning
Author: Lightning AI et al.
Author-email: pytorch@lightning.ai
License: Apache-2.0
Location: /usr/local/lib/python3.8/dist-packages
Requires: lightning-utilities, tqdm, torch, PyYAML, typing-extensions, packaging, torchmetrics, fsspec, numpy
Required-by: 
---
Name: diffusers
Version: 0.14.0
Summary: Diffusers
Home-page: https://github.com/huggingface/diffusers
Author: The HuggingFace team
Author-email: patrick@huggingface.co
License: Apache
Location: /usr/local/lib/python3.8/dist-packages
Requires: importlib-metadata, numpy, filelock, huggingface-hub, regex, Pillow, requests
Required-by: 
---
Name: transformers
Version: 4.21.2
Summary: State-of-the-art Machine Learning for JAX, PyTorch and TensorFlow
Home-page: https://github.com/huggingface/transformers
Author: The Hugging Face team (past and future) with the help of all our contributors (https://github.com/huggingface/transformers/graphs/contributors)
Author-email: transformers@huggingface.co
License: Apache
Location: /usr/local/lib/python3.8/dist-packages
Requires: tqdm, pyyaml, filelock, tokenizers, huggingface-hub, numpy, packaging, regex, requests
Required-by: deepspeed-mii
---
Name: scipy
Version: 1.6.3
Summary: SciPy: Scientific Library for Python
Home-page: https://www.scipy.org/
Author: 
Author-email: 
License: BSD
Location: /usr/local/lib/python3.8/dist-packages
Requires: numpy
Required-by: xgboost, treelite, treelite-runtime, scikit-learn, pytorch-quantization, librosa, cuml
---
Name: safetensors
Version: 0.3.0
Summary: Fast and Safe Tensor serialization
Home-page: https://github.com/huggingface/safetensors
Author: 
Author-email: 
License: Apache License 2.0
Location: /usr/local/lib/python3.8/dist-packages
Requires: 
Required-by: 
---
Name: accelerate
Version: 0.17.1
Summary: Accelerate
Home-page: https://github.com/huggingface/accelerate
Author: The HuggingFace team
Author-email: sylvain@huggingface.co
License: Apache
Location: /usr/local/lib/python3.8/dist-packages
Requires: psutil, torch, numpy, packaging, pyyaml
Required-by: 
---
Name: deepspeed
Version: 0.7.3
Summary: DeepSpeed library
Home-page: http://deepspeed.ai/
Author: DeepSpeed Team
Author-email: deepspeed@microsoft.com
License: MIT
Location: /usr/local/lib/python3.8/dist-packages
Requires: py-cpuinfo, ninja, psutil, packaging, numpy, tqdm, pydantic, hjson, torch
Required-by: deepspeed-mii
---
Name: deepspeed-mii
Version: 0.0.2
Summary: deepspeed mii
Home-page: http://deepspeed.ai/
Author: DeepSpeed Team
Author-email: deepspeed-mii@microsoft.com
License: 
Location: /usr/local/lib/python3.8/dist-packages
Requires: transformers, grpcio-tools, grpcio, asyncio, pydantic, torch, deepspeed
Required-by: 
Note: you may need to restart the kernel to use updated packages.
yvfmudvl

yvfmudvl1#

@lizelive,这个错误意味着你需要升级你的transformers包。相关页面有关于包版本的描述:

deepspeed==0.7.5
deepspeed-mii==0.0.3
diffusers==0.7.1
transformers==4.24.0
triton==2.0.0.dev20221005  (This does not exist, and you can use 2.0.0.dev20221031 instead)
Ubuntu 20.04.4 LTS
Python 3.9.15

你可以像这样逐个安装:pip install deepspeed==0.7.5
我可以使用上述包运行基准脚本mii-sd.py并获得类似的延迟(使用torch 1.13.1和CUDA 11.7,尽管页面推荐使用torch 1.12.1 + cuda 11.6)。

相关问题