当前位置: 首页 > news >正文

【PyTorch】DGL 报错FileNotFoundError: Cannot find DGL C++ graphbolt library

报错

使用PyTorch 和DGL时报错:

xxx@xxx-gpu-3080ti-1:~/workspace/inference$ python inference.py 
开始推理
100%|███████████████████████████████████████████████████████████████████████████████████| 99/99 [00:00<00:00, 877.31it/s]
Traceback (most recent call last):File "/home2/ykli/workspace/inference/inference.py", line 93, in <module>from dgl.data import DGLDatasetFile "/home2/ykli/.local/lib/python3.10/site-packages/dgl/__init__.py", line 16, in <module>from . import (File "/home2/ykli/.local/lib/python3.10/site-packages/dgl/dataloading/__init__.py", line 13, in <module>from .dataloader import *File "/home2/ykli/.local/lib/python3.10/site-packages/dgl/dataloading/dataloader.py", line 27, in <module>from ..distributed import DistGraphFile "/home2/ykli/.local/lib/python3.10/site-packages/dgl/distributed/__init__.py", line 5, in <module>from .dist_graph import DistGraph, DistGraphServer, edge_split, node_splitFile "/home2/ykli/.local/lib/python3.10/site-packages/dgl/distributed/dist_graph.py", line 11, in <module>from .. import backend as F, graphbolt as gb, heterograph_indexFile "/home2/ykli/.local/lib/python3.10/site-packages/dgl/graphbolt/__init__.py", line 55, in <module>load_graphbolt()File "/home2/ykli/.local/lib/python3.10/site-packages/dgl/graphbolt/__init__.py", line 45, in load_graphboltraise FileNotFoundError(
FileNotFoundError: Cannot find DGL C++ graphbolt library at /home2/ykli/.local/lib/python3.10/site-packages/dgl/graphbolt/libgraphbolt_pytorch_2.3.1.so

核心原因是DGL 与 PyTorch 的兼容性问题。

解决方法:

确定兼容性信息:
https://www.dgl.ai/pages/start.html

先查看自己的CUDA版本
nvidia-smi

xxx@xxx-gpu-3080ti-1:~/workspace/inference$ nvidia-smi
Thu Sep 18 15:15:58 2025       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 570.153.02             Driver Version: 570.153.02     CUDA Version: 12.8     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 3080 Ti     Off |   00000000:21:00.0 Off |                  N/A |
| 40%   61C    P0            116W /  350W |       0MiB /  12288MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------++-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+

所以

先安装torch

pip3 install torch==2.4.1 torchvision==0.19.1 torchaudio==2.4.1 --index-url https://download.pytorch.org/whl/cu121

再安装dgl
(参考https://www.dgl.ai/pages/start.html)

pip3 install  dgl -f https://data.dgl.ai/wheels/torch-2.4/cu124/repo.html

然后就成功了

xxx@xxx-gpu-3080ti-1:~/workspace/inference$ python inference.py 
开始推理
100%|█████████████████████████████████████| 99/99 [00:00<00:00, 884.90it/s]
ok
/home2/ykli/workspace/inference/inference.py:228: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.model.load_state_dict(torch.load("GCN_Multi.pth")["model"])
99it [00:01, 84.29it/s]
推理结束
测试app为恶意app的概率依次为
6.448549e-05
0.017811496
0.002427295
0.0017984548
0.002004614
0.99742377
0.004718356
0.9982717
3.615891e-17
0.9982717
0.99682534
0.004988429
0.010242186
0.98479813
0.98893905
0.9993826
0.004939628
7.899102e-05
0.022339027
0.0033634796
0.98893917
0.99742377
0.99967027
0.9982717
5.6295053e-06
0.030222524
0.99346876
0.99971515
0.9987703
0.09378741
5.4269745e-05
0.0010533822
0.9982717
0.99965036
0.9529677
0.9529677
0.98333883
5.459704e-09
0.0003061844
0.027305502
0.98893905
0.7514718
0.0049884245
0.0049884245
0.0005003361
0.001292823
1.0
0.9505768
0.6262198
0.024419907
0.0049884245
0.9982717
0.98893917
0.9982717
0.0005057038
0.98893917
0.98893917
0.0017296192
0.99965036
0.0014586173
0.917256
0.9986375
0.0006834932
0.95257545
8.688583e-06
0.0043205405
0.9505768
0.0018375306
0.98893917
0.9992711
0.98893905
0.99965036
0.99942386
0.00074927614
0.0015520339
0.99965036
0.041937307
0.9982717
0.98893917
0.0026961763
0.012011028
0.9982717
0.9982717
0.004988434
0.99998665
0.0007492758
0.99967027
0.9982717
1.3757738e-05
0.08972405
0.00043226476
0.99997044
0.4352821
0.99742377
0.013959418
0.9505768
0.0026908643
8.9060154e-07
0.021170292
检测准确率为0.9797979797979798
http://www.dtcms.com/a/389298.html

相关文章:

  • Autoware不同版本之间的区别
  • 多轮对话-上下文管理
  • 在阿里云私网服务器(无公网IP)上安装 Docker 环境的完整指南
  • opencv DNN模块及利用实现风格迁移
  • 多层感知机:从感知机到深度神经网络的演进
  • centos7 docker compose 安装redis
  • ⸢ 肆-Ⅱ⸥ ⤳ 风险发现体系的演进(下):实践与演进
  • 18兆欧超纯水抛光树脂
  • 第三篇:C++的进化之旅:从C with Class到C++20
  • 机器视觉的手机FPC丝印应用
  • 在Windows上使用Claude Code并集成到PyCharm IDE的完整指南
  • MoPKL与SPAR的思考
  • Ubuntu 启动分配不到 ip 地址问题
  • iOS 推送证书配置 - p12
  • Qt QVPieModelMapper详解
  • 【MySQL数据库管理问答题】第1章 MySQL 简介
  • 铁头山羊视stm32-HAL库
  • iOS 26 帧率检测实战攻略 如何监控FPS、GPU渲染、Core Anima
  • AWS Lightsail vs 阿里云轻量:企业上云服务器选型深度对比
  • stm32中的位带操作的使用意义
  • Qt QStackedBarSeries详解
  • WebSocket Secure(WSS)在Django项目中的使用
  • RocketMQ 部署;与Golang服务交互
  • 南京某高校校园外卖点餐系统_django
  • 类的基础语法(笔记补充)
  • pycharm 连git 传文件到GitHub
  • 11 简答题-伪码转为NS图 PAD图
  • Java 中如何利用 CAS 实现原子操作?以AtomicInteger 为例
  • Custom SRP - Point And Spot Shadows
  • 无障碍前端组件实践(上):基础交互组件与色彩无障碍