Browse Source

Make dora cuda agnostic and compatible using zig

tags/0.3.8-rc
haixuanTao 1 year ago
parent
commit
b6ef589216
4 changed files with 9 additions and 5 deletions
  1. +2
    -2
      .github/workflows/node-hub-ci-cd.yml
  2. +2
    -1
      node-hub/dora-internvl/dora_internvl/main.py
  3. +4
    -1
      node-hub/dora-qwenvl/dora_qwenvl/main.py
  4. +1
    -1
      node-hub/dora-qwenvl/pyproject.toml

+ 2
- 2
.github/workflows/node-hub-ci-cd.yml View File

@@ -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..."
@@ -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


+ 2
- 1
node-hub/dora-internvl/dora_internvl/main.py View File

@@ -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 = (
@@ -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


+ 4
- 1
node-hub/dora-qwenvl/dora_qwenvl/main.py View File

@@ -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
@@ -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)


+ 1
- 1
node-hub/dora-qwenvl/pyproject.toml View File

@@ -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"


Loading…
Cancel
Save