Skip to content

Commit

Permalink
Make dora cuda agnostic and compatible using zig
Browse files Browse the repository at this point in the history
  • Loading branch information
haixuanTao committed Nov 18, 2024
1 parent 3ee4d82 commit b6ef589
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/node-hub-ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ jobs:
if [[ -f "Cargo.toml" && -f "pyproject.toml" ]]; then
echo "Publishing $dir using maturin..."
pip3 install "maturin[patchelf]"
maturin publish --skip-existing
maturin publish --skip-existing --zig
else
if [ -f "pyproject.toml" ]; then
echo "Publishing $dir using Poetry..."
Expand All @@ -156,7 +156,7 @@ jobs:
echo "Package '$package_name' version '$version' already exists on crates.io. Skipping publish."
else
echo "Publishing package '$package_name' version '$version'..."
cargo publish
cargo publish
fi
fi
fi
Expand Down
3 changes: 2 additions & 1 deletion node-hub/dora-internvl/dora_internvl/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def load_image(image_array: np.array, input_size=448, max_num=12):
def main():
# Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables.
model_path = os.getenv("MODEL", "OpenGVLab/InternVL2-1B")
device = "cuda:0" if torch.cuda.is_available() else "cpu"

# If you want to load a model using multiple GPUs, please refer to the `Multiple GPUs` section.
model = (
Expand All @@ -112,7 +113,7 @@ def main():
trust_remote_code=True,
)
.eval()
.cuda()
.to(device)
)
tokenizer = AutoTokenizer.from_pretrained(
model_path, trust_remote_code=True, use_fast=False
Expand Down
5 changes: 4 additions & 1 deletion node-hub/dora-qwenvl/dora_qwenvl/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from dora import Node
import torch
from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
from qwen_vl_utils import process_vision_info
import numpy as np
Expand Down Expand Up @@ -83,7 +84,9 @@ def generate(frames: dict, question):
padding=True,
return_tensors="pt",
)
inputs = inputs.to("cuda")

device = "cuda:0" if torch.cuda.is_available() else "cpu"
inputs = inputs.to(device)

# Inference: Generation of the output
generated_ids = model.generate(**inputs, max_new_tokens=128)
Expand Down
2 changes: 1 addition & 1 deletion node-hub/dora-qwenvl/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ packages = [{ include = "dora_qwenvl" }]
python = "^3.7"
dora-rs = "^0.3.6"
numpy = "< 2.0.0"
torch = "^2.4.0"
torch = "^2.2.0"
torchvision = "^0.19"
transformers = "^4.45"
qwen-vl-utils = "^0.0.2"
Expand Down

0 comments on commit b6ef589

Please sign in to comment.