SegAnyGAussians icon indicating copy to clipboard operation
SegAnyGAussians copied to clipboard

[prompt_segmenting.py] RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)

Open cs-mshah opened this issue 1 year ago • 5 comments

I am facing image I selected 3 points and set them to input_point = np.array(selected_points)

image

I'm getting the SAM masks: image

I tried adding .cuda() (to mask_pooling_prototype.unsqueeze(0)) and removing .cuda() (in cluster_centers[cluster_mask, :].cuda()) but that didn't help.

cs-mshah avatar Mar 30 '24 12:03 cs-mshah

Hi, you may need to set the cluster_mask to cuda.

Jumpat avatar Apr 01 '24 06:04 Jumpat

Hi, you may need to set the cluster_mask to cuda.

我也遇到了一样的问题,有时候可以正常运行,但是修改input point或者换场景都有可能出现这个报错

CrescentRosexx avatar Apr 09 '24 05:04 CrescentRosexx

Yes, I encountered it while modifying the input point as well.

cs-mshah avatar Apr 09 '24 05:04 cs-mshah

当我修改input_point之后遇到了同样的问题,但是我找不到问题出在哪里

KevinCDJ avatar May 28 '24 09:05 KevinCDJ

我认为我解决了这个问题,当我尝试输出mask_pooling_prototype、cluster_centers、cluster_mask这三个张量运行的设备时,发现cluster_centers运行在cpu上(未修改过代码),然后我在79行报错(我自己是75行)后加入.cuda也不能解决,后发现在计算cluster_centers时,下面加一行 cluster_centers = cluster_centers.cuda(),即可解决

KevinCDJ avatar May 28 '24 09:05 KevinCDJ