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

双卡4090,使用代码里面的Flux,推理提示显存不足 #319

Open
BaoBaoJianqiang opened this issue Jan 21, 2025 · 2 comments
Open

Comments

@BaoBaoJianqiang
Copy link

下拉菜单选择Flux的时候,加载模型时出错

报错信息:
torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 54.00 MiB. GPU 0 has a total capacity of 23.64 GiB of which 24.81 MiB is free. Process 202215 has 23.61 GiB memory in use. Of the allocated memory 23.23 GiB is allocated by PyTorch, and 9.13 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)

看显卡:
第一张卡24186MiB / 24564MiB;第二张卡4MiB / 24564MiB。

说明推理代码全都在第一个显卡跑,结果超过24G了。有什么办法把一些模型加载到第二张卡。

我看加载模型用的是diffsynth库的ModelManager的load_models方法,有什么办法在这个方法中,让不同的显卡加载不同的模型?

@BaoBaoJianqiang
Copy link
Author

我看了ModelManager的源码,貌似load_models方法所有的model使用同一个device,因此要使用load_model方法分别指定不同的device。我明天睡醒了亲自试试

@BaoBaoJianqiang
Copy link
Author

试过了,不行,他这个代码都是写死的,使用第一个卡。要改的话,要修改flux_image.py,model_manager很多地方。所以和双卡无关,加再多卡也没有,只能换更高显存的卡。

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

No branches or pull requests

1 participant