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

Fail to build the SAM 2 CUDA extension #510

Open
zw-absin opened this issue Dec 31, 2024 · 0 comments
Open

Fail to build the SAM 2 CUDA extension #510

zw-absin opened this issue Dec 31, 2024 · 0 comments

Comments

@zw-absin
Copy link

I followed the instructions in this linkhttps://github.com/facebookresearch/sam2/blob/main/INSTALL.md. There was a problem when I executed this command:
pip uninstall -y SAM-2 &&
rm -f ./sam2/*.so &&
SAM2_BUILD_ALLOW_ERRORS=0 pip install -v -e ".[notebooks]"

By the way, the installation worked when I just used the code below:
pip install -e ".[notebooks]"
But when I run these code:
mask_generator_2 = SAM2AutomaticMaskGenerator(
model=sam2,
points_per_side=64,
points_per_batch=128,
pred_iou_thresh=0.7,
stability_score_thresh=0.92,
stability_score_offset=0.7,
crop_n_layers=1,
box_nms_thresh=0.7,
crop_n_points_downscale_factor=2,
min_mask_region_area=25.0,
use_m2m=True,
)
masks2 = mask_generator_2.generate(image)
I get the following error:
Skipping the post-processing step due to the error above at runtime/Failed to build the SAM 2 CUDA extension due to the error above

How can I fix it? Or do I have to give up building the SAM 2 CUDA extension?

Env:
Python 3.10.16
torch 2.5.1
torchaudio 2.5.1
torchvision 0.20.1
CUDA version: 12.1
cuDNN version: 90100

Error:
Traceback (most recent call last):
File "/data/zhouwx/anaconda3/envs/sam2-clone/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in
main()
File "/data/zhouwx/anaconda3/envs/sam2-clone/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/data/zhouwx/anaconda3/envs/sam2-clone/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 132, in get_requires_for_build_editable
return hook(config_settings)
File "/tmp/pip-build-env-b6kk24wu/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 483, in get_requires_for_build_editable
return self.get_requires_for_build_wheel(config_settings)
File "/tmp/pip-build-env-b6kk24wu/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 334, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
File "/tmp/pip-build-env-b6kk24wu/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 304, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-b6kk24wu/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 320, in run_setup
exec(code, locals())
File "", line 153, in
File "", line 115, in
File "/tmp/pip-build-env-b6kk24wu/overlay/lib/python3.10/site-packages/torch/init.py", line 367, in
from torch._C import * # noqa: F403
ImportError: /tmp/pip-build-env-b6kk24wu/overlay/lib/python3.10/site-packages/torch/lib/../../nvidia/cusparse/lib/libcusparse.so.12: undefined symbol: __nvJitLinkComplete_12_4, version libnvJitLink.so.12
error: subprocess-exited-with-error

× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
full command: /data/zhouwx/anaconda3/envs/sam2-clone/bin/python /data/zhouwx/anaconda3/envs/sam2-clone/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py get_requires_for_build_editable /tmp/tmpuz8g1brr
cwd: /data/zhouwx/sam2-main
Getting requirements to build editable ... error
error: subprocess-exited-with-error

× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

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

1 participant