facebookresearch / facebookresearch/sam2
Question about reporting errors using distributed inference
- Dominant language
- Jupyter Notebook
- Stars
- 19.9k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I want to use sam2 in my project, I used the model success in single GPU. It makes great results for me.
However, when I use multi-GPU to train my model, I wanna input image to sam2 model and get result(Only inference). Then I will input the result to my model and continue my process of training.
I limited the inference of sam2 to a single GPU, but it occurs errors, like this:

my code is :
```python
def forward(self, samples):
# print('-----------------')
# print(samples["text_input"])
# print(samples["text_output"])
# print('-----------------')
rank = dist.get_rank()
image = samples["image"]
# For video data
is_video = False
if image.dim() == 5:
is_video = True
B, C, T, H, W = image.shape
if rank == 0:
print("==========================")
print("We start to use sam2")
image = sam2(image)
print(image.shape)
print("==========================")
print("sam2 Finish")
image = image.half()
else:
print("Rank {} does not execute sam2".format(rank))
#image = image.to("cuda:0")
dist.broadcast(image, src=0)
image = image.to('cuda:{}'.format(rank))
```
Who can help me !! thx very much!!!
Contributor guide
Assessment
This issue has not been assessed yet.