1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【tips】detectron2 のビルドに失敗するとき

Posted at

【tips】Detectron2 のビルドに失敗するとき

torch が入っているのに Detectron2 のインストールに失敗するときの覚書です

事象

Python で Detectron2 を入れようとすると torch が無いと言われビルドが失敗する.
pip install で pytorch をあらかじめ入れていても失敗する.

$ python -c "import torch; print(torch.__version__)"
2.2.2

$ python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'

...
ModuleNotFoundError: No module named 'torch'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

原因

ビルド時の挙動として,一旦ビルド用の仮想環境を作成してビルドを行う.
その中に torch が無いため失敗する.

解決策

--no-build-isolation をつけて pip する.

$ python -m pip install 'git+https://github.com/facebookresearch/detectron2.git' --no-build-isolation

これにより今使用している環境を使ってビルドしてくれる.
そのため,既に torch を入れていれば問題なく Detectron2 のビルド・インストールができるようになる.

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?