Tried to access nonexistent attribute or method 'crow_indices' of type 'Tensor'.: File "/home/yjy/anaconda3/envs/MATP/lib/python3.7/site-packages/torch_sparse/tensor.py", line 109 def from_torch_sparse_csr_tensor(self, mat: torch.Tensor, has_value: bool = True): rowptr = mat.crow_indices() ~~~~~~~~~~~~~~~~ <--- HERE col = mat.col_indices()
时间: 2023-10-21 20:05:25 浏览: 441
根据提供的错误信息,出现了一个关于Tensor的错误。具体地说,它试图访问一个名为'crow_indices'的属性或方法,但在Tensor类型中并不存在该属性或方法。
这个问题可能是由于以下几种情况导致的:
1. 版本不兼容:请确保你正在使用与torch_sparse库兼容的torch版本。尝试更新torch_sparse库或降级torch版本,看看是否解决了问题。
2. 引入错误:检查你的代码,确保正确导入了torch_sparse库以及所有必需的依赖项。
3. API变更:如果你的代码是基于旧版本的torch_sparse编写的,在新版本中可能已经发生了一些API变更。请查阅torch_sparse的文档或相关更新日志,了解这些变更,并相应地修改你的代码。
如果上述方法都没有解决问题,我建议你将完整的错误信息和相关的代码片段提交给torch_sparse库的开发者或社区,以获取更具体的帮助和支持。
相关问题
解析这个报错INTEL MKL ERROR: dlopen(/Users/baiminchen/opt/anaconda3/lib/libmkl_core.1.dylib, 0x0009): tried: '/Users/baiminchen/opt/anaconda3/lib/libmkl_core.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/baiminchen/opt/anaconda3/lib/libmkl_core.1.dylib' (no such file), '/Users/baiminchen/opt/anaconda3/lib/libmkl_core.1.dylib' (no such file). Intel MKL FATAL ERROR: Cannot load libmkl_core.1.dylib. Traceback (most recent call last): File "/Users/baiminchen/opt/anaconda3/lib/python3.9/site-packages/PyInstaller/isolated/_parent.py", line 373, in call return isolated.call(function, *args, **kwargs) File "/Users/baiminchen/opt/anaconda3/lib/python3.9/site-packages/PyInstaller/isolated/_parent.py", line 302, in call ok, output = loads(b64decode(self._read_handle.readline())) EOFError: EOF read where object expected During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/baiminchen/opt/anaconda3/bin/pyinstaller", line 8, in <module> sys.exit(_console_script_run()) File "/Users/baiminchen/opt/anaconda3/lib/python3.9/site-packages/PyInstaller/__main__.py", line 194, in _console_script_run run() File "/Users/baiminchen/opt/anaconda3/lib/python3.9/site-packages/PyInstaller/__main__.py", line 180, in run run_build(pyi_config, spec_file, **vars(args)) File "/Users/baiminchen/opt/anaconda3/lib/python3.9/site-packages/PyInstaller/__main__.py", line 61, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "/Users/baiminchen/opt/anaconda3/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 971, in main build(specfile, distpath, workpath, clean_build) File "/Users/baiminchen/opt/anaconda3/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 893, in build exec(code, spec_namespace) File "/Users/baiminchen/Desktop/database of xinstitute/main.spec", line 7, in <module> a = Analysis( File "/Users/baiminchen/opt/anaconda3/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 378, in __init__ self.hookspath += discover_hook_directories() File "/Users/baiminchen/opt/anaconda3/lib/python3.9/site-packages/PyInstaller/isolated/_parent.py", line 404, in wrapped return call(function, *args, **kwargs) File "/Users/baiminchen/opt/anaconda3/lib/python3.9/site-packages/PyInstaller/isolated/_parent.py", line 373, in call return isolated.call(function, *args, **kwargs) File "/Users/baiminchen/opt/anaconda3/lib/python3.9/site-packages/PyInstaller/isolated/_parent.py", line 244, in __exit__ self._write_handle.flush() BrokenPipeError: [Errno 32] Broken pipe
这个错误是在使用 PyInstaller 工具时出现的,它是一个用于将 Python 程序打包为单个可执行文件的工具。这个错误提示中有一行提到了 Intel MKL,MKL 是 Intel Math Kernel Library 的缩写,是一个优化的数学函数库。
错误信息表明 PyInstaller 在尝试加载 Intel MKL 库文件 libmkl_core.1.dylib 时失败了,并且指出了找不到这个文件。这通常是因为该文件在本机上没有安装或者安装路径不正确。你需要检查你的系统中是否已经正确安装了 Intel MKL,或者尝试重新安装它。
如果你确定 Intel MKL 已经安装,那么你可能需要检查 PyInstaller 脚本中的路径是否正确。这个错误信息中还提到了文件 main.spec,这是 PyInstaller 生成的一个配置文件,你可以在其中指定 Intel MKL 的安装路径。
import osos.environ['DYLD_LIBRARY_PATH']='/usr/local/opt/libomp/lib'import lightgbm as lgb dlopen(/Users/sentianzhenping/opt/anaconda3/lib/python3.9/site-packages/lightgbm/lib_lightgbm.so, 0x0006): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib Referenced from: /Users/sentianzhenping/opt/anaconda3/lib/python3.9/site-packages/lightgbm/lib_lightgbm.so Reason: tried: '/usr/local/opt/libomp/lib/libomp.dylib' (no such file), '/usr/local/lib/libomp.dylib' (no such file), '/usr/lib/libomp.dylib' (no such file)
你需要将设置 `DYLD_LIBRARY_PATH` 的代码放在 `import lightgbm` 语句之前。请修改代码如下:
```python
import os
os.environ['DYLD_LIBRARY_PATH']='/usr/local/opt/libomp/lib'
import lightgbm as lgb
```
这样就先设置好了 `DYLD_LIBRARY_PATH` 环境变量,然后再导入 LightGBM 库,就可以顺利加载共享库了。
阅读全文