Stable diffusion: AttributeError: module ‘jax.random‘ has no attribute ‘KeyArray‘

Stable diffusion: AttributeError: module ‘jax.random‘ has no attribute ‘KeyArray‘

    正在检查是否收录...

错误提示

安装
from diffusers import StableDiffusionPipeline 提示错误

AttributeError: module ‘jax.random’ has no attribute ‘KeyArray’

解决方法

pip install "jax[cuda12_pip]==0.4.23" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html 或者 pip install "jax[cuda12_local]==0.4.23" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html 

在colab里面,可以运行以下命令行

!pip install "jax[cuda12_local]==0.4.23" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html !pip install diffusers==0.11.1 !pip install transformers scipy ftfy accelerate 

参考:
https://stackoverflow.com/questions/78302031/stable-diffusion-attributeerror-module-jax-random-has-no-attribute-keyarray

总结

### 文章总结
#### 问题描述
在安装`StableDiffusionPipeline`时遇到`AttributeError`,错误信息显示`module ‘jax.random’ has no attribute ‘KeyArray’`。这个问题通常是由于`jax`库的版本与其他依赖性库不兼容所导致的。
#### 解决方法
为解决这个错误,可以通过指定版本的`jax`库进行安装。推荐的版本是`0.4.23`,并且有两个不同的版本可以根据需求选择,它们针对CUDA支持有所不同:
1. **CUDA远程版本**:用于需要从远程位置安装CUDA支持的场景,可以使用以下命令:
```bash
pip install "jax[cuda12_pip]==0.4.23" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
```
2. **CUDA本地版本**:如果你已经有CUDA环境配置在你的系统中,或者在你不需要从远程下载安装CUDA的情况下,可以使用:
```bash
pip install "jax[cuda12_local]==0.4.23" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
```
#### 在Google Colab中的特别说明
如果你在Google Colab上操作,可以使用以下一组命令来安装所有必要的库,并确保版本兼容性:
```bash
!pip install "jax[cuda12_local]==0.4.23" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
!pip install diffusers==0.11.1
!pip install transformers scipy ftfy accelerate
```
这些命令将安装特定版本的`jax`来避免`KeyArray`属性的问题,并安装或更新`diffusers`和相关依赖库到适当的版本。
#### 参考链接
如果需要更多信息或遇到其他问题,可以参考Stack Overflow上的一个类似问题解答:
[Stable Diffusion: AttributeError: module 'jax.random' has no attribute 'KeyArray'](https://stackoverflow.com/questions/78302031/stable-diffusion-attributeerror-module-jax-random-has-no-attribute-keyarray) jaxgoogleapiraghtmldiffusionflowbashtransformerstablediffusiontransformersstackoverflowstable diffusion问题解答命令行兼容性
  • 本文作者:李琛
  • 本文链接: https://wapzz.net/post-19929.html
  • 版权声明:本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。
本站部分内容来源于网络转载,仅供学习交流使用。如涉及版权问题,请及时联系我们,我们将第一时间处理。
文章很赞!支持一下吧 还没有人为TA充电
为TA充电
还没有人为TA充电
0
  • 支付宝打赏
    支付宝扫一扫
  • 微信打赏
    微信扫一扫
感谢支持
文章很赞!支持一下吧
关于作者
2.3W+
5
0
1
WAP站长官方

一文看懂llama2(原理&模型&训练)

上一篇

Datawhale X 魔搭 AI夏令营第四期AIGC方向笔记task3

下一篇
  • 复制图片
按住ctrl可打开默认菜单