RenShuhuai-Andy / TimeChat

[CVPR 2024] TimeChat: A Time-sensitive Multimodal Large Language Model for Long Video Understanding
https://arxiv.org/abs/2312.02051
BSD 3-Clause "New" or "Revised" License
267 stars 23 forks source link

torch.load raise TypeError: 'strict' is an invalid keyword argument for Unpickler() #9

Closed wwq66 closed 7 months ago

wwq66 commented 7 months ago

raise TypeError: 'strict' is an invalid keyword argument for Unpickler() when running the code below. It seems torch.load does not have the keyword 'strict'.

def _load_checkpoint(self, url_or_filename):
        """
        Resume from a checkpoint.
        """
        if is_url(url_or_filename):
            cached_file = download_cached_file(url_or_filename, check_hash=False, progress=True)
            checkpoint = torch.load(cached_file, map_location=self.device, strict=False)
        elif os.path.isfile(url_or_filename):
            print("url_or_filename: ", url_or_filename)
            checkpoint = torch.load(url_or_filename, map_location=self.device, strict=False)
        else:
            raise RuntimeError("checkpoint url or path is invalid")
RenShuhuai-Andy commented 7 months ago

Hi, what's your torch version? You can try pip install torch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 --index-url https://download.pytorch.org/whl/cu118

wwq66 commented 7 months ago

I've tried torch version of 1.12.1, 1.13.1, 2.1.0, but none of these version works. And the pytorch docs shows that torch.load do not have the keyword 'strict' as below.

image

Only the load_state_dict have the 'strict' keyword

image
RenShuhuai-Andy commented 7 months ago

I see. I think you can directly remove the argument of strict=False. I will fix it later.

wwq66 commented 7 months ago

Removing strict can actually fix the error. But seems to raise another error about missing keys while loading state_dict. I'll close this issue temporarily and try to fix the missing keys error.