-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Cannot Build SAM v2 i have pytorch installed on GPU but build scrypt seem to create a venv pip-build-env-n0may61s that does not have the required dependencies ? #172
Comments
Hi, this is likely due to an error in building the SAM 2 CUDA extension. We have recently made the CUDA extension step optional (in #155 and #175) as a workaround to this problem. You can pull the latest code and reinstall via # run the line below inside the SAM 2 repo
git pull;
pip uninstall -y SAM-2;
rm -f sam2/*.so;
pip install -e ".[demo]" which allows using SAM 2 without CUDA extension (the results should stay the same in most cases, see |
I'm having the same problem as you, so can you solve it? |
Buy the way NumPy IS installed the submodule that crash refer as numpy not found and I am on windows CUDA driver for GPU is Installed and CUDA 12.6 toolkit also. Pytorch found the device and GPU capable. Failed to initialize NumPy: No module named 'numpy' D:\Applfich>pip install numpy And the other requirement also meet Pytorch D:\Applfich>pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124 |
Hi @mcousine @fffionayou It seems that the CUDA extension failed to build on Windows. We have recently made it optional to build the SAM 2 CUDA extension. Could you try pulling the latest code and reinstall via # run the line below inside the SAM 2 repo
git pull;
pip uninstall -y SAM-2;
rm -f sam2/*.so;
pip install -e ".[demo]" which allows using SAM 2 without CUDA extension (the results should stay the same in most cases, see |
Same, and my environment is torch=2.3.1 cuda=12.1, the output show that it installs torch=2.4.0 in the venv |
Exactly the same situation. Have you solved this problem by now, @YachiZhang ? Thanks. |
D:\Applfich\SAM2\segment-anything-2>pip install -e ".[demo]"
Looking in indexes: https://artifactory.hydro.qc.ca/artifactory/api/pypi/global-pypi-virtual/simple
Obtaining file:///D:/Applfich/SAM2/segment-anything-2
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... error
error: subprocess-exited-with-error
× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> [32 lines of output]
C:\LOCAL\TEMP\pip-build-env-n0may61s\overlay\Lib\site-packages\torch_subclasses\functional_tensor.py:258: UserWarning: Failed to initialize NumPy: No module named 'numpy' (Triggered internally at C:\actions-runner_work\pytorch\pytorch\builder\windows\pytorch\torch\csrc\utils\tensor_numpy.cpp:84.)
cpu = _conversion_method_template(device=torch.device("cpu"))
Traceback (most recent call last):
File "C:\Users\dd1968\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 353, in
main()
File "C:\Users\dd1968\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\dd1968\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 132, in get_requires_for_build_editable
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "C:\LOCAL\TEMP\pip-build-env-n0may61s\overlay\Lib\site-packages\setuptools\build_meta.py", line 458, in get_requires_for_build_editable
return self.get_requires_for_build_wheel(config_settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\LOCAL\TEMP\pip-build-env-n0may61s\overlay\Lib\site-packages\setuptools\build_meta.py", line 327, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\LOCAL\TEMP\pip-build-env-n0may61s\overlay\Lib\site-packages\setuptools\build_meta.py", line 297, in _get_build_requires
self.run_setup()
File "C:\LOCAL\TEMP\pip-build-env-n0may61s\overlay\Lib\site-packages\setuptools\build_meta.py", line 313, in run_setup
exec(code, locals())
File "", line 70, in
File "", line 51, in get_extensions
File "C:\LOCAL\TEMP\pip-build-env-n0may61s\overlay\Lib\site-packages\torch\utils\cpp_extension.py", line 1076, in CUDAExtension
library_dirs += library_paths(cuda=True)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\LOCAL\TEMP\pip-build-env-n0may61s\overlay\Lib\site-packages\torch\utils\cpp_extension.py", line 1214, in library_paths
paths.append(_join_cuda_home(lib_dir))
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\LOCAL\TEMP\pip-build-env-n0may61s\overlay\Lib\site-packages\torch\utils\cpp_extension.py", line 2416, in _join_cuda_home
raise OSError('CUDA_HOME environment variable is not set. '
OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
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.
CUDA is enable pytorch is using GPU ?
D:\Applfich\SAM2\segment-anything-2>pip install torch Looking in indexes: https://artifactory.hydro.qc.ca/artifactory/api/pypi/global-pypi-virtual/simple Requirement already satisfied: torch in c:\users\dd1968\appdata\local\programs\python\python312\lib\site-packages (2.4.0+cu124) Requirement already satisfied: filelock in c:\users\dd1968\appdata\local\programs\python\python312\lib\site-packages (from torch) (3.13.1) Requirement already satisfied: typing-extensions>=4.8.0 in c:\users\dd1968\appdata\local\programs\python\python312\lib\site-packages (from torch) (4.9.0) Requirement already satisfied: sympy in c:\users\dd1968\appdata\local\programs\python\python312\lib\site-packages (from torch) (1.12) Requirement already satisfied: networkx in c:\users\dd1968\appdata\local\programs\python\python312\lib\site-packages (from torch) (3.2.1) Requirement already satisfied: jinja2 in c:\users\dd1968\appdata\local\programs\python\python312\lib\site-packages (from torch) (3.1.3) Requirement already satisfied: fsspec in c:\users\dd1968\appdata\local\programs\python\python312\lib\site-packages (from torch) (2023.10.0) Requirement already satisfied: setuptools in c:\users\dd1968\appdata\local\programs\python\python312\lib\site-packages (from torch) (72.1.0) Requirement already satisfied: MarkupSafe>=2.0 in c:\users\dd1968\appdata\local\programs\python\python312\lib\site-packages (from jinja2->torch) (2.1.4) Requirement already satisfied: mpmath>=0.19 in c:\users\dd1968\appdata\local\programs\python\python312\lib\site-packages (from sympy->torch) (1.3.0)
`D:\Applfich\SAM2\segment-anything-2>python
Python 3.12.4 (tags/v3.12.4:8e8a4ba, Jun 6 2024, 19:30:16) [MSC v.1940 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
The text was updated successfully, but these errors were encountered: