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

how to run demo on CPU #18

Open
sychou11 opened this issue Nov 19, 2021 · 6 comments
Open

how to run demo on CPU #18

sychou11 opened this issue Nov 19, 2021 · 6 comments

Comments

@sychou11
Copy link

I wanted to run demo on CPU so I tried
python demo.py --vid_file demo.mp4 --gpu -1
However, it turned out:
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.

Then I tried to fix code in demo.py in line 108 and line 127.
But it still couldn't work.

@hongsukchoi
Copy link
Owner

Did you also change the code here?

@sychou11
Copy link
Author

Did you also change the code here?
It works, thanks!

@AhmedBourouis
Copy link

i did the same thing and i changed the code as follow:
demo.py {
line 108: ckpt = torch.load(pretrained_file,map_location=torch.device('cpu'))
line 127: checkpoint = torch.load(osp.join(BASE_DATA_DIR, 'spin_model_checkpoint.pth.tar'),map_location=torch.device('cpu'))
}
tcmr.py {
line 134: pretrained_dict = torch.load(pretrained,map_location=torch.device('cpu'))['model']
}
but I'm still getting this error:

AssertionError:
Found no NVIDIA driver on your system. Please check that you
have an NVIDIA GPU and installed a driver from
http://www.nvidia.com/Download/index.aspx

@hongsukchoi
Copy link
Owner

@AhmedBourouis

Hmm, it seems there is no problem. Would you trying eliminating this line?

@AhmedBourouis
Copy link

@hongsukchoi
thank you for your answer but i still have the same error even after eliminating that line (line 374 in demo.py)
can i run it in google colab ?

@hongsukchoi
Copy link
Owner

No, I haven't prepared google colab codes.

I recommend you follow this instructions to run on CPU. I did the same thing and was able to run TCMR on CPU.
In demo.py

L55 : device = torch.device('cpu')
L108: ckpt = torch.load(pretrained_file,map_location=torch.device('cpu'))
L115: model.regressor.smpl = SMPL(
        SMPL_MODEL_DIR,
        batch_size=64,
        create_transl=False,
        gender=gender
    ) #.cuda()
L127: checkpoint = torch.load(osp.join(BASE_DATA_DIR, 'spin_model_checkpoint.pth.tar'),map_location=torch.device('cpu'))

In tcmr.py

L134: pretrained_dict = torch.load(pretrained, map_location=torch.device('cpu'))['model']

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

3 participants