5090에서 GroundingDINO build하기

choonsikmom·2025년 8월 26일
0

calm-down daily life

목록 보기
25/25
post-thumbnail

GroundedSAM 좀 쓰려고 했더니만 망할 compatibility 때문에 빌드가 안 된다....

망할 삽질 Jonnan 했넹 ㅠ


Grounded-Segment-Anything

대충 빌드하다가 이런 에러가 떴다면..?

git issue 좀 찾아보니까, GroundingDINO 특정 파일 일부를 수정하면 된다고 함.

여기서 디렉토리명은 Grounded-Segment-Anything 기준이다.

ms_deform_attn_cuda.cu 파일 수정

  • groundingdino/models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn_cuda.cu

여기서 type() -> scalar_type() 으로 수정 (line 65, 135)

ms_deform_attn.h 파일 수정

  • groundingdino/models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn.h

여기서 value().type().is_cuda() -> value.is_cuda() 으로 수정 (line 30, 52)


그리고 5090은 cuda 호환성도 중요하다. cuda 12.8+ 써야 함

nvcc fatal : Unsupported gpu architecture 'compute_120'

5090과 cuda, torch compatibility가 맞지 않으면 빌드할 때 이런 식의 에러가 뜬다.

local에 cuda12.8 설치되었다면 $CUDA_HOME/usr/local/cuda-12.8로 export 해주고, cuda12.8과 호환되는 torch, torchvision, torchaudio를 install 해줘야 한다.

$ pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/cu128

torch 2.9도 해봤는데, 뭔가 torch 연산할 때 compatibility가 꼬여서 안되는 듯 싶다. 내부 연산 방식이 달라졌나 봄

torch install 할때 version에 무조건 cuda 12.8 명시하기.


Grounded-Segment-Anything 2

GroundedSAM2도 테스트 해봤는데, 똑같이 groundingdino 요구하지만 빌드가 좀 더 간단해서 (코드 변경 요하지 않음) 편했다. cuda, torch compatibility만 잘 맞춰놓고 github의 install 가이드라인을 따르자.

GroundedSAM2 github

빌드를 마치고, 동영상 넣어서 real-time으로 frame 연산하는 테스트도 해봤다. GroundedSAM2 demo 영상 돌려봤을 때, 5090 기준으로 평균 fps 12 정도 나오고 연산에 사용되는 Vram은 4.5Gb, utill은 최대 ~50%대까지 올라가는 걸 봤다.

보통은 한 20~40%?

아니 근데 데모 영상이 좀 숭한데요..?

아무튼 줘도 못먹는... 아니 먹기 힘든 rtx 5090 대여자의 하루였다.

profile
춘식이랑 함께하는 개발일지.. 그런데 이제 먼작귀를 곁들인

0개의 댓글