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

Issue with video predictor #14

Closed
MattLiutt opened this issue Jul 30, 2024 · 9 comments
Closed

Issue with video predictor #14

MattLiutt opened this issue Jul 30, 2024 · 9 comments

Comments

@MattLiutt
Copy link

I tried to run the example under Colab, and encountered the following error when import _C.so from sam2. It would be helpful if you could provide some ideas on this issue.

/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py in decorate_context(*args, **kwargs)
    113     def decorate_context(*args, **kwargs):
    114         with ctx_factory():
--> 115             return func(*args, **kwargs)
    116 
    117     return decorate_context

/content/segment-anything-2/sam2/sam2_video_predictor.py in add_new_points(self, inference_state, frame_idx, obj_id, points, labels, clear_old_points, normalize_coords)
    219             # Clamp the scale of prev_sam_mask_logits to avoid rare numerical issues.
    220             prev_sam_mask_logits = torch.clamp(prev_sam_mask_logits, -32.0, 32.0)
--> 221         current_out, _ = self._run_single_frame_inference(
    222             inference_state=inference_state,
    223             output_dict=obj_output_dict,  # run on the slice of a single object

/content/segment-anything-2/sam2/sam2_video_predictor.py in _run_single_frame_inference(self, inference_state, output_dict, frame_idx, batch_size, is_init_cond_frame, point_inputs, mask_inputs, reverse, run_mem_encoder, prev_sam_mask_logits)
    808         # potentially fill holes in the predicted masks
    809         if self.fill_hole_area > 0:
--> 810             pred_masks_gpu = fill_holes_in_mask_scores(
    811                 pred_masks_gpu, self.fill_hole_area
    812             )

/content/segment-anything-2/sam2/utils/misc.py in fill_holes_in_mask_scores(mask, max_area)
    221     # (background regions are those with mask scores <= 0)
    222     assert max_area > 0, "max_area must be positive"
--> 223     labels, areas = get_connected_components(mask <= 0)
    224     is_hole = (labels > 0) & (areas <= max_area)
    225     # We fill holes with a small positive mask score (0.1) to change them to foreground.

/content/segment-anything-2/sam2/utils/misc.py in get_connected_components(mask)
     59               components for foreground pixels and 0 for background pixels.
     60     """
---> 61     from sam2 import _C
     62 
     63     return _C.get_connected_componnets(mask.to(torch.uint8).contiguous())

ImportError: /content/segment-anything-2/sam2/_C.so: undefined symbol: _ZN3c1015SmallVectorBaseIjE8grow_podEPKvmm

Python version: 3.10
Environment: Google Colab with T4

@MattLiutt
Copy link
Author

Issue solved.

@albertfaromatics
Copy link

How did you solve it?

@leoisufa
Copy link

How did you solve it? same question

@leviome
Copy link

leviome commented Jul 30, 2024

How ?

@leoisufa
Copy link

I fix this problem by installing pytorch=2.1.0, while I meet this problem by using pytorch=2.3.1. After changing the pytorch version, it works well.

How did you solve it? same question

@fangli333
Copy link

fangli333 commented Jul 30, 2024

just conda install pytorch=2.1.0?

@Squirrel-code
Copy link

I noticed that there are

REQUIRED_PACKAGES = [
"torch>=2.3.1",

in setpu.py,
I'm confused. X﹏X

@Squirrel-code
Copy link

Another solution in #22 is running: python setup.py build_ext --inplace.
It workd. ( •̀ ω •́ )✧

@XinrunXu
Copy link

Do not work for me

(sam2) C:\Users\PS\Desktop\segment-anything-2>python setup.py clean --all
CUDA_HOME in setup.py: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8
running clean
removing 'build\temp.win-amd64-cpython-310' (and everything under it)
'build\lib.win-amd64-cpython-310' does not exist -- can't clean it
'build\bdist.win-amd64' does not exist -- can't clean it
'build\scripts-3.10' does not exist -- can't clean it
removing 'build'

(sam2) C:\Users\PS\Desktop\segment-anything-2>python setup.py build_ext --inplace
CUDA_HOME in setup.py: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8
running build_ext
C:\Users\PS.conda\envs\sam2\lib\site-packages\torch\utils\cpp_extension.py:384: UserWarning: Error checking compiler version for cl: [WinError 2] The system cannot find the file specified
warnings.warn(f'Error checking compiler version for {compiler}: {error}')
building 'sam2.C' extension
creating C:\Users\PS\Desktop\segment-anything-2\build
creating C:\Users\PS\Desktop\segment-anything-2\build\temp.win-amd64-cpython-310
creating C:\Users\PS\Desktop\segment-anything-2\build\temp.win-amd64-cpython-310\Release
creating C:\Users\PS\Desktop\segment-anything-2\build\temp.win-amd64-cpython-310\Release\sam2
creating C:\Users\PS\Desktop\segment-anything-2\build\temp.win-amd64-cpython-310\Release\sam2\csrc
Emitting ninja build file C:\Users\PS\Desktop\segment-anything-2\build\temp.win-amd64-cpython-310\Release\build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
[1/1] C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\bin\nvcc --generate-dependencies-with-compile --dependency-output C:\Users\PS\Desktop\segment-anything-2\build\temp.win-amd64-cpython-310\Release\sam2/csrc/connected_components.obj.d -std=c++17 --use-local-env -Xcompiler /MD -Xcompiler /wd4819 -Xcompiler /wd4251 -Xcompiler /wd4244 -Xcompiler /wd4267 -Xcompiler /wd4275 -Xcompiler /wd4018 -Xcompiler /wd4190 -Xcompiler /wd4624 -Xcompiler /wd4067 -Xcompiler /wd4068 -Xcompiler /EHsc -Xcudafe --diag_suppress=base_class_has_different_dll_interface -Xcudafe --diag_suppress=field_without_dll_interface -Xcudafe --diag_suppress=dll_interface_conflict_none_assumed -Xcudafe --diag_suppress=dll_interface_conflict_dllexport_assumed -IC:\Users\PS.conda\envs\sam2\lib\site-packages\torch\include -IC:\Users\PS.conda\envs\sam2\lib\site-packages\torch\include\torch\csrc\api\include -IC:\Users\PS.conda\envs\sam2\lib\site-packages\torch\include\TH -IC:\Users\PS.conda\envs\sam2\lib\site-packages\torch\include\THC "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\include" -IC:\Users\PS.conda\envs\sam2\include -IC:\Users\PS.conda\envs\sam2\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\cppwinrt" -c C:\Users\PS\Desktop\segment-anything-2\sam2\csrc[connected_components.cu](http://connected_components.cu/) -o C:\Users\PS\Desktop\segment-anything-2\build\temp.win-amd64-cpython-310\Release\sam2/csrc/connected_components.obj -D__CUDA_NO_HALF_OPERATORS
_ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -DCUDA_HAS_FP16=1 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=C -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_80,code=sm_80
FAILED: C:/Users/PS/Desktop/segment-anything-2/build/temp.win-amd64-cpython-310/Release/sam2/csrc/connected_components.obj
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\bin\nvcc --generate-dependencies-with-compile --dependency-output C:\Users\PS\Desktop\segment-anything-2\build\temp.win-amd64-cpython-310\Release\sam2/csrc/connected_components.obj.d -std=c++17 --use-local-env -Xcompiler /MD -Xcompiler /wd4819 -Xcompiler /wd4251 -Xcompiler /wd4244 -Xcompiler /wd4267 -Xcompiler /wd4275 -Xcompiler /wd4018 -Xcompiler /wd4190 -Xcompiler /wd4624 -Xcompiler /wd4067 -Xcompiler /wd4068 -Xcompiler /EHsc -Xcudafe --diag_suppress=base_class_has_different_dll_interface -Xcudafe --diag_suppress=field_without_dll_interface -Xcudafe --diag_suppress=dll_interface_conflict_none_assumed -Xcudafe --diag_suppress=dll_interface_conflict_dllexport_assumed -IC:\Users\PS.conda\envs\sam2\lib\site-packages\torch\include -IC:\Users\PS.conda\envs\sam2\lib\site-packages\torch\include\torch\csrc\api\include -IC:\Users\PS.conda\envs\sam2\lib\site-packages\torch\include\TH -IC:\Users\PS.conda\envs\sam2\lib\site-packages\torch\include\THC "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\include" -IC:\Users\PS.conda\envs\sam2\include -IC:\Users\PS.conda\envs\sam2\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\cppwinrt" -c C:\Users\PS\Desktop\segment-anything-2\sam2\csrc[connected_components.cu](http://connected_components.cu/) -o C:\Users\PS\Desktop\segment-anything-2\build\temp.win-amd64-cpython-310\Release\sam2/csrc/connected_components.obj -D__CUDA_NO_HALF_OPERATORS
_ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -DCUDA_HAS_FP16=1 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_80,code=sm_80
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\include\crt/host_config.h(153): fatal error C1189: #error: -- unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2022 (inclusive) are supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
connected_components.cu
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
File "C:\Users\PS.conda\envs\sam2\lib\site-packages\torch\utils\cpp_extension.py", line 2107, in _run_ninja_build
subprocess.run(
File "C:\Users\PS.conda\envs\sam2\lib\subprocess.py", line 526, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\PS\Desktop\segment-anything-2\setup.py", line 68, in
setup(
File "C:\Users\PS.conda\envs\sam2\lib\site-packages\setuptools_init_.py", line 104, in setup
return distutils.core.setup(**attrs)
File "C:\Users\PS.conda\envs\sam2\lib\site-packages\setuptools_distutils\core.py", line 184, in setup
return run_commands(dist)
File "C:\Users\PS.conda\envs\sam2\lib\site-packages\setuptools_distutils\core.py", line 200, in run_commands
dist.run_commands()
File "C:\Users\PS.conda\envs\sam2\lib\site-packages\setuptools_distutils\dist.py", line 969, in run_commands
self.run_command(cmd)
File "C:\Users\PS.conda\envs\sam2\lib\site-packages\setuptools\dist.py", line 967, in run_command
super().run_command(command)
File "C:\Users\PS.conda\envs\sam2\lib\site-packages\setuptools_distutils\dist.py", line 988, in run_command
cmd_obj.run()
File "C:\Users\PS.conda\envs\sam2\lib\site-packages\setuptools\command\build_ext.py", line 91, in run
_build_ext.run(self)
File "C:\Users\PS.conda\envs\sam2\lib\site-packages\setuptools_distutils\command\build_ext.py", line 359, in run
self.build_extensions()
File "C:\Users\PS.conda\envs\sam2\lib\site-packages\torch\utils\cpp_extension.py", line 870, in build_extensions
build_ext.build_extensions(self)
File "C:\Users\PS.conda\envs\sam2\lib\site-packages\setuptools_distutils\command\build_ext.py", line 479, in build_extensions
self._build_extensions_serial()
File "C:\Users\PS.conda\envs\sam2\lib\site-packages\setuptools_distutils\command\build_ext.py", line 505, in _build_extensions_serial
self.build_extension(ext)
File "C:\Users\PS.conda\envs\sam2\lib\site-packages\setuptools\command\build_ext.py", line 252, in build_extension
_build_ext.build_extension(self, ext)
File "C:\Users\PS.conda\envs\sam2\lib\site-packages\setuptools_distutils\command\build_ext.py", line 560, in build_extension
objects = self.compiler.compile(
File "C:\Users\PS.conda\envs\sam2\lib\site-packages\torch\utils\cpp_extension.py", line 842, in win_wrap_ninja_compile
_write_ninja_file_and_compile_objects(
File "C:\Users\PS.conda\envs\sam2\lib\site-packages\torch\utils\cpp_extension.py", line 1783, in _write_ninja_file_and_compile_objects
_run_ninja_build(
File "C:\Users\PS.conda\envs\sam2\lib\site-packages\torch\utils\cpp_extension.py", line 2123, in _run_ninja_build
raise RuntimeError(message) from e
RuntimeError: Error compiling objects for extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants