Skip to content

(Fix)(app) Delay Imports that require torch for app launch #8067

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

Merged

Conversation

mickr777
Copy link
Contributor

Summary

Fix for RuntimeError: configure_torch_cuda_allocator() must be called before importing torch. on app start

Related Issues / Discussions

Traceback (most recent call last):
  File "D:\InvokeMain\InvokeAI\scripts\invokeai-web.py", line 20, in <module>
    main()
  File "D:\InvokeMain\InvokeAI\scripts\invokeai-web.py", line 16, in main
    run_app()
  File "D:\InvokeMain\InvokeAI\invokeai\app\run_app.py", line 33, in run_app
    configure_torch_cuda_allocator(app_config.pytorch_cuda_alloc_conf, logger)
  File "D:\InvokeMain\InvokeAI\invokeai\app\util\torch_cuda_allocator.py", line 13, in configure_torch_cuda_allocator
    raise RuntimeError("configure_torch_cuda_allocator() must be called before importing torch.")
RuntimeError: configure_torch_cuda_allocator() must be called before importing torch.
  • The PR has a short but descriptive title, suitable for a changelog

@github-actions github-actions bot added the python PRs that change python files label May 30, 2025
Copy link
Collaborator

@psychedelicious psychedelicious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't reproduce this locally - maybe it's platform specific or related to certain custom nodes? At any rate, thanks for the fix!

@psychedelicious psychedelicious merged commit 4c5ad1b into invoke-ai:main May 30, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python PRs that change python files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants