gpt4 book ai didi

python - Pytorch 属性错误 : module 'torch' has no attribute 'as_tensor'

转载 作者:行者123 更新时间:2023-12-04 10:45:55 26 4
gpt4 key购买 nike

$ python main.py --hetero
Created directory results/ACMRaw_2020-01-13_01-20-26
Traceback (most recent call last):
File "main.py", line 101, in <module>
main(args)
File "main.py", line 30, in main
val_mask, test_mask = load_data(args['dataset'])
File "/home/cnudi1/wook/dgl/examples/pytorch/han/utils.py", line 225, in load_data
return load_acm_raw(remove_self_loop)
File "/home/cnudi1/wook/dgl/examples/pytorch/han/utils.py", line 189, in load_acm_raw
pa = dgl.bipartite(p_vs_a, 'paper', 'pa', 'author')
File "/home/cnudi1/.conda/envs/lcr_env/lib/python3.6/site-packages/dgl-0.4-py3.6-linux-ppc64le.egg/dgl/convert.py", line 260, in bipartite
return create_from_scipy(data, utype, etype, vtype)
File "/home/cnudi1/.conda/envs/lcr_env/lib/python3.6/site-packages/dgl-0.4-py3.6-linux-ppc64le.egg/dgl/convert.py", line 823, in create_from_scipy
indptr = utils.toindex(spmat.indptr)
File "/home/cnudi1/.conda/envs/lcr_env/lib/python3.6/site-packages/dgl-0.4-py3.6-linux-ppc64le.egg/dgl/utils.py", line 242, in toindex
return data if isinstance(data, Index) else Index(data)
File "/home/cnudi1/.conda/envs/lcr_env/lib/python3.6/site-packages/dgl-0.4-py3.6-linux-ppc64le.egg/dgl/utils.py", line 15, in __init__
self._initialize_data(data)
File "/home/cnudi1/.conda/envs/lcr_env/lib/python3.6/site-packages/dgl-0.4-py3.6-linux-ppc64le.egg/dgl/utils.py", line 22, in _initialize_data
self._dispatch(data)
File "/home/cnudi1/.conda/envs/lcr_env/lib/python3.6/site-packages/dgl-0.4-py3.6-linux-ppc64le.egg/dgl/utils.py", line 75, in _dispatch
self._user_tensor_data[F.cpu()] = F.zerocopy_from_numpy(self._pydata)
File "/home/cnudi1/.conda/envs/lcr_env/lib/python3.6/site-packages/dgl-0.4-py3.6-linux-ppc64le.egg/dgl/backend/pytorch/tensor.py", line 276, in zerocopy_from_numpy
return th.as_tensor(np_array)
AttributeError: module 'torch' has no attribute 'as_tensor'

当我尝试运行代码时出现错误 ( https://github.com/dmlc/dgl/blob/master/examples/pytorch/han/main.py )

来自 DGL
( https://github.com/dmlc/dgl )

它需要 CUDA 和 Pytorch,所以我设法安装了它。

但是我遇到了错误并且无法通过 Google/Stackoverflow 搜索找到解决方案

我的环境是
  • Linux minsky 3.10.0-957.5.1.el7.ppc64le
  • CentOS
  • Python 3.6.9
  • conda 4.5.11
  • CUDA 10.1
  • NVCC 10.1
  • pytorch 0.4.0
  • Torchvision 0.2.1

  • Pytorch 在 Python 中运行良好
    >>> import torch
    >>> print (torch.__version__)
    0.4.0
    >>> import torchvision
    >>> print (torchvision.__version__)
    0.2.1

    请你能帮我一下吗?

    * DGL 从源代码安装

    ** Pytorch 与来自 channel:engility( How to install pytorch on Power 8 or PPC64 machine? ) 的 conda 一起安装
    conda install -c engility pytorch

    因为其他方式(默认 conda、pip、从源代码安装)永远不适用于 ppc64le

    最佳答案

    tl;博士 升级到 PyTorch 0.4。 1

    请注意,DGL 需要 PyTorch 0.4.1,而您使用的是 PyTorch 0.4.0。如果你仔细观察,你会看到 as_tensorproposed in 30 Apr 2018并于 2018 年 5 月 1 日合并。您还会看到 PyTorch 0.4.0 在 2018 年 4 月 24 日之前发布,而 PyTorch 0.4.1于 2018 年 7 月 26 日之后发布。实际上,如果您查看 changelog of the 0.4.1 version ,您会注意到宣布了一个新的运营商:torch.as_tensor :)

    关于python - Pytorch 属性错误 : module 'torch' has no attribute 'as_tensor' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59705922/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com