Comments (6)
我根据报错信息中的这句话 from transformers import CLIPTextModel, CLIPFeatureExtractor
,做了一些尝试
- 执行
import diffusers
,也报同样的错误 - 执行
from transformers import CLIPTextModel, CLIPFeatureExtractor
没有报错误 - 执行
from transformers import CLIPTextModel, CLIPFeatureExtractor
后,再次执行import diffusers
不再报错误,于是我继续尝试from diffusers import OneFlowStableDiffusionPipeline
也不再报错。 - 当我关闭这个 ipython,开启新的后,
import diffusers
继续报错
在导入diffusers之前先导入transformers可以解决报错的问题,但不知道原因
下面附上测试过程:
In [1]: import diffusers
RuntimeError: Failed to import transformers.models.clip.modeling_clip because of the following error (look up to see its traceback):
oneflow.cuda.amp.GradScaler is not implemented, please submit an issue at
'https://github.com/Oneflow-Inc/oneflow/issues' including the log information of the error, the
minimum reproduction code, and the system information.
In [1]: import oneflow
In [2]: with oneflow.mock_torch.enable():
...: from transformers import CLIPTextModel, CLIPFeatureExtractor
RuntimeError: Failed to import transformers.models.clip.modeling_clip because of the following error (look up to see its traceback):
oneflow.cuda.amp.GradScaler is not implemented, please submit an issue at
'https://github.com/Oneflow-Inc/oneflow/issues' including the log information of the error, the
minimum reproduction code, and the system information.
In [1]: from transformers import CLIPTextModel, CLIPFeatureExtractor
In [2]: import oneflow
In [3]: with oneflow.mock_torch.enable():
...: from transformers import CLIPTextModel, CLIPFeatureExtractor
...:
In [1]: from transformers import CLIPTextModel, CLIPFeatureExtractor
In [2]: import diffusers
In [3]: from diffusers import OneFlowStableDiffusionPipeline
from onediff.
python3 -m pip uninstall accelerate
from onediff.
solved : )
from onediff.
可以先安装下 accelerate,复现问题;
然后改下:
diffusers/src/diffusers/utils/import_utils.py
def is_accelerate_available():
return _accelerate_available
注释下这里,让该函数返回 false,看是否能解决问题。如果可以的话,把改动可以提交到 oneflow 的 diffusers 仓库。
from onediff.
更改后,重新执行 python3 -m pip install -e .[oneflow]
,导入diffuser依旧报错
In [1]: import diffusers
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
File ~/miniconda3/lib/python3.10/site-packages/transformers/utils/import_utils.py:1110, in _LazyModule._get_module(self, module_name)
1109 try:
-> 1110 return importlib.import_module("." + module_name, self.__name__)
1111 except Exception as e:
File ~/miniconda3/lib/python3.10/importlib/__init__.py:126, in import_module(name, package)
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
File <frozen importlib._bootstrap>:1050, in _gcd_import(name, package, level)
File <frozen importlib._bootstrap>:1027, in _find_and_load(name, import_)
File <frozen importlib._bootstrap>:1006, in _find_and_load_unlocked(name, import_)
File <frozen importlib._bootstrap>:688, in _load_unlocked(spec)
File <frozen importlib._bootstrap_external>:883, in exec_module(self, module)
File <frozen importlib._bootstrap>:241, in _call_with_frames_removed(f, *args, **kwds)
File ~/miniconda3/lib/python3.10/site-packages/transformers/models/clip/modeling_clip.py:27
26 from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling
---> 27 from ...modeling_utils import PreTrainedModel
28 from ...utils import (
29 ModelOutput,
30 add_start_docstrings,
(...)
33 replace_return_docstrings,
34 )
File ~/miniconda3/lib/python3.10/site-packages/transformers/modeling_utils.py:83
82 if is_accelerate_available():
---> 83 from accelerate import __version__ as accelerate_version
84 from accelerate import dispatch_model, infer_auto_device_map, init_empty_weights
File ~/miniconda3/lib/python3.10/site-packages/accelerate/__init__.py:7
5 __version__ = "0.16.0"
----> 7 from .accelerator import Accelerator
8 from .big_modeling import (
9 cpu_offload,
10 disk_offload,
(...)
14 load_checkpoint_and_dispatch,
15 )
File ~/miniconda3/lib/python3.10/site-packages/accelerate/accelerator.py:29
27 import torch.utils.hooks as hooks
---> 29 from .checkpointing import load_accelerator_state, load_custom_state, save_accelerator_state, save_custom_state
30 from .data_loader import DataLoaderDispatcher, prepare_data_loader, skip_first_batches
File ~/miniconda3/lib/python3.10/site-packages/accelerate/checkpointing.py:22
21 import torch
---> 22 from torch.cuda.amp import GradScaler
24 from .utils import (
25 MODEL_NAME,
26 OPTIMIZER_NAME,
(...)
32 save,
33 )
File ~/oneflow/python/oneflow/mock_torch/__init__.py:44, in ModuleWrapper.__getattr__(self, name)
43 return [attr for attr in dir(self.module) if not attr.startswith("_")]
---> 44 raise ModuleNotFoundError(self.module.__name__ + "." + name + error_msg)
45 attr = getattr(self.module, name)
ModuleNotFoundError: oneflow.cuda.amp.GradScaler is not implemented, please submit an issue at
'https://github.com/Oneflow-Inc/oneflow/issues' including the log information of the error, the
minimum reproduction code, and the system information.
The above exception was the direct cause of the following exception:
RuntimeError Traceback (most recent call last)
Cell In[1], line 1
----> 1 import diffusers
File ~/diffusers/src/diffusers/__init__.py:22
20 import oneflow
21 with oneflow.mock_torch.enable():
---> 22 from transformers import CLIPTextModel, CLIPFeatureExtractor
23 from .modeling_utils import ModelMixin
24 from .models import AutoencoderKL, Transformer2DModel, UNet1DModel, UNet2DConditionModel, UNet2DModel, VQModel
File <frozen importlib._bootstrap>:1075, in _handle_fromlist(module, fromlist, import_, recursive)
File ~/miniconda3/lib/python3.10/site-packages/transformers/utils/import_utils.py:1101, in _LazyModule.__getattr__(self, name)
1099 elif name in self._class_to_module.keys():
1100 module = self._get_module(self._class_to_module[name])
-> 1101 value = getattr(module, name)
1102 else:
1103 raise AttributeError(f"module {self.__name__} has no attribute {name}")
File ~/miniconda3/lib/python3.10/site-packages/transformers/utils/import_utils.py:1100, in _LazyModule.__getattr__(self, name)
1098 value = self._get_module(name)
1099 elif name in self._class_to_module.keys():
-> 1100 module = self._get_module(self._class_to_module[name])
1101 value = getattr(module, name)
1102 else:
File ~/miniconda3/lib/python3.10/site-packages/transformers/utils/import_utils.py:1112, in _LazyModule._get_module(self, module_name)
1110 return importlib.import_module("." + module_name, self.__name__)
1111 except Exception as e:
-> 1112 raise RuntimeError(
1113 f"Failed to import {self.__name__}.{module_name} because of the following error (look up to see its"
1114 f" traceback):\n{e}"
1115 ) from e
RuntimeError: Failed to import transformers.models.clip.modeling_clip because of the following error (look up to see its traceback):
oneflow.cuda.amp.GradScaler is not implemented, please submit an issue at
'https://github.com/Oneflow-Inc/oneflow/issues' including the log information of the error, the
minimum reproduction code, and the system information.
from onediff.
File ~/miniconda3/lib/python3.10/site-packages/transformers/models/clip/modeling_clip.py:27
26 from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling
---> 27 from ...modeling_utils import PreTrainedModel
28 from ...utils import (
29 ModelOutput,
30 add_start_docstrings,
(...)
33 replace_return_docstrings,
34 )
File ~/miniconda3/lib/python3.10/site-packages/transformers/modeling_utils.py:83
82 if is_accelerate_available():
---> 83 from accelerate import __version__ as accelerate_version
84 from accelerate import dispatch_model, infer_auto_device_map, init_empty_weights
尴尬了,这个路径是 transformers 库里面的,我们现在让用户自己安装的官方 transformers,这样就改不了它的逻辑了。
那就还是沿用上面的方法吧:
python3 -m pip uninstall accelerate
from onediff.
Related Issues (20)
- 让 ComfyUI Manager 安装 Onediff 更丝滑 HOT 5
- Diffusers IPAdapter bug HOT 20
- [New algo for optimization]Align Your Steps: Optimizing Sampling Schedules in Diffusion Models
- image-to-image sdxl light
- webui中使用regional-prompter插件时编译模型报错
- oneflow优化和nsys同时使用时出错
- During execution, the script keeps adjusting the size of the output image, resulting in OOM of the graphics card HOT 3
- Repeated compilation of the txt2image model under dynamic resolution HOT 3
- Can not use 'nsys profile' for onediff diffusers
- After using onediff to speed up, it slows down in sd-webui HOT 1
- runtime and compiletime cudu is not match
- A10 性能下降 HOT 4
- module 'oneflow._C' has no attribute 'broadcast_dim_like'
- DeepCache error and recompilation in ComfyUI
- ComfyUI_IPAdapter_plus with OneDiff支持再加lora吗
- Source code of oneflow HOT 1
- comfyui切换模型报错 HOT 3
- 请问一下,我现在想要加速sdxl版本的图生图,输入图像的分辨率是任意的,这样情况可以用oneflow加速吗? HOT 1
- ComfyUI IPA: Failed to save graph file & Increased Time Consumption HOT 2
- Is it possible to manually set recompile to false?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onediff.