安装pytorch遇到的问题

下载安装pytorch:

git  clone  --recursive   https://github.com/pytorch/pytorch

pip  install   -r   requirements.txt  (这步操作超级慢)

python   setup.py   install

安装成功后,测试:

python

>>>import  torch

出现错误:

Python 3.5.2 (default, Nov  23  2017, 12:12:55) 
[GCC 6.3.1 20170109] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
  File "", line 1, in
  File "/home/zml/pytorch/torch/__init__.py", line 84, in
    from torch._C import *
ModuleNotFoundError: No module named 'torch._C'
 

参考:https://blog.csdn.net/sparkexpert/article/details/77675581?locationNum=7&fps=1

cd /usr/local/lib/python3.5/dist-packages/torch/

ls

发现 _C.cpython-36m-x86_64-linux-gnu.so,  _dl.cpython-36m-x86_64-linux-gnu.so两个so文件的文件名都太长了,需要进行修改。

采用cp 的方式复制两个文件:

/usr/local/lib/python3.5/dist-packages/torch/$      sudo   cp    _C.cpython-36m-x86_64-linux-gnu.so      _C.so
/usr/local/lib/python3.5/dist-packages/torch/$      sudo    cp    _dl.cpython-36m-x86_64-linux-gnu.so     _dl.so

成功解决

 

你可能感兴趣的:(安装pytorch遇到的问题)