Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
evshiron committed May 10, 2023
0 parents commit fc539a4
Show file tree
Hide file tree
Showing 13 changed files with 239 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/build-rocm5.5-torch2.0-wheels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: build-rocm5.5-torch2.0-wheels

on: workflow_dispatch

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: sudo bash scripts/prepare.sh
- run: sudo bash scripts/build_torch.sh
- uses: actions/upload-artifact@v3
with:
name: wheels
path: |
**/dist/*.whl
16 changes: 16 additions & 0 deletions .github/workflows/build-rocm5.5-torchvision0.15-wheels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: build-rocm5.5-torchvision0.15-wheels

on: workflow_dispatch

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: sudo bash scripts/prepare.sh
- run: sudo bash scripts/build_torchvision.sh
- uses: actions/upload-artifact@v3
with:
name: wheels
path: |
**/dist/*.whl
19 changes: 19 additions & 0 deletions .github/workflows/docker-build-rocm5.5-a1111-webui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: docker-build-rocm5.5-a1111-webui

on: workflow_dispatch

jobs:
build:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: docker build -f dockerfiles/rocm5.5-a1111-webui -t ghcr.io/${{ github.actor }}/rocm_lab:rocm5.5-a1111-webui .
- run: docker push ghcr.io/${{ github.actor }}/rocm_lab:rocm5.5-a1111-webui
19 changes: 19 additions & 0 deletions .github/workflows/docker-build-rocm5.5-ub22.04-base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: docker-build-rocm5.5-ub22.04-base

on: workflow_dispatch

jobs:
build:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: docker build -f dockerfiles/rocm5.5-ub22.04-base -t ghcr.io/${{ github.actor }}/rocm_lab:rocm5.5-ub22.04-base .
- run: docker push ghcr.io/${{ github.actor }}/rocm_lab:rocm5.5-ub22.04-base
19 changes: 19 additions & 0 deletions .github/workflows/docker-build-rocm5.5-ub22.04-torch2.0.1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: docker-build-rocm5.5-ub22.04-torch2.0.1

on: workflow_dispatch

jobs:
build:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: docker build -f dockerfiles/rocm5.5-ub22.04-torch2.0.1 -t ghcr.io/${{ github.actor }}/rocm_lab:rocm5.5-ub22.04-torch2.0.1 .
- run: docker push ghcr.io/${{ github.actor }}/rocm_lab:rocm5.5-ub22.04-torch2.0.1
13 changes: 13 additions & 0 deletions dockerfiles/rocm5.5-a1111-webui
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ghcr.io/evshiron/rocm_lab:rocm5.5-ub22.04-torch2.0.1

SHELL ["/bin/bash", "-c"]
WORKDIR /root

ADD scripts/build_a1111-webui.sh build_a1111-webui.sh

RUN source venv/bin/activate \
&& bash build_a1111-webui.sh

CMD source venv/bin/activate \
&& cd /root/stable-diffusion-webui \
&& LD_PRELOAD=libtcmalloc.so python3 launch.py --listen --no-half-vae
9 changes: 9 additions & 0 deletions dockerfiles/rocm5.5-ub22.04-base
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ubuntu:22.04

RUN apt update && apt install -y curl \
&& curl -O https://repo.radeon.com/amdgpu-install/5.5/ubuntu/jammy/amdgpu-install_5.5.50500-1_all.deb \
&& dpkg -i amdgpu-install_5.5.50500-1_all.deb \
&& DEBIAN_FRONTEND=noninteractive amdgpu-install --usecase=rocm --no-dkms --no-32 -y \
&& apt clean

CMD bash
14 changes: 14 additions & 0 deletions dockerfiles/rocm5.5-ub22.04-torch2.0.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM ghcr.io/evshiron/rocm_lab:rocm5.5-ub22.04-base

SHELL ["/bin/bash", "-c"]
WORKDIR /root

RUN apt update && apt install -y curl python3-pip python3-venv && python3 -m venv venv
RUN source venv/bin/activate \
&& curl -O https://pub-1cbfe09f357e4aa1a82dc7a43cc443ab.r2.dev/wheel/torch-2.0.1%2Bgitd0d0524-cp310-cp310-linux_x86_64.whl \
&& pip install torch-2.0.1%2Bgitd0d0524-cp310-cp310-linux_x86_64.whl
RUN source venv/bin/activate \
&& curl -O https://pub-1cbfe09f357e4aa1a82dc7a43cc443ab.r2.dev/wheel/torchvision-0.15.2%2B6770a25-cp310-cp310-linux_x86_64.whl \
&& pip install torchvision-0.15.2%2B6770a25-cp310-cp310-linux_x86_64.whl

CMD bash
14 changes: 14 additions & 0 deletions patches/torch.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 471fc8a..c4d3a64 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -463,7 +463,7 @@ option(BUILD_EXECUTORCH "Master flag to build Executorch" ON)
# symbol lookup error: miniconda3/envs/pytorch-py3.7/lib/libmkl_intel_lp64.so: undefined symbol: mkl_blas_dsyrk
# https://software.intel.com/en-us/articles/symbol-lookup-error-when-linking-intel-mkl-with-gcc-on-ubuntu
if(LINUX)
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-as-needed")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-as-needed,--verbose,-L/opt/rocm/lib")
endif()

if(MSVC)

36 changes: 36 additions & 0 deletions scripts/build_a1111-webui.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh

set -ex

# taken from https://github.com/camenduru/stable-diffusion-webui-colab

apt install -y -qq git wget aria2 libcairo2-dev pkg-config python3-dev libgoogle-perftools-dev

git clone -b v2.1 https://github.com/camenduru/stable-diffusion-webui

aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/embed/upscale/resolve/main/4x-UltraSharp.pth -d /root/stable-diffusion-webui/models/ESRGAN -o 4x-UltraSharp.pth
git clone https://github.com/camenduru/stable-diffusion-webui-images-browser /root/stable-diffusion-webui/extensions/stable-diffusion-webui-images-browser
git clone https://github.com/kohya-ss/sd-webui-additional-networks /root/stable-diffusion-webui/extensions/sd-webui-additional-networks
git clone https://github.com/Mikubill/sd-webui-controlnet /root/stable-diffusion-webui/extensions/sd-webui-controlnet
git clone https://github.com/KohakuBlueleaf/a1111-sd-webui-locon /root/stable-diffusion-webui/extensions/a1111-sd-webui-locon
git clone https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111 /root/stable-diffusion-webui/extensions/multidiffusion-upscaler-for-automatic1111
git clone https://github.com/thomasasfk/sd-webui-aspect-ratio-helper /root/stable-diffusion-webui/extensions/sd-webui-aspect-ratio-helper

cd /root/stable-diffusion-webui

pip install git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379
pip install git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1
pip install git+https://github.com/mlfoundations/open_clip.git@bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b

mkdir -p /root/stable-diffusion-webui/repositories

git clone https://github.com/Stability-AI/stablediffusion /root/stable-diffusion-webui/repositories/stable-diffusion-stability-ai
git clone https://github.com/CompVis/taming-transformers /root/stable-diffusion-webui/repositories/taming-transformers
git clone https://github.com/crowsonkb/k-diffusion /root/stable-diffusion-webui/repositories/k-diffusion
git clone https://github.com/sczhou/CodeFormer /root/stable-diffusion-webui/repositories/CodeFormer
git clone https://github.com/salesforce/BLIP /root/stable-diffusion-webui/repositories/BLIP

pip install -r /root/stable-diffusion-webui/repositories/CodeFormer/requirements.txt
pip install -r /root/stable-diffusion-webui/requirements.txt

# python launch.py --listen
30 changes: 30 additions & 0 deletions scripts/build_torch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

set -ex

python3 -m venv venv

source venv/bin/activate

export USE_CUDA=0
export PYTORCH_ROCM_ARCH=gfx1100

# build torch

curl -L -O https://github.com/pytorch/pytorch/releases/download/v2.0.1/pytorch-v2.0.1.tar.gz
tar -xzvf pytorch-v2.0.1.tar.gz

cd pytorch-v2.0.1
echo 2.0.1 > version.txt

pip install cmake ninja
pip install -r requirements.txt
pip install mkl mkl-include

python3 tools/amd_build/build_amd.py

git apply ../patches/torch.diff

python setup.py bdist_wheel

cd ..
26 changes: 26 additions & 0 deletions scripts/build_torchvision.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

set -ex

python3 -m venv venv

source venv/bin/activate

export FORCE_CUDA=1

# build torchvision

curl -L -O https://pub-1cbfe09f357e4aa1a82dc7a43cc443ab.r2.dev/wheel/torch-2.0.1%2Bgitd0d0524-cp310-cp310-linux_x86_64.whl
pip install torch-2.0.1%2Bgitd0d0524-cp310-cp310-linux_x86_64.whl

curl -L -O https://github.com/pytorch/vision/archive/refs/tags/v0.15.2.tar.gz
tar -xzvf v0.15.2.tar.gz

cd vision-0.15.2
echo 0.15.2 > version.txt

pip install setuptools wheel cmake ninja

python setup.py bdist_wheel

cd ..
8 changes: 8 additions & 0 deletions scripts/prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

apt update && apt install -y git vim curl build-essential python3-pip python3-venv libpython3-dev libpng-dev libjpeg-dev

curl -O https://repo.radeon.com/amdgpu-install/5.5/ubuntu/jammy/amdgpu-install_5.5.50500-1_all.deb
dpkg -i amdgpu-install_5.5.50500-1_all.deb

DEBIAN_FRONTEND=noninteractive amdgpu-install --usecase=rocm --no-dkms --no-32 -y

0 comments on commit fc539a4

Please sign in to comment.