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

ModuleNotFoundError: No module named 'selective_scan_cuda' #55

Closed
DianCh opened this issue Feb 27, 2024 · 27 comments
Closed

ModuleNotFoundError: No module named 'selective_scan_cuda' #55

DianCh opened this issue Feb 27, 2024 · 27 comments

Comments

@DianCh
Copy link

DianCh commented Feb 27, 2024

Hi! I followed the instructions for installation, and after cd selective_scan && pip install . I can successfully import selective_scan but not other functions:

root@ip-10-242-7-67:/workspace/vmamba/selective_scan# pip install .                                                                                                                                                                                                 [41/1909]
Processing /workspace/vmamba/selective_scan                                                                                                                                                                                                                                  
  Preparing metadata (setup.py) ... done                                                                                                                                                                                                                                     
Requirement already satisfied: torch in /opt/conda/lib/python3.10/site-packages (from selective-scan==0.0.2) (2.0.1)                                                                                                                                                         
Requirement already satisfied: packaging in /opt/conda/lib/python3.10/site-packages (from selective-scan==0.0.2) (23.0)                                                                                                                                                      
Requirement already satisfied: ninja in /opt/conda/lib/python3.10/site-packages (from selective-scan==0.0.2) (1.11.1.1)                                                                                                                                                      
Requirement already satisfied: einops in /opt/conda/lib/python3.10/site-packages (from selective-scan==0.0.2) (0.4.1)                                                                                                                                                        
Requirement already satisfied: filelock in /opt/conda/lib/python3.10/site-packages (from torch->selective-scan==0.0.2) (3.9.0)                                                                                                                                               
Requirement already satisfied: typing-extensions in /opt/conda/lib/python3.10/site-packages (from torch->selective-scan==0.0.2) (4.5.0)                                                                                                                                      
Requirement already satisfied: sympy in /opt/conda/lib/python3.10/site-packages (from torch->selective-scan==0.0.2) (1.12)                                                                                                                                                   
Requirement already satisfied: networkx in /opt/conda/lib/python3.10/site-packages (from torch->selective-scan==0.0.2) (3.1)                                                                                                                                                 
Requirement already satisfied: jinja2 in /opt/conda/lib/python3.10/site-packages (from torch->selective-scan==0.0.2) (3.1.2)                                                                                                                                                 
Requirement already satisfied: MarkupSafe>=2.0 in /opt/conda/lib/python3.10/site-packages (from jinja2->torch->selective-scan==0.0.2) (2.1.1)                                                                                                                                
Requirement already satisfied: mpmath>=0.19 in /opt/conda/lib/python3.10/site-packages (from sympy->torch->selective-scan==0.0.2) (1.3.0)                                                                                                                                    
Building wheels for collected packages: selective-scan                                                                                                                                                                                                                       
  Building wheel for selective-scan (setup.py) ... done                                                                                                                                                                                                                      
  Created wheel for selective-scan: filename=selective_scan-0.0.2-cp310-cp310-linux_x86_64.whl size=57684805 sha256=3a2511a0005cf3b9117ff3f4633c89ccf17dbc248573d66c52a207357af648e7                                                                                         
  Stored in directory: /tmp/pip-ephem-wheel-cache-3rb5jl53/wheels/53/a3/04/de2aa7777fc2474de84837455e0fb9151192630629aba26666
Successfully built selective-scan
Installing collected packages: selective-scan
  Attempting uninstall: selective-scan
    Found existing installation: selective-scan 0.0.2
    Uninstalling selective-scan-0.0.2:
      Successfully uninstalled selective-scan-0.0.2
Successfully installed selective-scan-0.0.2

root@ip-10-242-7-67:/workspace/vmamba# python
Python 3.10.11 (main, Apr 20 2023, 19:02:41) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import selective_scan
>>> import selective_scan_core
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'selective_scan_core'
>>> import selective_scan_cuda
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'selective_scan_cuda'
>>> import selective_scan_cuda_test
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'selective_scan_cuda_test'

What's the fix? Thank you.

@MzeroMiko
Copy link
Owner

There's no module selective_scan_cuda, selective_scan_core or selective_scan_cuda_test in our project. We only have selective_scan_cuda_core, selective_scan_cuda_oflex and selective_scan_cuda_nrow. And all those versions have only slight difference.

