Open TongkunGuan opened 5 months ago
It looks like cmake is failing to detect your CUDA compiler.
Is there a reason you're building from source? I don't think there's been any changes since the last release, 0.17.1.
It looks like cmake is failing to detect your CUDA compiler.
Is there a reason you're building from source? I don't think there's been any changes since the last release, 0.17.1.
Because I want to use kernel=65.
When using pip3 install natten==0.17.1+torch200cu118 -f https://shi-labs.com/natten/wheels
, the following issue will appear:
NATTEN kernel launch failed! na2d_pn_cuda_gemm_sm80_float does not support implement kernel size 65. You may try generating it manually and build from source. Refer to NATTEN's github repository for more information.
Yeah so you're trying to use the unfused interface; unless you need to train with positional bias, I highly recommend using the FNA interface.
I.e. instead of importing na2d_qk
and na2d_av
from natten.functional
, just import na2d
. Read more here:
https://github.com/SHI-Labs/NATTEN/blob/main/docs/fna/fused-vs-unfused.md
If you need to use unfused, you should be able to just run naive kernels with any kernel size by disabling gemm:
from natten import disable_gemm_na
disable_gemm_na()
If you want to use the unfused GEMM kernels (i.e. need performance and need to use unfused because of RPB), please let me know, you'll have to re-generate the GEMM instantiations, and then build from source.
Yeah so you're trying to use the unfused interface; unless you need to train with positional bias, I highly recommend using the FNA interface. I.e. instead of importing
na2d_qk
andna2d_av
fromnatten.functional
, just importna2d
. Read more here:https://github.com/SHI-Labs/NATTEN/blob/main/docs/fna/fused-vs-unfused.md
If you need to use unfused, you should be able to just run naive kernels with any kernel size by disabling gemm:
from natten import disable_gemm_na disable_gemm_na()
If you want to use the unfused GEMM kernels (i.e. need performance and need to use unfused because of RPB), please let me know, you'll have to re-generate the GEMM instantiations, and then build from source.
Thanks! Some backbones (MViT, SAM) use the rel_pos_bias
different from the rpb
. How should I solve this problem?
Yeah so as long as you're on the latest NATTEN release (0.17.1), and run disable_gemm_na()
before the first call to NATTEN (i.e. the beginning of your program), kernel size 65 should work, but it will fall back to our naive kernels, which might not be too performant. If you'd like you use our GEMM kernels, you would need to build from source, but first, you'll have to remove the generated GEMM kernels and re-generate with max kernel size set to a number larger than 65:
rm -rf csrc/autogen/include/natten_autogen/cuda/gemm/2d
rm -rf csrc/autogen/src/cuda/gemm/2d
python3 scripts/autogen_cuda_gemm_2d.py --max-kernel-size 67
And then build from source. But from the looks of it, you'll need to figure out the cmake issue first. I'd recommend trying installing the cuda toolkit with anaconda or use a docker image.
Thanks! Some backbones (MViT, SAM) use the rel_pos_bias different from the rpb. How should I solve this problem?
I'm not sure I understand; if it's a relative positional bias, it should be dependent on the attention pattern, not model, so you'd use the RPB in NATTEN. However, I wouldn't use RPB or any explicit biasing of attention weights. There's better alternatives that are more easily computable.
It's been a while since I looked at this issue. Are you still having issues?
`guantongkun in 🌐 DVLab-1 in NATTEN on main via 🐍 v3.8.19 via 🅒 BA-SAM took 2s ❯ make Cleaning up rm -rf dist/ rm -rf natten.egg-info/ rm -rf src/natten/_C. rm -rf src/natten/libnatten. rm -rf pycache rm -rf tests/pycache rm -rf src/pycache rm -rf src/natten/pycache rm -rf src/natten.egg rm -rf install.out Uninstalling NATTEN pip uninstall -y natten WARNING: Skipping natten as it is not installed. Fetching all third party submodules git submodule update --init --recursive Installing NATTEN from source NATTEN_CUDA_ARCH="" \ NATTEN_N_WORKERS="" \ NATTEN_WITH_CUDA="" \ NATTEN_VERBOSE="" \ pip install -v -e . 2>&1 | tee install.out Using pip 24.0 from /home/guantongkun/.conda/envs/BA-SAM/lib/python3.8/site-packages/pip (python 3.8) Obtaining file:///home/guantongkun/TS/NATTEN Preparing metadata (setup.py): started Running command python setup.py egg_info Building NATTEN with CUDA 118 Building NATTEN for SM: 8.6 Number of workers: 18 running egg_info creating /tmp/pip-pip-egg-info-rkgk5ssc/natten.egg-info writing /tmp/pip-pip-egg-info-rkgk5ssc/natten.egg-info/PKG-INFO writing dependency_links to /tmp/pip-pip-egg-info-rkgk5ssc/natten.egg-info/dependency_links.txt writing requirements to /tmp/pip-pip-egg-info-rkgk5ssc/natten.egg-info/requires.txt writing top-level names to /tmp/pip-pip-egg-info-rkgk5ssc/natten.egg-info/top_level.txt writing manifest file '/tmp/pip-pip-egg-info-rkgk5ssc/natten.egg-info/SOURCES.txt' reading manifest file '/tmp/pip-pip-egg-info-rkgk5ssc/natten.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching '.cc' under directory 'csrc' warning: no files found matching '.cpp' under directory 'third_party/cutlass/include' warning: no files found matching '.cuh' under directory 'third_party/cutlass/include' warning: no files found matching '.cu' under directory 'third_party/cutlass/include' warning: no files found matching '.txt' under directory 'third_party/cutlass/include' warning: no files found matching '*.cc' under directory 'third_party/cutlass/include' no previously-included directories found matching 'webpage/' no previously-included directories found matching 'tools/' no previously-included directories found matching 'scripts/' adding license file 'LICENSE' writing manifest file '/tmp/pip-pip-egg-info-rkgk5ssc/natten.egg-info/SOURCES.txt' Preparing metadata (setup.py): finished with status 'done' Requirement already satisfied: packaging in /home/guantongkun/.conda/envs/BA-SAM/lib/python3.8/site-packages (from natten==0.17.1) (24.0) Requirement already satisfied: torch>=2.0.0 in /home/guantongkun/.conda/envs/BA-SAM/lib/python3.8/site-packages (from natten==0.17.1) (2.0.0+cu118) Requirement already satisfied: filelock in /home/guantongkun/.conda/envs/BA-SAM/lib/python3.8/site-packages (from torch>=2.0.0->natten==0.17.1) (3.13.1) Requirement already satisfied: typing-extensions in /home/guantongkun/.conda/envs/BA-SAM/lib/python3.8/site-packages (from torch>=2.0.0->natten==0.17.1) (4.9.0) Requirement already satisfied: sympy in /home/guantongkun/.conda/envs/BA-SAM/lib/python3.8/site-packages (from torch>=2.0.0->natten==0.17.1) (1.12) Requirement already satisfied: networkx in /home/guantongkun/.conda/envs/BA-SAM/lib/python3.8/site-packages (from torch>=2.0.0->natten==0.17.1) (3.0) Requirement already satisfied: jinja2 in /home/guantongkun/.conda/envs/BA-SAM/lib/python3.8/site-packages (from torch>=2.0.0->natten==0.17.1) (3.1.3) Requirement already satisfied: triton==2.0.0 in /home/guantongkun/.conda/envs/BA-SAM/lib/python3.8/site-packages (from torch>=2.0.0->natten==0.17.1) (2.0.0) Requirement already satisfied: cmake in /home/guantongkun/.conda/envs/BA-SAM/lib/python3.8/site-packages (from triton==2.0.0->torch>=2.0.0->natten==0.17.1) (3.25.0) Requirement already satisfied: lit in /home/guantongkun/.conda/envs/BA-SAM/lib/python3.8/site-packages (from triton==2.0.0->torch>=2.0.0->natten==0.17.1) (15.0.7) Requirement already satisfied: MarkupSafe>=2.0 in /home/guantongkun/.conda/envs/BA-SAM/lib/python3.8/site-packages (from jinja2->torch>=2.0.0->natten==0.17.1) (2.1.5) Requirement already satisfied: mpmath>=0.19 in /home/guantongkun/.conda/envs/BA-SAM/lib/python3.8/site-packages (from sympy->torch>=2.0.0->natten==0.17.1) (1.3.0) Installing collected packages: natten Running setup.py develop for natten Running command python setup.py develop Building NATTEN with CUDA 118 Building NATTEN for SM: 8.6 Number of workers: 18 running develop running egg_info creating src/natten.egg-info writing src/natten.egg-info/PKG-INFO writing dependency_links to src/natten.egg-info/dependency_links.txt writing requirements to src/natten.egg-info/requires.txt writing top-level names to src/natten.egg-info/top_level.txt writing manifest file 'src/natten.egg-info/SOURCES.txt' reading manifest file 'src/natten.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' /home/guantongkun/.conda/envs/BA-SAM/lib/python3.8/site-packages/setuptools/command/develop.py:40: EasyInstallDeprecationWarning: easy_install command is deprecated. !!
error: subprocess-exited-with-error
× python setup.py develop 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. `