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

Fix bug in example causing config.py to crash on computers with no CUDA-enabled GPUs #55

Merged
merged 1 commit into from
Jul 11, 2023
Merged
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
5 changes: 3 additions & 2 deletions examples/llm/hf_pipeline_dolly/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from functools import lru_cache

from langchain import HuggingFacePipeline
from torch.cuda import device_count

from nemoguardrails.llm.helpers import get_llm_instance_wrapper
from nemoguardrails.llm.providers import register_llm_provider
Expand All @@ -25,8 +26,8 @@ def get_dolly_v2_3b_llm():
repo_id = "databricks/dolly-v2-3b"
params = {"temperature": 0, "max_length": 1024}

# Using the first GPU
device = 0
# Use the first CUDA-enabled GPU, if any
device = 0 if device_count() else -1

llm = HuggingFacePipeline.from_model_id(
model_id=repo_id, device=device, task="text-generation", model_kwargs=params
Expand Down