facebookresearch / facebookresearch/sam2
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 ?
- Dominant language
- Jupyter Notebook
- Stars
- 19.9k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
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.
>>> import torch
>>>
>>> if torch.cuda.is_available():
... print("CUDA is available. PyTorch can use the GPU.")
... device = torch.device("cuda")
... device_name = torch.cuda.get_device_name(device)
... print(f"Using GPU: {device_name}")
... else:
... print("CUDA is not available. PyTorch will use the CPU.")
... device = torch.device("cpu")
...
CUDA is available. PyTorch can use the GPU.
Using GPU: NVIDIA RTX A2000 Laptop GPU
>>> # Example tensor on CPU
>>> tensor = torch.randn(3, 3)
>>> print(f"Tensor is on device: {tensor.device}")
Tensor is on device: cpu
>>>
>>> # Move tensor to GPU if available
>>> tensor_gpu = tensor.to(device)
>>> print(f"Tensor is now on device: {tensor_gpu.device}")
Tensor is now on device: cuda:0
>>>`
Contributor guide
Assessment
This issue has not been assessed yet.