@DianCh
Copy link
Author

DianCh commented Feb 27, 2024

I was trying to run pytest selective_scan/test_selective_scan.py:

________________________________________________________________________________________________________ ERROR collecting test_selective_scan.py ________________________________________________________________________________________________________
ImportError while importing test module '/workspace/vmamba/selective_scan/test_selective_scan.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/conda/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
selective_scan/test_selective_scan.py:349: in <module>
    import selective_scan_cuda
E   ModuleNotFoundError: No module named 'selective_scan_cuda'

which imports selective_scan_cuda and selective_scan_cuda_test.

In classification/models/vmamba.py there's also selective_scan_cuda. Why do I not have the module?

@MzeroMiko
Copy link
Owner

It is optional, without selective_scan_cuda, the model runs well too.

Check Selective Scan (optional)

  • If you want to check if the implementation of selective scan of ours is the same with mamba_ssm, selective_scan/test_selective_scan.py is here for you. Change to MODE = "mamba_ssm_sscore" in selective_scan/test_selective_scan.py, and run pytest selective_scan/test_selective_scan.py.

  • If you want to check if the implementation of selective scan of ours is the same with reference code (selective_scan_ref), change to MODE = "sscore" in selective_scan/test_selective_scan.py, and run pytest selective_scan/test_selective_scan.py.

  • MODE = "mamba_ssm" stands for checking whether the results of mamba_ssm is close to selective_scan_ref, and "sstest" is preserved for development.

  • If you find mamba_ssm (selective_scan_cuda) or selective_scan ( selctive_scan_cuda_core) is not close enough to selective_scan_ref, and the test failed, do not worry. Check if mamba_ssm and selective_scan are close enough instead.

  • If you are interested in selective scan, you can check mamba, mamba-mini, mamba.py mamba-minimal for more information.

@DianCh
Copy link
Author

DianCh commented Feb 27, 2024

