JavaScriptを有効にしてください

MambaをPoetryで管理する

 ·  ☕ 1 min read

リンク集

備忘録

  • mamba-ssmcausal-conv1dがPEP517に準拠していないのでpoetry add <package-name>だとインスコできない
    • poetry add <path>でもsetup.py読んでくれないからムリ
  • → 無理やりローカルでwheelを作ってpoetry addすればOK
    • python setup.py bdist_wheel

一例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#!/bin/bash
set -e # Exit immediately if a command exits with a non-zero status.

which python || exit 1
pip install poetry || exit 1
poetry source add torch_cu118 --priority=explicit https://download.pytorch.org/whl/cu118 || exit 1
poetry source add pyg_cu118 --priority=explicit https://data.pyg.org/whl/torch-2.0.0+cu118.html || exit 1

poetry install || exit 1

for package in "causal-conv1d" "mamba"
do
    cd $package
    python setup.py bdist_wheel
    wheel_path=$(find `pwd` -name "*.whl" | grep linux)
    cd ../
    poetry add $wheel_path
done

For English speakers

When managing Mamba with Poetry, there are some complications to be aware of. Mamba, which refers to “Linear-Time Sequence Modeling with Selective State Spaces” (you can find the paper at https://arxiv.org/abs/2312.00752 ), and its associated repositories (https://github.com/state-spaces/mamba and https://github.com/Dao-AILab/causal-conv1d ) present challenges when using Poetry for package management.

The issue arises because mamba-ssm and causal-conv1d are not compliant with PEP 517. This means you can’t install them using the standard poetry add <package-name> command. Furthermore, attempting to add them via poetry add <path> doesn’t work either, as this method does not execute setup.py.

I found a workaround: you can manually build a wheel for the package locally and then add it to your project using Poetry. This can be done by running python setup.py bdist_wheel. This process creates a wheel file, which can then be successfully added to your project with Poetry.

共有

YuWd (Yuiga Wada)
著者
YuWd (Yuiga Wada)
機械学習・競プロ・iOS・Web