移动云配置

来自 https://t.me/StableDiffusion_CN/395727 By @iracca

移动云灵车炼丹环境配置,V100实例复现成功:
大部分参考了chan佬的autodl:https://github.com/crosstyan/dreambooth-scripts-for-autodl ,下面炼丹使用的也是。
另一种来自 @junjiex 的部署方法:https://www.notion.so/aajie/fd4747a969344594aca26d24aecab402

  1. 准备工作
    移动云网络环境很糟(全局要通过移动的HTTP代理联网,而且有白名单),数据盘在各个实例间都是互通的。
    所以强烈建议先开个CPU实例(或者在面板—数据集—用户数据),去nvidia官网 下载Ubuntu 18.04 cuda11.0.3 (https://developer.download.nvidia.com/compute/cuda/11.0.3/local_installers/cuda_11.0.3_450.51.06_linux.run) ,上传到数据盘(/root),同时把炼丹的数据该上传的上传。
    如果您有高速下载且符合白名单的方法请无视。
  2. 将dreambooth-scripts-for-autodl拉到实例上
    新建一个terminal页面(以下均在terminal中),执行
    cd ~
    git clone https://github.com/crosstyan/dreambooth-scripts-for-autodl dreambooth
    cd dreambooth
    git submodule update --init --recursive
    (但是根据移动云的糟糕网络环境,可以尝试先clone到本地再传上去)
  3. 创建conda虚拟环境,安装cuda runtime和cudnn
    conda create -n diffusers python=3.10.6
    conda init bash
    进入虚拟环境
    conda activate diffusers
    conda install cudatoolkit=11.0
    conda install cudnn=8.0.5

安装完成后建议清理conda缓存,详见conda clean
尽量不要用conda安装torch,无法使用GPU,很怪

  1. pip安装各种依赖
    pip install -U pip
    pip install torch torchvision
    pip install wandb
    pip install -U --pre triton
    pip install accelerate==0.12.0 transformers ftfy bitsandbytes gradio
    pip install omegaconf einops pytorch_lightning
    pip install transformers
    cd repos/diffusers
    pip install .
  2. 安装cuda11.0.3
    在第0步上传的cuda_11.0.3_450.51.06_linux.run目录下执行
    sh cuda_11.0.3_450.51.06_linux.run
    等一会后会弹出来安装,第一步输入accept后在下一步取消勾选driver,然后install安装。最终的warning: incomplete installation不用管。
    注:这一步的环境每次重启实例后都会掉,都要再安装一次cuda,所以安装包最好不要删
    (个人尝试更新driver失败,也因此没安装更高版本cuda,有必要可以自己折腾一下)
    (测试结果是必须安装完整的cudatoolkit,只装conda的cudatoolkit跑不起来db)
  3. xformers(大概可选)
    根据 dreambooth-scripts-for-autodl (https://github.com/crosstyan/dreambooth-scripts-for-autodl) 的 xformers 环节安装即可。Compile from source可以成功但编译时间很长很长...
    没有试过直接装prebuilt wheel,推荐自行测试省些时间。我在移动云上build好的xformers whl: https://t.me/StableDiffusion_CN/398326

不想用powershell的话到这里已经不用看了。环境到这里应该已经好了

  1. 安装powershell
    默认apt源无法使用,编辑/etc/apt/sources.list替换为阿里云的Ubuntu bionic源。然后 apt update
    下载 powershell的deb包 (https://github.com/PowerShell/PowerShell/releases/download/v7.0.13/powershell_7.0.13-1.ubuntu.18.04_amd64.deb) ,上传到实例上,执行
    dpkg -i powershell_7.0.13-1.ubuntu.18.04_amd64.deb
    apt install -f (如果这一步没有安装缺少的依赖反而删掉了powershell,检查一下上面有没有替换掉默认的apt源)
    验证安装:
    pwsh
    注:这一步的powershell重启后也会消失,也需要再安装一遍,包括更新apt源
  2. 按照dreambooth-scripts-for-autodl配置炼丹参数,pwsh train.ps1 开炼
    以后使用的时候注意conda activate diffusers
  3. 数据盘空间问题
    移动云在删除实例后并不会清理遗留环境,需要手动清理。如果反复删除创建实例导致数据盘占用增加,建议在 /root 下使用 ls -lah 列出并删除一些废弃的.dl开头的文件夹(终端的 root@dl-xxxx是当前正在使用的)。
    环境全部安装完成后大概剩余25~30GB空间。一个checkpoint占用大概4~5GB,酌情配置自动保存
Edit
Pub: 23 Nov 2022 10:44 UTC
Edit: 23 Nov 2022 10:44 UTC
Views: 707