improving warning message and adding further tips for installation (#204)
This commit is contained in:
22
INSTALL.md
22
INSTALL.md
@@ -5,6 +5,7 @@
|
||||
- Linux with Python ≥ 3.10, PyTorch ≥ 2.3.1 and [torchvision](https://github.com/pytorch/vision/) that matches the PyTorch installation. Install them together at https://pytorch.org to ensure this.
|
||||
* Note older versions of Python or PyTorch may also work. However, the versions above are strongly recommended to provide all features such as `torch.compile`.
|
||||
- [CUDA toolkits](https://developer.nvidia.com/cuda-toolkit-archive) that match the CUDA version for your PyTorch installation. This should typically be CUDA 12.1 if you follow the default installation command.
|
||||
- If you are installing on Windows, it's strongly recommended to use [Windows Subsystem for Linux (WSL)](https://learn.microsoft.com/en-us/windows/wsl/install) with Ubuntu.
|
||||
|
||||
Then, install SAM 2 from the root of this repository via
|
||||
```bash
|
||||
@@ -22,11 +23,13 @@ This would also skip the post-processing step at runtime (removing small holes a
|
||||
|
||||
By default, we allow the installation to proceed even if the SAM 2 CUDA extension fails to build. (In this case, the build errors are hidden unless using `-v` for verbose output in `pip install`.)
|
||||
|
||||
If you see a message like `Skipping the post-processing step due to the error above` at runtime or `Failed to build the SAM 2 CUDA extension due to the error above` during installation, it indicates that the SAM 2 CUDA extension failed to build in your environment. In this case, you can still use SAM 2 for both image and video applications, but the post-processing step (removing small holes and sprinkles in the output masks) will be skipped. This shouldn't affect the results in most cases.
|
||||
If you see a message like `Skipping the post-processing step due to the error above` at runtime or `Failed to build the SAM 2 CUDA extension due to the error above` during installation, it indicates that the SAM 2 CUDA extension failed to build in your environment. In this case, **you can still use SAM 2 for both image and video applications**. The post-processing step (removing small holes and sprinkles in the output masks) will be skipped, but this shouldn't affect the results in most cases.
|
||||
|
||||
If you would like to enable this post-processing step, you can reinstall SAM 2 on a GPU machine with environment variable `SAM2_BUILD_ALLOW_ERRORS=0` to force building the CUDA extension (and raise errors if it fails to build), as follows
|
||||
```bash
|
||||
pip uninstall -y SAM-2; rm -f sam2/*.so; SAM2_BUILD_ALLOW_ERRORS=0 pip install -v -e ".[demo]"
|
||||
pip uninstall -y SAM-2 && \
|
||||
rm -f ./sam2/*.so && \
|
||||
SAM2_BUILD_ALLOW_ERRORS=0 pip install -v -e ".[demo]"
|
||||
```
|
||||
|
||||
Note that PyTorch needs to be installed first before building the SAM 2 CUDA extension. It's also necessary to install [CUDA toolkits](https://developer.nvidia.com/cuda-toolkit-archive) that match the CUDA version for your PyTorch installation. (This should typically be CUDA 12.1 if you follow the default installation command.) After installing the CUDA toolkits, you can check its version via `nvcc --version`.
|
||||
@@ -101,6 +104,21 @@ In particular, if you have a lower PyTorch version than 2.3.1, it's recommended
|
||||
We have been building SAM 2 against PyTorch 2.3.1 internally. However, a few user comments (e.g. https://github.com/facebookresearch/segment-anything-2/issues/22, https://github.com/facebookresearch/segment-anything-2/issues/14) suggested that downgrading to PyTorch 2.1.0 might resolve this problem. In case the error persists, you may try changing the restriction from `torch>=2.3.1` to `torch>=2.1.0` in both [`pyproject.toml`](pyproject.toml) and [`setup.py`](setup.py) to allow PyTorch 2.1.0.
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
I got `CUDA error: no kernel image is available for execution on the device`
|
||||
</summary>
|
||||
<br/>
|
||||
|
||||
A possible cause could be that the CUDA kernel is somehow not compiled towards your GPU's CUDA [capability](https://developer.nvidia.com/cuda-gpus). This could happen if the installation is done in an environment different from the runtime (e.g. in a slurm system).
|
||||
|
||||
You can try pulling the latest code from the SAM 2 repo and running the following
|
||||
```
|
||||
export TORCH_CUDA_ARCH_LIST=9.0 8.0 8.6 8.9 7.0 7.2 7.5 6.0`
|
||||
```
|
||||
to manually specify the CUDA capability in the compilation target that matches your GPU.
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
I got `RuntimeError: No available kernel. Aborting execution.` (or similar errors)
|
||||
|
Reference in New Issue
Block a user