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

Use device by reference for dino #189

Conversation

light-and-ray
Copy link
Contributor

@light-and-ray light-and-ray commented Feb 4, 2024

Hello! I tried to temporary override global device variable in my extension, which uses your extension, before use dino model, to make it works on cpu, for Intel ARC witch doesn't support 64-bit float, and for potato-gpus which doesn't have enought memory for dino model. But I've found the extension copies device on app started. from ... import variable copies it

restore = []
try:
    if useCpuForDetection():
        oldDevice = devices.device
        def restore_():
            devices.device = oldDevice
        restore.append(restore_)
        devices.device = 'cpu'
        print(f'[{EXT_NAME}] Use CPU for detection')
    self._createMasks()
    masksCreatorCached = self
    print('MasksCreator cached')
finally:
    for f in restore:
        f()

I've patched your extension, and this trick started to work

@light-and-ray
Copy link
Contributor Author

light-and-ray commented Feb 4, 2024

Can you merge it, please @continue-revolution

@continue-revolution continue-revolution merged commit 5f69b95 into continue-revolution:master Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants