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博客

目录
相关文章
|
4月前
|
Python
【Python】已解决:AttributeError: module ‘sys’ has no attribute ‘setdefaultencoding’
【Python】已解决:AttributeError: module ‘sys’ has no attribute ‘setdefaultencoding’
201 0
|
4月前
|
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
322 1
|
4月前
|
数据挖掘 开发者 索引
【Python】已解决:ValueError: If using all scalar values, you must pass an index
【Python】已解决:ValueError: If using all scalar values, you must pass an index
1560 0
|
6月前
|
机器学习/深度学习 监控 数据可视化
【已解决】 ‘Conv2d’ object has no attribute ‘register_full_backward_hook’
【已解决】 ‘Conv2d’ object has no attribute ‘register_full_backward_hook’
|
Python
Python报错ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Python报错ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
1559 1
|
6月前
|
机器学习/深度学习 人工智能
【CatBoost报错解决】CatBoostError: Bad value for num feature[non default doc idx=0,feature idx=19]=
【CatBoost报错解决】CatBoostError: Bad value for num feature[non default doc idx=0,feature idx=19]=
|
数据库
解决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
1113 0
解决numpy.core._exceptions.UFuncTypeError: ufunc ‘add‘ did not contain a loop with signature matching
AttributeError: module ‘torch.utils‘ has no attribute ‘data‘
属性错误:模块的'torch.utils'没有属性'data'
96 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’
99 0
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.