torch-sparse安裝失敗分析
環境
- Linux: Ubuntu 16.04
- cuda: 9.0
- cudnn: 7.3.0
- pytorch: 1.1.0
- python: 3.6
- torch-geometric: 1.4.3
- torch-sparse報錯的版本:0.6.0
報錯內容
/tmp/pip-install-vjwvkdbw/torch-sparse/csrc/spspmm.cpp:33:5: **error: ‘RegisterOperators’ is not a member of ‘torch’**
torch::RegisterOperators().op("torch_sparse::spspmm_sum", &spspmm_sum);
^
struct TORCH_API **RegisterOperators** {
^
/tmp/pip-install-vjwvkdbw/torch-sparse/csrc/spspmm.cpp:32:13: warning: ‘registry’ defined but not used [-Wunused-variable]
static auto registry =
^
**error: command 'gcc' failed with exit status 1**
-----------------------------------------------------------------------
Command "/home/wb/miniconda3/envs/dl/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-vjwvkdbw/torch-sparse/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-_tbk9rnv/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-vjwvkdbw/torch-sparse/
原因分析
猜測1:難道是cuda版本太低?
分析:可是我的cuda版本肯定不能改啊,改了其他項目代碼不久崩了麼。想想其他辦法。
猜測2:pytorch版本太低?
分析:也不能改,太麻煩,其他代碼也依賴。
猜測3:torch-sparse版本太高?
分析:換成 0.4.4 ,pip install torch-sparse==0.4.4 哇,成功了!!!太棒了!!!
後記
後來又報其他的錯,我按照這個思路往低版本試,果然可以。
ModuleNotFoundError: No module named ‘torch_scatter’
pip install torch_geometric==1.4.1
pip install torch_sparse==0.4.4
pip install torch_scatter==1.4.0
pip install torch_cluster==1.4.5
後來我發現,這幾個庫都是一個哥們寫的。
我找到了他的github,並找到了這些庫每個版本的release記錄和日期。
https://github.com/rusty1s/pytorch_sparse/releases
這一個最難安裝的,版本0.4.4安裝成功了,發佈日期是2020/2/4 於是,我以這個時間節點爲基準,其他庫的發佈時間不能大於這個時間,不能會出現依賴問題。
按照這個思路很快,把這一堆包的安裝問題搞定了!!!
感覺自己是福爾摩斯!!!
https://github.com/rusty1s/pytorch_geometric/releases
https://github.com/rusty1s/pytorch_scatter/releases
https://github.com/rusty1s/pytorch_cluster/releases
更多內容,歡迎關注我的公衆號:AI分享者