Skip to content

Commit

Permalink
fix: handling docker errors for missing gpu more gracefully (handles #41
Browse files Browse the repository at this point in the history
)
  • Loading branch information
evilsocket committed Feb 6, 2025
1 parent 7ba92b4 commit bfd4027
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions dyana/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ def loaders(
table.add_column("Description")

for loader in sorted(loaders, key=lambda x: x.name):
table.add_row(loader.name, loader.settings.description if loader.settings else "")
table.add_row(
loader.name,
loader.settings.description if loader.settings else "",
)

print(table)

Expand Down Expand Up @@ -98,8 +101,8 @@ def trace(
) -> None:
try:
# disable GPU on non-Linux systems
# if not no_gpu and platform_pkg.system() != "Linux":
# no_gpu = True
if not no_gpu and platform_pkg.system() != "Linux":
no_gpu = True

# check if policy is either a file or a directory
if policy and not policy.exists():
Expand All @@ -119,7 +122,12 @@ def trace(

summary(output)
except Exception as e:
print(f":cross_mark: [bold][red]error:[/] [red]{e}[/]")
serr = str(e)
if "could not select device driver" in serr and "capabilities: [[gpu]]" in serr:
print(":cross_mark: [bold][red]error:[/] [red]GPUs are not available on this system, run with --no-gpu.[/]")
else:
print(f":cross_mark: [bold][red]error:[/] [red]{e}[/]")

if verbose:
raise
else:
Expand Down

0 comments on commit bfd4027

Please sign in to comment.