安装torch之后import torch报错

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装torch之后import torch报错相关的知识,希望对你有一定的参考价值。

参考技术A 参考:

https://blog.csdn.net/dongfang1984/article/details/81363834

https://blog.csdn.net/qq_33289694/article/details/103858513

问题 :安装Pytorch之后,输入import torch,出现ImportError: libmkl_gnu_thread.so: cannot open shared object file: No such file or directory

原因: mkl等库都在anaconda里安装,但是torch没有链接anaconda里的这些库,所以报错。

解决方法:

    首先找到linux上的libmkl_gf_lp64.so,复制当前的路径,很重要!!!

    然后 cd /etc/ld.so.conf.d,使用sudo vi runtime-x86_64.conf建立一个文件,将刚刚的路径写入新建的文件中,即,按下i,右键paste,按下Esc,按下:,输入wq,按下回车键。

    然后再输入sudo ldconfig完成更新即可。

    输入ipython,然后import torch 成功

以上是关于安装torch之后import torch报错的主要内容,如果未能解决你的问题,请参考以下文章

linux上安装完torch后仍报错:ImportError: No module named torch

安装PyTorch后jupyter notebook中仍出现“No module named torch“

安装PyTorch后jupyter notebook中仍出现“No module named torch“

安装torch7时出现致命错误:errno.h: No such file or directory

[转] conda安装torch出现链接错误

torch安装