Pytorch导入错误:<路径名>:目标文件没有可加载的段

时间:2020-09-20 15:03:23

标签: pytorch ubuntu-16.04 importerror

我一直在尝试通过conda为我的Ubuntu 16.04 LTS安装Pytorch模块。我使用find /Volumes/GoPro8/DCIM/100GOPRO/ \ -name 'GH0[0-9]71[0-9][0-9].MP4' \ -type f \ -printf '%A@\t%p\0' | sort -z -k1n | cut -z -f2- | while IFS= read -r -d '' f; do echo "$f" done 进行安装(非CUDA版本)。但是,当我在Python shell上键入conda install pytorch torchvision cpuonly -c pytorch时,这就是我看到的-

import torch

我已验证使用ImportError: /home/student/anaconda2/lib/python2.7/site-packages/torch/_C.so: object file has no loadable segments 安装了Pytorch

1 个答案:

答案 0 :(得分:0)

我在 Ubuntu 18.04 上为 conda env with python 3.8 遇到了同样的问题。我认为问题在于手电筒安装不完整。所以我做了 pip install from wheel 而不是 conda install。您可以按照以下操作(假设您安装了 cuda11):

  1. 创建 conda 环境
conda create --name=myenv python=3.8
conda activate myenv
  1. 从轮子上安装割炬
pip install torch==1.7.0+cu110 torchvision==0.8.1+cu110 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html

请注意,我必须安装 torchvision==0.8.1+cu110,如报告 here