0

我正在尝试在 Mac osx 计算机上开始使用 PyTorch。但是,基本步骤失败:

from torch_sparse import coalesce, SparseTensor

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-1-dad8246d5249> in <module>
----> 1 from torch_sparse import coalesce, SparseTensor

/usr/local/Caskroom/miniconda/base/envs/my_conda_env/lib/python3.8/site-packages/torch_sparse/__init__.py in <module>
     10         '_saint', '_padding'
     11 ]:
---> 12     torch.ops.load_library(importlib.machinery.PathFinder().find_spec(
     13         library, [osp.dirname(__file__)]).origin)
     14 

/usr/local/Caskroom/miniconda/base/envs/my_conda_env/lib/python3.8/site-packages/torch/_ops.py in load_library(self, path)
    102             # static (global) initialization code in order to register custom
    103             # operators with the JIT.
--> 104             ctypes.CDLL(path)
    105         self.loaded_libraries.add(path)
    106 

/usr/local/Caskroom/miniconda/base/envs/my_conda_env/lib/python3.8/ctypes/__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    371 
    372         if handle is None:
--> 373             self._handle = _dlopen(self._name, mode)
    374         else:
    375             self._handle = handle

OSError: dlopen(/usr/local/Caskroom/miniconda/base/envs/my_conda_env/lib/python3.8/site-packages/torch_sparse/_version.so, 6): Symbol not found: __ZN3c105ErrorC1ENS_14SourceLocationERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE
  Referenced from: /usr/local/Caskroom/miniconda/base/envs/my_conda_env/lib/python3.8/site-packages/torch_sparse/_version.so
  Expected in: flat namespace
 in /usr/local/Caskroom/miniconda/base/envs/my_conda_env/lib/python3.8/site-packages/torch_sparse/_version.so

我正在使用以下 conda 环境:

name: my_conda_env
channels:
  - pytorch
  - conda-forge
  - defaults
dependencies:
  - python>=3.8
  - pytorch
  - pytorch_geometric

并使用以下方法实例化它:

conda env create --force -f environment.yml
4

1 回答 1

0

https://github.com/rusty1s/pytorch_sparse/issues/135

确实,https://github.com/conda-forge/pytorch_sparse-feedstock/issues/13是问题使用 pip https://pytorch-geometric.readthedocs.io手动安装 pytorch 几何及其依赖项(例如 pytorch sparse)/en/latest/notes/installation.html是当前合适的解决方法

于 2021-05-09T11:16:04.187 回答