Skip to content

Device Argument Not Working as Expected #18

Description

@timlac

Device Argument Not Working as Expected (cuda:0)

Issue 1: --device cuda in the CLI does not actually enable GPU in image mode

In process_image(), the device passed from the CLI is ignored because the function resets it internally:

def process_image(..., device='cpu'):
    # Initialize models with specified device
    device = 'cpu'   # ← this line overrides the CLI argument

As a result:
openface detect image.jpg --device cuda
still runs on CPU.

Issue 2: cuda:0 is rejected in LandmarkDetector

The constructor expects device="cuda" and a separate device_ids=[0], which is not how PyTorch normally handles device strings. Passing a standard string like cuda:0 results in:

Error: Invalid device type 'cuda:0'. Use 'cpu' or 'cuda'.

Just passing --device cuda results in:

Error: When using 'cuda', provide at least one valid device ID.
Aborted! 

Expected Behavior

--device cuda:0 should be accepted and run on GPU 0.

process_image() should not override the device passed from CLI.

Suggested Fixes

Remove or modify the hardcoded device='cpu' line in process_image().

Change device checks to device.startswith("cuda") to support cuda:0, cuda:1, etc.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions