hustvl / Vim

Vision Mamba: Efficient Visual Representation Learning with Bidirectional State Space Model
Apache License 2.0
2.55k stars 159 forks source link

Run the test code successfully, share my environment. #53

Closed poult-lab closed 2 weeks ago

poult-lab commented 3 months ago

Hello every researcher, I have researched this code for 3 day, Finally, I can run the test code successfully. below is the test code. `import torch from mamba_ssm import Mamba

batch, length, dim = 2, 64, 16 print(torch.cuda.is_available()) x = torch.randn(batch, length, dim).to("cuda") model = Mamba(

This module uses roughly 3 expand d_model^2 parameters

d_model=dim, # Model dimension d_model
d_state=16,  # SSM state expansion factor
d_conv=4,    # Local convolution width
expand=2,    # Block expansion factor

).to("cuda") y = model(x) assert y.shape == x.shape`

Therefore, I would like to share my experiments to help those people are still struggling for the problem of setting environment.
my syetem: **Ubuntu 22.04 nvidia driver 535 (if you don't know how to upgrade or downgrade your nvidia-driver, you can leave a message here) CUDA 11.8 (downloaded run file from official website, but before install the cuda 11.8. we should have gcc installed. we can easily use the code to install 'sudo apt install build-essential' gcc )

python 3.10.13 (installed via conda ) pytorch 2.2.2 (installed via conda, hint: here must install 2.2.2, not another version) causal-conv1d-1.1.3.post1( installed via pip install causal-conv1d==1.1.3.post1) mamba_ssm(installed via author provided file cd mamba-1p1p1/ pip install -e .)** Hint: please install g++ in advance if you haven't it.

poult-lab commented 3 months ago

if you encounter some warnings like this : UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead. _torch_pytree._register_pytree_node(

you can try to use below code to solve this issue:

pip install --upgrade transformers

Medallion11 commented 3 months ago

Thanks for the solution! But i encountered another problem when i running the bash train code: CUDA_VISIBLE_DEVICES=5 torchrun --master_port=6666 --nproc_per_node=1 main.py --model vim_small_patch16_224_bimambav2_final_pool_mean_abs_pos_embed_with_midclstok_div2 --batch-size 2 --drop-path 0.05 --weight-decay 0.05 --lr 1e-3 --num_workers 1 --data-set CIFAR --data-path /data/nvme0/cifar100 --output_dir ./output/vim_small_patch16_224_bimambav2_final_pool_mean_abs_pos_embed_with_midclstok_div2 --no_amp

TypeError: causal_conv1d_fwd(): incompatible function arguments. The following argument types are supported:

Medallion11 commented 3 months ago

Thanks for the solution! But i encountered another problem when i running the bash train code: CUDA_VISIBLE_DEVICES=5 torchrun --master_port=6666 --nproc_per_node=1 main.py --model vim_small_patch16_224_bimambav2_final_pool_mean_abs_pos_embed_with_midclstok_div2 --batch-size 2 --drop-path 0.05 --weight-decay 0.05 --lr 1e-3 --num_workers 1 --data-set CIFAR --data-path /data/nvme0/cifar100 --output_dir ./output/vim_small_patch16_224_bimambav2_final_pool_mean_abs_pos_embed_with_midclstok_div2 --no_amp

TypeError: causal_conv1d_fwd(): incompatible function arguments. The following argument types are supported:

i figured it out, but i change to install causal_conv1d-1.1.3 and mamba_ssm-1.1.1. the key problem is Incompatible version between causal_conv1d and mamba_ssm. whatever thank you!

poult-lab commented 2 months ago

actually I've encounter this problem from models_mamba.py TypeError: Mamba.init() got an unexpected keyword argument 'bimamba_type' I think the reason is that the author of vim has modified this file, it means if we want to run this code properly we have to install the mamba_ssm from receipt which is author provided. You can find the solution from https://github.com/hustvl/Vim/issues/14, cd mamba-1p1p1/ pip install -e .

By the way, if we install the mamba_ssm which is provided by author, the test code won't run. If anyone can find a solution to make the test code running based on the mamba_ssm which is provided by author, you can leave your solution here.

poult-lab commented 2 months ago

actually I've encounter this problem from models_mamba.py TypeError: Mamba.init() got an unexpected keyword argument 'bimamba_type' I think the reason is that the author of vim has modified this file, it means if we want to run this code properly we have to install the mamba_ssm from receipt which is author provided. You can find the solution from #14, cd mamba-1p1p1/ pip install -e .

By the way, if we install the mamba_ssm which is provided by author, the test code won't run. If anyone can find a solution to make the test code running based on the mamba_ssm which is provided by author, you can leave your solution here.

I have re-install the causal-conv1d via causal-conv1d-1.1.3.post1, and the test code is able to run as well.

xianfeizhu commented 2 months ago

I encountered another problem when i running the bash train code: self.mixer = mixer_cls(dim) TypeError: Mamba.init() got an unexpected keyword argument 'bimamba_type' Have you ever encountered this problem? Do you know how to solve it?

abc-132 commented 1 month ago

Hello, in my environment “causal_conv1d_cuda“ can't be imported ,do you encount the same problem? Do you know how to solve this problem ? If you can answer me ,i would thank you very much.

Laulen commented 2 weeks ago

感谢您的解决方案!但是我在运行bash训练代码时遇到了另一个问题: CUDA_VISIBLE_DEVICES=5 torchrun --master_port=6666 --nproc_per_node=1 main.py --model vim_small_patch16_224_bimambav2_final_pool_mean_abs_pos_embed_with_midclstok_div2 --batch-size 2 --drop-path 0.05 --weight-decay 0.05 --lr 1e-3 --num_workers 1 --data-set CIFAR --data-path /data/nvme0/cifar100 --output_dir ./output/vim_small_patch16_224_bimambav2_final_pool_mean_abs_pos_embed_with_midclstok_div2 --no_amp

TypeError:causal_conv1d_fwd():不兼容的函数参数。支持以下参数类型:

我也遇到了同样的问题

poult-lab commented 2 weeks ago

I encountered another problem when i running the bash train code: self.mixer = mixer_cls(dim) TypeError: Mamba.init() got an unexpected keyword argument 'bimamba_type' Have you ever encountered this problem? Do you know how to solve it?

actually the author of Vim edited the code of Mamba, therefore we have to follow the instruction from vim's author

poult-lab commented 2 weeks ago

Hello, in my environment “causal_conv1d_cuda“ can't be imported ,do you encount the same problem? Do you know how to solve this problem ? If you can answer me ,i would thank you very much.

hello, I think it will working properly if you follow the steps that are provided by me.

poult-lab commented 2 weeks ago

感谢您的解决方案!但是我在运行bash训练代码时遇到了另一个问题: CUDA_VISIBLE_DEVICES=5 torchrun --master_port=6666 --nproc_per_node=1 main.py --model vim_small_patch16_224_bimambav2_final_pool_mean_abs_pos_embed_with_midclstok_div2 --batch-size 2 --drop-path 0.05 --weight-decay 0.05 --lr 1e-3 --num_workers 1 --data-set CIFAR --data-path /data/nvme0/cifar100 --output_dir ./output/vim_small_patch16_224_bimambav2_final_pool_mean_abs_pos_embed_with_midclstok_div2 --no_amp TypeError:causal_conv1d_fwd():不兼容的函数参数。支持以下参数类型:

我也遇到了同样的问题

您好, 您可能没有把vim的包安装好。