cbensimon HF Staff commited on
Commit
f1f06d3
·
1 Parent(s): 4166007

Keep pinned-memory

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -45,8 +45,8 @@ def compile_model():
45
  weights_: dict[str, torch.Tensor] = {}
46
  for name in weights:
47
  tensor, _properties = weights.get_weight(name)
48
- tensor_ = torch.empty_like(tensor, device='cpu', requires_grad=False)
49
- weights_[name] = tensor_.copy_(tensor).share_memory_() # TODO: non_blocking=True?
50
  return weights_
51
 
52
  weights = compile_model()
 
45
  weights_: dict[str, torch.Tensor] = {}
46
  for name in weights:
47
  tensor, _properties = weights.get_weight(name)
48
+ tensor_ = torch.empty_like(tensor, device='cpu', requires_grad=False).pin_memory()
49
+ weights_[name] = tensor_.copy_(tensor).share_memory_()
50
  return weights_
51
 
52
  weights = compile_model()