Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refact: walkthrough Linuxified; auto-detect target for build #5

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
import pickle
import web_stable_diffusion.trace as trace
import web_stable_diffusion.utils as utils
from platform import system

import GPUtil
import tvm
from tvm import relax
from tvm.contrib import tvmjs


def _parse_args():
args = argparse.ArgumentParser()
args.add_argument("--target", type=str, default="apple/m2-gpu")
args.add_argument("--target", type=str, default="auto")
args.add_argument("--db-path", type=str, default="log_db/")
args.add_argument("--artifact-path", type=str, default="dist")
args.add_argument(
Expand All @@ -26,7 +27,15 @@ def _parse_args():

parsed = args.parse_args()

if parsed.target == "webgpu":
if parsed.target == "auto":
if system() == "Darwin":
target = tvm.target.Target("apple/m1-gpu")
else:
has_gpu = len(GPUtil.getGPUs()) > 0
target = tvm.target.Target("cuda" if has_gpu else "llvm")
print(f"Automatically configuring target: {target}")
parsed.target = tvm.target.Target(target, host="llvm")
elif parsed.target == "webgpu":
parsed.target = tvm.target.Target(
"webgpu", host="llvm -mtriple=wasm32-unknown-unknown-wasm"
)
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accelerate
diffusers
gputil
transformers
Loading