Got it! Thank you. What are these selective_scan_ref functions defined in test_selective_scan.py`?

def selective_scan_ref(u, delta, A, B, C, D=None, z=None, delta_bias=None, delta_softplus=False,
                      return_last_state=False):

def selective_scan_ref_v2(u, delta, A, B, C, D=None, z=None, delta_bias=None, delta_softplus=False,
                      return_last_state=False):

@MzeroMiko
Copy link
Owner

They are supposed to be the very simple version of selctive_scan_cuda, but are not exactly the same due to precision issues. Thay are slow.

@DianCh
Copy link
Author

DianCh commented Feb 27, 2024

Thanks! Closing this.

@DianCh DianCh closed this as completed Feb 27, 2024
@CF-KM
Copy link

CF-KM commented Apr 11, 2024

Hi! You said 'We only have selective_scan_cuda_core, selective_scan_cuda_oflex and selective_scan_cuda_nrow.' But I couldn't import selective_scan_cuda_oflex or selective_scan_cuda_core. It shows that 'NameError: name 'selective_scan_cuda_oflex' is not defined'. What's the fix? Thank you!

@liuchengzhi314159
Copy link

Hello, please, what if I want to run your sample program on Windows? My computer is an rtx 2060 laptop. The teacher has no fucking money and can't provide a server.

@MzeroMiko
Copy link
Owner

Hello, please, what if I want to run your sample program on Windows? My computer is an rtx 2060 laptop. The teacher has no fucking money and can't provide a server.

have you tried the solution in issue #95 ?

@liuchengzhi314159
Copy link

liuchengzhi314159 commented Apr 17, 2024 via email

@MzeroMiko
Copy link
Owner

the selective scan in vmamba do support cuda version under cuda11.6. You can try lower version of cuda then, if cuda11.6 is too high for your device.

@liuchengzhi314159
Copy link

liuchengzhi314159 commented Apr 18, 2024 via email

@0130wangjiashu
Copy link

He
1
2
llo,dear Hello dear VMamba author of this paper, I always get three errors when trying to run a vmamba.py file in the classfication folder。selective_scan_cuda_oflex;Such as @selective_scan_cuda_core;selective_scan_cuda,none of these three packages are available。 @MzeroMiko

@AliasChenYi
Copy link

They are supposed to be the very simple version of selctive_scan_cuda, but are not exactly the same due to precision issues. Thay are slow.

image
What can I replace this with? Because I didn't find the module

@MzeroMiko
Copy link
Owner

Have you solved it ?

Maybe you can not find the module selective_scan_cuda_oflex, mainly because that you did not install kernel/selective_scan.

@AliasChenYi
Copy link

AliasChenYi commented Jun 4, 2024 via email

@Elaineok
Copy link

Elaineok commented Jun 5, 2024

2024-06-06 11 58 19
state-spaces/mamba#169

I have been successfully run. Environment follows:

Python 3.10.14
cuda 12.1
pytorch 2.2.2
causal-conv1d 1.2.2.post1
mamba-ssm 2.0.3

conda create -n myenv python=3.10.14
source activate myenv
conda install pytorch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 pytorch-cuda=12.1 -c pytorch -c nvidia

pip install causal_conv1d-1.2.2.post1+cu122torch2.2cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
pip install mamba_ssm-2.0.3+cu122torch2.2cxx11abiFALSE-cp310-cp310-linux_x86_64.whl

causal_conv can also be downloaded by searching pypi causal_conv, python setup.py installation
mamba_ssm only supports whl installation

(maba2) jt2@ubuntu:/data3/jt2$ pip list
Package Version


Brotli 1.0.9
causal-conv1d 1.2.2.post1
certifi 2024.2.2
charset-normalizer 2.0.4
einops 0.8.0
filelock 3.13.1
fsspec 2024.6.0
gmpy2 2.1.2
huggingface-hub 0.23.3
idna 3.7
Jinja2 3.1.4
mamba-ssm 2.0.3
MarkupSafe 2.1.3
mkl-fft 1.3.8
mkl-random 1.2.4
mkl-service 2.4.0
mpmath 1.3.0
networkx 3.1
ninja 1.11.1.1
numpy 1.26.4
packaging 24.0
pillow 10.3.0
pip 24.0
PySocks 1.7.1
PyYAML 6.0.1
regex 2024.5.15
requests 2.32.2
safetensors 0.4.3
setuptools 69.5.1
sympy 1.12
tokenizers 0.19.1
torch 2.2.2
torchaudio 2.2.2
torchvision 0.17.2
tqdm 4.66.4
transformers 4.41.2
triton 2.2.0
typing_extensions 4.11.0
urllib3 2.2.1
wheel 0.43.0

(maba2) jt2@ubuntu:/data3/jt2$ conda list

packages in environment at /home/jt2/anaconda3/envs/maba2:

Name Version Build Channel

_libgcc_mutex 0.1 main defaults
_openmp_mutex 5.1 1_gnu defaults
blas 1.0 mkl defaults
brotli-python 1.0.9 py310h6a678d5_8 defaults
bzip2 1.0.8 h5eee18b_6 defaults
ca-certificates 2024.3.11 h06a4308_0 defaults
causal-conv1d 1.2.2.post1 pypi_0 pypi
certifi 2024.2.2 py310h06a4308_0 defaults
charset-normalizer 2.0.4 pyhd3eb1b0_0 defaults
cuda-cudart 12.1.105 0 nvidia
cuda-cupti 12.1.105 0 nvidia
cuda-libraries 12.1.0 0 nvidia
cuda-nvrtc 12.1.105 0 nvidia
cuda-nvtx 12.1.105 0 nvidia
cuda-opencl 12.5.39 0 nvidia
cuda-runtime 12.1.0 0 nvidia
cuda-version 12.5 3 nvidia
einops 0.8.0 pypi_0 pypi
ffmpeg 4.3 hf484d3e_0 pytorch
filelock 3.13.1 py310h06a4308_0 defaults
freetype 2.12.1 h4a9f257_0 defaults
fsspec 2024.6.0 pypi_0 pypi
gmp 6.2.1 h295c915_3 defaults
gmpy2 2.1.2 py310heeb90bb_0 defaults
gnutls 3.6.15 he1e5248_0 defaults
huggingface-hub 0.23.3 pypi_0 pypi
idna 3.7 py310h06a4308_0 defaults
intel-openmp 2023.1.0 hdb19cb5_46306 defaults
jinja2 3.1.4 py310h06a4308_0 defaults
jpeg 9e h5eee18b_1 defaults
lame 3.100 h7b6447c_0 defaults
lcms2 2.12 h3be6417_0 defaults
ld_impl_linux-64 2.38 h1181459_1 defaults
lerc 3.0 h295c915_0 defaults
libcublas 12.1.0.26 0 nvidia
libcufft 11.0.2.4 0 nvidia
libcufile 1.10.0.4 0 nvidia
libcurand 10.3.6.39 0 nvidia
libcusolver 11.4.4.55 0 nvidia
libcusparse 12.0.2.55 0 nvidia
libdeflate 1.17 h5eee18b_1 defaults
libffi 3.4.4 h6a678d5_1 defaults
libgcc-ng 11.2.0 h1234567_1 defaults
libgomp 11.2.0 h1234567_1 defaults
libiconv 1.16 h5eee18b_3 defaults
libidn2 2.3.4 h5eee18b_0 defaults
libjpeg-turbo 2.0.0 h9bf148f_0 pytorch
libnpp 12.0.2.50 0 nvidia
libnvjitlink 12.1.105 0 nvidia
libnvjpeg 12.1.1.14 0 nvidia
libpng 1.6.39 h5eee18b_0 defaults
libstdcxx-ng 11.2.0 h1234567_1 defaults
libtasn1 4.19.0 h5eee18b_0 defaults
libtiff 4.5.1 h6a678d5_0 defaults
libunistring 0.9.10 h27cfd23_0 defaults
libuuid 1.41.5 h5eee18b_0 defaults
libwebp-base 1.3.2 h5eee18b_0 defaults
llvm-openmp 14.0.6 h9e868ea_0 defaults
lz4-c 1.9.4 h6a678d5_1 defaults
mamba-ssm 2.0.3 pypi_0 pypi
markupsafe 2.1.3 py310h5eee18b_0 defaults
mkl 2023.1.0 h213fc3f_46344 defaults
mkl-service 2.4.0 py310h5eee18b_1 defaults
mkl_fft 1.3.8 py310h5eee18b_0 defaults
mkl_random 1.2.4 py310hdb19cb5_0 defaults
mpc 1.1.0 h10f8cd9_1 defaults
mpfr 4.0.2 hb69a4c5_1 defaults
mpmath 1.3.0 py310h06a4308_0 defaults
ncurses 6.4 h6a678d5_0 defaults
nettle 3.7.3 hbbd107a_1 defaults
networkx 3.1 py310h06a4308_0 defaults
ninja 1.11.1.1 pypi_0 pypi
numpy 1.26.4 py310h5f9d8c6_0 defaults
numpy-base 1.26.4 py310hb5e798b_0 defaults
openh264 2.1.1 h4ff587b_0 defaults
openjpeg 2.4.0 h3ad879b_0 defaults
openssl 3.0.13 h7f8727e_2 defaults
packaging 24.0 pypi_0 pypi
pillow 10.3.0 py310h5eee18b_0 defaults
pip 24.0 py310h06a4308_0 defaults
pysocks 1.7.1 py310h06a4308_0 defaults
python 3.10.14 h955ad1f_1 defaults
pytorch 2.2.2 py3.10_cuda12.1_cudnn8.9.2_0 pytorch
pytorch-cuda 12.1 ha16c6d3_5 pytorch
pytorch-mutex 1.0 cuda pytorch
pyyaml 6.0.1 py310h5eee18b_0 defaults
readline 8.2 h5eee18b_0 defaults
regex 2024.5.15 pypi_0 pypi
requests 2.32.2 py310h06a4308_0 defaults
safetensors 0.4.3 pypi_0 pypi
setuptools 69.5.1 py310h06a4308_0 defaults
sqlite 3.45.3 h5eee18b_0 defaults
sympy 1.12 py310h06a4308_0 defaults
tbb 2021.8.0 hdb19cb5_0 defaults
tk 8.6.14 h39e8969_0 defaults
tokenizers 0.19.1 pypi_0 pypi
torchaudio 2.2.2 py310_cu121 pytorch
torchtriton 2.2.0 py310 pytorch
torchvision 0.17.2 py310_cu121 pytorch
tqdm 4.66.4 pypi_0 pypi
transformers 4.41.2 pypi_0 pypi
typing_extensions 4.11.0 py310h06a4308_0 defaults
tzdata 2024a h04d1e81_0 defaults
urllib3 2.2.1 py310h06a4308_0 defaults
wheel 0.43.0 py310h06a4308_0 defaults
xz 5.4.6 h5eee18b_1 defaults
yaml 0.2.5 h7b6447c_0 defaults
zlib 1.2.13 h5eee18b_1 defaults
zstd 1.5.5 hc292b87_2 defaults

@shuodehaoa
Copy link

There's no module selective_scan_cuda, selective_scan_core or selective_scan_cuda_test in our project. We only have selective_scan_cuda_core, selective_scan_cuda_oflex and selective_scan_cuda_nrow. And all those versions have only slight difference.

I have successfully installed selective_scan 0.0.2, but I can only import selective_scan_cuda_oflex, and selective_scan_cuda_core shows no module, is it that this module is no longer supported?

image
image
image

@kgurnani
Copy link

I'm having the same problem too! I am using only VSSBlock, and not using vssm, there is no way to set a default selective scan module, I would like to use torch only, but it defaults to selective_scan_cuda_core.

Btw i have selective scan 0.0.2 installed too, when using only VSSBlock, it errors out because it doesn find it when calling something in csms6s.py

Does someone know how can I change the backend to mamba or torch?

@bryanbocao
Copy link

I tried both:

If you want to check the modules compared with mamba_ssm, install mamba_ssm first!

If you want to check if the implementation of selective scan of ours is the same with mamba_ssm, selective_scan/test_selective_scan.py is here for you. Change to MODE = "mamba_ssm_sscore" in selective_scan/test_selective_scan.py, and run pytest selective_scan/test_selective_scan.py.

If you want to check if the implementation of selective scan of ours is the same with reference code (selective_scan_ref), change to MODE = "sscore" in selective_scan/test_selective_scan.py, and run pytest selective_scan/test_selective_scan.py.

but still got this error:

VMamba/kernels# pytest selective_scan/test_selective_scan.py
================================================ test session starts =================================================platform linux -- Python 3.10.13, pytest-8.2.2, pluggy-1.5.0
rootdir: VMamba/kernels/selective_scan
plugins: hypothesis-6.87.1
collected 0 items / 1 error

======================================================= ERRORS =======================================================______________________________________ ERROR collecting test_selective_scan.py _______________________________________ImportError while importing test module 'VMamba/kernels/selective_scan/test_selective_scan.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/conda/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
selective_scan/test_selective_scan.py:331: in <module>
    import selective_scan_cuda_core
E   ModuleNotFoundError: No module named 'selective_scan_cuda_core'
============================================== short test summary info ===============================================ERROR selective_scan/test_selective_scan.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!================================================== 1 error in 1.33s ==================================================

@MzeroMiko Any help would be great.

@MzeroMiko
Copy link
Owner

selective_scan_cuda_core is deprecated, so use selective_scan_cuda_oflex instead.

@bryanbocao
Copy link

@MzeroMiko Thanks for the reply.

selective_scan_cuda_core is deprecated, so use selective_scan_cuda_oflex instead.

It's imported in the code. Any updated specific instructions? Or should we fix it ourselves and make a pull request?

@MzeroMiko
Copy link
Owner

No modification needed as core is aligned with oflex, they acts the same when the hyperparameter oflex equals false.

Also,all the models except for v2 (which is also deprecated,use v05 instead) uses oflex,or mamba for ablation.

@bryanbocao
Copy link

Sorry, it is still unclear to me in terms of the specific modifications. If we follow exactly the same instructions we will encounter the same issue again. Any specific instructions to install packages or hyperparameters when running a code would be helpful.

@MzeroMiko
Copy link
Owner

what's the hyperparameters you are using?

@bryanbocao
Copy link

bryanbocao commented Jul 28, 2024

I followed this one:

If you want to check if the implementation of selective scan of ours is the same with mamba_ssm, selective_scan/test_selective_scan.py is here for you. Change to MODE = "mamba_ssm_sscore" in selective_scan/test_selective_scan.py, and run pytest selective_scan/test_selective_scan.py.

@MzeroMiko
Copy link
Owner

So you want to check if everything is right? Then modify selective_scan_cuda_core to selective_scan_cuda_oflex.

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

No branches or pull requests

10 participants