mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-02-10 16:50:45 +01:00
Fix base fairseq dense models when using accelerate with a GPU
This commit is contained in:
parent
5d957e33ae
commit
aeed9bd8f7
@ -642,6 +642,11 @@ def move_model_to_devices(model):
|
||||
import breakmodel
|
||||
|
||||
if(utils.HAS_ACCELERATE):
|
||||
import accelerate.utils
|
||||
for key, value in model.state_dict().items():
|
||||
target_dtype = torch.float32 if breakmodel.primary_device == "cpu" else torch.float16
|
||||
if(value.dtype is not target_dtype):
|
||||
accelerate.utils.set_module_tensor_to_device(model, key, target_dtype)
|
||||
disk_blocks = breakmodel.disk_blocks
|
||||
gpu_blocks = breakmodel.gpu_blocks
|
||||
ram_blocks = len(utils.layers_module_names) - sum(gpu_blocks)
|
||||
|
Loading…
x
Reference in New Issue
Block a user