我尝试使用 Docker for Windows 运行主题 Stable-Dreamfusion

你好! !紫苑是! ! !
这次能在Docker环境下跑题Stable-Dreamfusion,所以打算写一篇关于流程的文章。
Docker本身还是个初学者,所以可能会有文笔不好的地方。
因此,我希望您将其视为一种方式! !

执行环境

视窗 10
英伟达 GeForce RTX 3090
内存 64GB
适用于 Windows 的 Docker

什么是稳定-Dreamfusion

稳定-Dreamfusion是一种从文本生成 3D 模型的方法。
其特点是完全不需要 3D 数据集,因为将 2D 图像生成模型转换为 3D。
因此,可以进行各种 3D 生成。

Docker for Windowsで話題のDreamfusion(Text to 3D model)を動かしてみた

细节是请看。

在为 Windows 运行 Docker 之前

WSL2的介绍

在以管理员权限打开的 PowerShell 中运行以下命令:

wsl --install

接下来,检查是否启用了 WSL2。

wsl --status

如果这里的默认版本不是 2,请执行以下操作:

wsl --set-default-version 2

为 WSL 安装 NVIDIA 驱动程序

让我们将 NVIDIA 驱动程序放在主机环境中。

按下下一页的Get CUDA Driver按钮,安装GeForce Driver(Quadro Driver取决于执行环境)
请下载它。
https://developer.nvidia.com/cuda/wsl

默认安装一切都很好。

为 Windows 安装 Docker 桌面

接下来,放置 Docker 桌面。
https://www.docker.com/products/docker-desktop/

安装时要注意的是配置
检查安装 WSL 2 所需的 Windows 组件并安装。

让我们检查它是否已安装。

 wsl -l -v
  NAME                   STATE           VERSION
* Ubuntu-20.04           Running         2
  docker-desktop         Running         2
  docker-desktop-data    Running         2

GPU 现在可以在 Docker for Windows 上使用。

直到我运行 Stable-Dreamfusion

将 Stable-Dreamfusion 代码克隆到任何文件夹中。

git clone https://github.com/ashawkey/stable-dreamfusion.git

接下来,我想做一个 Docker 构建,但是 Dockerfile 发生了错误。
因此,重写 Dockerfile。这时候,我们还要为共享文件夹添加一个文件夹。

dockerfile
FROM nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04

# Remove any third-party apt sources to avoid issues with expiring keys.
RUN rm -f /etc/apt/sources.list.d/*.list

RUN apt-get update

RUN DEBIAN_FRONTEND=noninteractive TZ=Europe/MADRID apt-get install -y tzdata

# Install some basic utilities
RUN apt-get install -y 
    curl 
    ca-certificates 
    sudo 
    git 
    bzip2 
    libx11-6 
    python3 
    python3-pip 
    libglfw3-dev 
    libgles2-mesa-dev 
    libglib2.0-0 
 && rm -rf /var/lib/apt/lists/*

RUN pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116

RUN pip3 install git+https://github.com/NVlabs/nvdiffrast/

RUN pip3 install git+https://github.com/openai/CLIP.git

RUN mkdir -p /home/folder

# Set the default command to python3
#CMD ["python3"]

Docker 运行时将 home/folder 设置为共享文件夹。

接下来,进行 Docker 构建。

cd stable-dreamfusion/docker
docker build -t stable-dreamfusion:latest .

然后进行 Docker 运行。

docker run --gpus all --name stable-dreamfusion --mount type=bind,src=C:Users9044Desktopesakistable-dreamfusion,dst=/home/folder -it stable-dreamfusion

让我们将 src=C:Users9044Desktopesakistable-dreamfusion 部分更改为我们刚刚克隆的位置。
现在您可以在 Docker 中共享 stable-dreamfusion 文件夹和 home/文件夹。

让我们接下来设置它。

cd home/folder/stable-dreamfusion
pip3 install -r requirements.txt
bash scripts/install_ext.sh

我以为我已经为 Github 做好了准备,但有一个很大的陷阱。
它从 hngingface 和 "Stable Diffusion" 获得访问令牌
我必须去模型描述页面并同意使用条款。

注册拥抱脸。
https://huggingface.co/settings/tokens

注册并检查您的电子邮件。否则,无法颁发访问令牌。

Docker for Windowsで話題のDreamfusion(Text to 3D model)を動かしてみた

确认您的电子邮件后,您应该会看到如下所示的屏幕。
然后按New Token,选择一个合适的名字(我这次选择了stable-dreamfusion),生成一个token。

Docker for Windowsで話題のDreamfusion(Text to 3D model)を動かしてみた

接下来,让我们登录 Docker 上的 huggingrface。

python -m pip install huggingface_hub
huggingface-cli login

生成的访问令牌

huggingface-cli login

        _|    _|  _|    _|    _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|_|_|_|    _|_|      _|_|_|  _|_|_|_|
        _|    _|  _|    _|  _|        _|          _|    _|_|    _|  _|            _|        _|    _|  _|        _|
        _|_|_|_|  _|    _|  _|  _|_|  _|  _|_|    _|    _|  _|  _|  _|  _|_|      _|_|_|    _|_|_|_|  _|        _|_|_|
        _|    _|  _|    _|  _|    _|  _|    _|    _|    _|    _|_|  _|    _|      _|        _|    _|  _|        _|
        _|    _|    _|_|      _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|        _|    _|    _|_|_|  _|_|_|_|

        To login, `huggingface_hub` now requires a token generated from https://huggingface.co/settings/tokens .

Token:

让我们将访问令牌放入 Token 中。

接下来,同意使用条款。
https://huggingface.co/CompVis/stable-diffusion-v1-4

大部分设置现已完成。

如果要显示gui,需要单独设置。
使用 X Window Server 执行 GUI 操作。
有关如何设置的说明,请参阅本文。
启动firefox前的设置完成后就完成了。
https://wisteriahill.sakura.ne.jp/CMS/WordPress/2020/09/02/docker-desktop-for-windows-x-window-gui/

所有设置完成。
然后让我们运行它!
没有图形用户界面

python3 main.py -O --text "a DSLR photo of adelicious hamburger" --workspace trial2 --iters 15000 --lr 1e-3 --w 64 --seed 0 --lambda_entropy 1e-4 --ckpt scratch --save_mesh

Docker for Windowsで話題のDreamfusion(Text to 3D model)を動かしてみた

顺便说一句失败了
神秘的拉面
Docker for Windowsで話題のDreamfusion(Text to 3D model)を動かしてみた

概括

这一次,我使用 Dreamfusion 从 Text 生成 3D 模型! !
未来,我们将使在 Docker 环境中运行其他模型成为可能。


原创声明:本文系作者授权爱码网发表,未经许可,不得转载;

原文地址:https://www.likecs.com/show-308630007.html

相关文章:

  • 2022-12-23
  • 2021-10-06
  • 2021-07-21
  • 2021-11-22
  • 2022-12-23
  • 2022-03-10
  • 2022-01-17
  • 2022-02-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
  • 2021-08-11
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
相关资源
相似解决方案