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

Attempted to set the storage of a tensor on device "cpu" to a storage on different device "mps:0" #487

Closed
byy-yby opened this issue Dec 12, 2024 · 7 comments · Fixed by #495

Comments

@byy-yby
Copy link

byy-yby commented Dec 12, 2024

When i use mps or cpu to run the video-predictor code in notebook, everything about picture segment is ok, but when it comes to the video predictor, the code go wrong like this:

截屏2024-12-12 13 50 30 sonthing meet same problem with me? my device is mbp m4
@pwaver
Copy link

pwaver commented Dec 15, 2024

Same problem.

ronghanghu added a commit to ronghanghu/sam2 that referenced this issue Dec 15, 2024
…r in MPS

In this PR, we remove `.pin_memory()` in `obj_pos` of `SAM2Base` to resolve and error in MPS. Investigations show that `.pin_memory()` causes an error of `Attempted to set the storage of a tensor on device "cpu" to a storage on different device "mps:0"`, as originally reported in facebookresearch#487.

(close facebookresearch#487)
@ronghanghu
Copy link
Contributor

Hi @pwaver @byy-yby thanks for reporting this issue! I made a patch for the MPS device in #495

ronghanghu added a commit that referenced this issue Dec 16, 2024
…r in MPS (#495)

In this PR, we remove `.pin_memory()` in `obj_pos` of `SAM2Base` to resolve and error in MPS. Investigations show that `.pin_memory()` causes an error of `Attempted to set the storage of a tensor on device "cpu" to a storage on different device "mps:0"`, as originally reported in #487.

(close #487)
@pwaver
Copy link

pwaver commented Dec 16, 2024 via email

@byy-yby
Copy link
Author

byy-yby commented Dec 16, 2024

@pwaver can you solve this problem by just delete the .pin_momeory?, it seems useless for me. interesting

@pwaver
Copy link

pwaver commented Dec 16, 2024 via email

@ronghanghu
Copy link
Contributor

Yes, I solved it by removing .pin_memory() (and then deleting pychache). But on the git site it seems this is not pulled into the main distribution so you may just re install sam2.Sent from my iPadOn Dec 16, 2024, at 11:23 AM, byy-yby @.> wrote: @pwaver can you solve this problem by just delete the .pin_momeory?, it seems useless for me. interesting —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.>

Hi @pwaver, please try pulling the latest code -- it's been merged to https://github.com/facebookresearch/sam2/blob/main/sam2/modeling/sam2_base.py in 2b90b9f

@byy-yby
Copy link
Author

byy-yby commented Dec 17, 2024

@pwaver @ronghanghu thank you for your help! I have solved this problem by delete pychache and reinstall sam2.

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

Successfully merging a pull request may close this issue.

3 participants