ImportError: cannot import name ‘_update_worker_pids’ from ‘torch._C’

简介: ImportError: cannot import name ‘_update_worker_pids’ from ‘torch._C’

问题描述:

在复现超分辨率算法RNAN(EDSR、RCAN同样的环境)的时候报错,torch要求是0.4.0版本的。

解决方案:

解决方法1(已安装anaconda)

1. 打开命令行(这个自行查找)

2. 新建python的环境 3.6.5(python的版本不能大于3.6)

conda create -n Your_project_name python=3.6.5   # Your_project_name为你的项目名称,自己拟定

3. 进入Your_project_name 项目

conda.bat activate Your_project_name

4. 安装torch(0.4.0版本)

要指定路径安装,不然 version==0.4.0

pip install torch==0.4.0 -f https://download.pytorch.org/whl/torch_stable.html

注:对应上一步骤中torch=0.4.0版本,torchvision得是0.2.0才行,torchvision安装命令如下:

pip install torchvision==0.2.0 -i https://pypi.mirrors.ustc.edu.cn/simple/

解决方法2(未安装anaconda)

1. 如果你的python版本小于3.7,那你就可以不用下载新的python,则你直接进行这一步的操作。(查看自己python的版本可以在命令行输入 python -V)

pip install torch==0.4.0 -f https://download.pytorch.org/whl/torch_stable.html

2. 如果python版本大于3.6,则可以卸载掉或下载新的替换之前版本使用(方法靠个人喜欢),链接参考:https://www.cnblogs.com/sxdcgaq8080/p/10237089.html

然后下载安装新的python3.6.5之后,安装如下包:

pip install torch==0.4.0 -f https://download.pytorch.org/whl/torch_stable.html

参考:解决问题ImportError: cannot import name ‘_update_worker_pids’ from ‘torch._C’_importerror: cannot import name '_update_worker_pi-CSDN博客

目录
相关文章
|
7月前
|
Python
【Python】已解决:AttributeError: module ‘sys’ has no attribute ‘setdefaultencoding’
【Python】已解决:AttributeError: module ‘sys’ has no attribute ‘setdefaultencoding’
332 0
|
7月前
|
XML 移动开发 数据格式
【Python】已解决:bs4.FeatureNotFound: Couldn’t find a tree builder with the features you requested: html5
【Python】已解决:bs4.FeatureNotFound: Couldn’t find a tree builder with the features you requested: html5
582 1
|
6月前
|
Python
【Python 3】解决FeatureNotFound: Couldn‘t find a tree builder with the features you requested: lxml.
文章讨论了在使用Python的BeautifulSoup库时遇到的"Couldn't find a tree builder with"错误,并提供了解决方案。
318 0
|
数据库
解决numpy.core._exceptions.UFuncTypeError: ufunc ‘add‘ did not contain a loop with signature matching
解决numpy.core._exceptions.UFuncTypeError: ufunc ‘add‘ did not contain a loop with signature matching
1342 0
解决numpy.core._exceptions.UFuncTypeError: ufunc ‘add‘ did not contain a loop with signature matching
|
机器学习/深度学习 PyTorch 算法框架/工具
AttributeError: module ‘torch.utils‘ has no attribute ‘data‘
属性错误:模块的'torch.utils'没有属性'data'
132 0
onnx-tensorrt:builtin_op_importers.cpp:628:5: error: ‘IIdentityLayer’ is not a member of ‘nvinfer1’
onnx-tensorrt:builtin_op_importers.cpp:628:5: error: ‘IIdentityLayer’ is not a member of ‘nvinfer1’
116 0
|
PyTorch 算法框架/工具
AttributeError: ‘model’ object has no attribute ‘copy’-pytorch
AttributeError: ‘model’ object has no attribute ‘copy’-pytorch
python报错bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requested: lxml.
python报错bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requested: lxml.
|
算法框架/工具 Windows