Unfortunately, LENS does not currently support devices without CUDA, or not correctly. In the lens.score
function there is the possibility to deactivate CUDA via devices=None
, but without CUDA I am not able to initialize LENS
at all:
from lens import download_model, LENS
lens_path = download_model("davidheineman/lens")
lens = LENS(lens_path, rescale=True)
lens/models/__init__.py:68, in load_from_checkpoint(checkpoint_path)
[64](.../site-packages/lens/models/__init__.py:64) model_class = str2model[hparams["class_identifier"]]
[65](.../site-packages/lens/models/__init__.py:65) # model = model_class.load_from_checkpoint(
[66](.../site-packages/lens/models/__init__.py:66) # checkpoint_path, load_pretrained_weights=False, strict=False
[67](.../site-packages/lens/models/__init__.py:67) # )
...
[253](.../site-packages/torch/serialization.py:253) 'to map your storages to the CPU.')
[254](.../site-packages/torch/serialization.py:254) device_count = torch.cuda.device_count()
[255](.../site-packages/torch/serialization.py:255) if device >= device_count:
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.
model = model_class.load_from_checkpoint(
checkpoint_path, **hparams, strict=False, map_location=torch.device('cpu')
)