Fix bug in example causing config.py to crash on computers with no CUDA-enabled GPUs #55
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When running guardrails with the example configuration found in
examples/llm/hf_pipeline_dolly
, the following error will occur if the host machine does not have any CUDA-enabled GPUs:This happens because the following lines in
config.py
attempt to select the "first" CUDA-enabled GPU on the device, when in reality there aren't any:However, this script runs fine if we simply don't specify which GPU the initializer should use, in which case it will revert to the default value. Thus, we may modify the example slightly so that it runs without crashing regardless of whether the host machine has a CUDA device:
The caveat is that the example might seem a little bit more complex, but I think this is a better approach compared to setting
device = -1
without checking for CUDA devices as the model will run significantly slower.