1.该问题错误情况如下
File "E:\PythonCode\STANet-master\options\base_options.py", line 140, in parse
torch.cuda.set_device(opt.gpu_ids[0])
File "E:\Python\lib\site-packages\torch\cuda\__init__.py", line 281, in set_device
torch._C._cuda_setDevice(device)
AttributeError: module 'torch._C' has no attribute '_cuda_setDevice'
2.解决方法
1)修改执行命令
由于我的pytorch装的是CPU版本的,因此需要在python执行命令后面加上 --gpu_ids -1。
E:\PythonCode\Net>python train.py --gpu_ids -1
这样运行就没有出错了,不过,还可以用另一种方式解决~
2)修改"base_options.py"文件
这个文件在错误信息里面可以找到。
def initialize(self, parser):
"""Define the common options that are used in both training and test."""
# basic param