前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >成功解决 OSError: libcusparse.so.11: cannot open shared object file: No such file or directory

成功解决 OSError: libcusparse.so.11: cannot open shared object file: No such file or directory

作者头像
叶庭云
发布2022-10-25 18:30:56
4.4K0
发布2022-10-25 18:30:56
举报
文章被收录于专栏:Python进阶之路

新建一个干净的虚拟环境,安装配置 BIONIC

代码语言:javascript
复制
conda create -n BIONIC python=3.8
conda activate BIONIC


pip install torch-scatter==2.0.9 -f https://pytorch-geometric.com/whl/torch-1.9.0+cu111.html
pip install torch-cluster==1.5.9 -f https://pytorch-geometric.com/whl/torch-1.9.0+cu111.html
pip install torch-sparse==0.6.12 -f https://pytorch-geometric.com/whl/torch-1.9.0+cu111.html
pip install torch-spline-conv==1.2.1 -f https://pytorch-geometric.com/whl/torch-1.9.0+cu111.html
pip install torch-geometric==1.7.2 -f https://pytorch-geometric.com/whl/torch-1.9.0+cu111.html

pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

pip install https://github.com/bowang-lab/BIONIC/releases/download/v0.2.4/bionic_model-0.2.4+cu111-cp38-cp38-linux_x86_64.whl

然后执行 bionic --help 指令发生报错:

代码语言:javascript
复制
bionic --help
代码语言:javascript
复制
Traceback (most recent call last):
  File "/home/cenghaolong/anaconda3/envs/BIONIC/bin/bionic", line 5, in <module>
    from bionic.cli import main
  File "/home/cenghaolong/anaconda3/envs/BIONIC/lib/python3.8/site-packages/bionic/cli.py", line 4, in <module>
    from .train import Trainer
  File "/home/cenghaolong/anaconda3/envs/BIONIC/lib/python3.8/site-packages/bionic/train.py", line 18, in <module>
    from .utils.preprocessor import Preprocessor
  File "/home/cenghaolong/anaconda3/envs/BIONIC/lib/python3.8/site-packages/bionic/utils/preprocessor.py", line 17, in <module>
    from torch_geometric.transforms import ToSparseTensor
  File "/home/cenghaolong/anaconda3/envs/BIONIC/lib/python3.8/site-packages/torch_geometric/__init__.py", line 5, in <module>
    import torch_geometric.data
  File "/home/cenghaolong/anaconda3/envs/BIONIC/lib/python3.8/site-packages/torch_geometric/data/__init__.py", line 1, in <module>
    from .data import Data
  File "/home/cenghaolong/anaconda3/envs/BIONIC/lib/python3.8/site-packages/torch_geometric/data/data.py", line 8, in <module>
    from torch_sparse import coalesce, SparseTensor
  File "/home/cenghaolong/anaconda3/envs/BIONIC/lib/python3.8/site-packages/torch_sparse/__init__.py", line 15, in <module>
    torch.ops.load_library(importlib.machinery.PathFinder().find_spec(
  File "/home/cenghaolong/anaconda3/envs/BIONIC/lib/python3.8/site-packages/torch/_ops.py", line 104, in load_library
    ctypes.CDLL(path)
  File "/home/cenghaolong/anaconda3/envs/BIONIC/lib/python3.8/ctypes/__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libcusparse.so.11: cannot open shared object file: No such file or directory

具体情况是:安装了 torch-geometric 和 torch-sparse(官网安装说明:PyG Documentation — pytorch_geometric documentation)后,导入 torch-sparse 时却报错。

谷歌搜索啥的也没找到啥简洁有效解决方案,都是说 CUDA 版本啥的,得改改配置,重新装东西,很麻烦。最快解决方案如下:

  • 在 /home/cenghaolong/anaconda3/envs/BIONIC/lib(你建的虚拟环境的 lib 文件夹) 中放入缺少的 libcusparse.so.11 文件。
  • 如果仍然报错,则在 /home/user/.bashrc 文件最下面,加入下述一行。注意,此路径下需包含 libcusparse.so.11 文件。

具体操作如下:

代码语言:javascript
复制
vi  ~/.bashrc      # 打开.bashrc 文件     i 键进入编辑模式
export LD_LIBRARY_PATH="/home/cenghaolong/anaconda3/envs/BIONIC/lib"
加入上面的指令后,esc 退出编辑模式   :wq 保存并退出   然后 source 激活一下
source ~/.bashrc

成功解决问题,没有报错了:


本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-10-16,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档