linux部署stable diffusion

模型地址:https://github.com/CompVis/stable-diffusion

  1. 下载代码库

    git clone https://github.com/CompVis/stable-diffusion.git
    

2.创建虚拟环境

#找到environment.yaml,注释掉最后三行,单独下载,然后将环境名字改成sd,因为之前下载过一遍,这里为了和之前的不同所以改名字。
conda env create -f environment.yaml
conda activate sd
pip3 install git+https://github.com/CompVis/taming-transformers.git@master#egg=taming-transformers
pip3 install git+https://github.com/openai/CLIP.git@main#egg=clip
pip install -e .

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-nermWs4q-1675858439226)(F:%5Cmakedown%E5%9B%BE%E7%89%87%5Cimage-20230206192150701.png)]

出现这个错误在多运行几遍同样的命令即可。。。。玄学。。。。

  1. 将权重文件放在对应的位置

    mkdir -p models/ldm/stable-diffusion-v1/
    #从https://huggingface.co/CompVis/stable-diffusion下载预训练权重。放到stable-diffusion-v1文件中,并且命名为model.ckpt
    #测试文生图指令
    python scripts/txt2img.py --prompt "a photograph of an astronaut riding a horse" --plms 
    

    如果报错:ModuleNotFoundError: no module named “taming”,使用下面指令解决。

    pip install taming-transformers-rom1504
    #cuda out of memory
    export CUDA_LAUNCH_BLOCKING=1
    师兄清理了一下gpu内存,在重复运行2遍居然就可以了?。。。。。玄学
    
    

猜你喜欢

转载自blog.csdn.net/shan_5233/article/details/128942693