zsfcg
17420
2019-03-30 15:28
采纳率: 100%
浏览 4.2k

pytorch RuntimeError: already started

在visual studio code 中调试pytorch代码(debug)跳出错误 RuntimeError: already started

跑的是pytorch官方例子

当单步执行到

inputs, classes = next(iter(dataloaders['train']))

时候出错,错误提示如下

E00012.128: Exception escaped from start_client

            Traceback (most recent call last):
              File "/home/zeng/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/log.py", line 110, in g
                return f(*args, **kwargs)
              File "/home/zeng/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/pydevd_hooks.py", line 74, in start_client
                sock, start_session = daemon.start_client((host, port))
              File "/home/zeng/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/daemon.py", line 214, in start_client
                with self.started():
              File "/home/zeng/anaconda3/lib/python3.6/contextlib.py", line 81, in __enter__
                return next(self.gen)
              File "/home/zeng/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/daemon.py", line 110, in started
                self.start()
              File "/home/zeng/.vscode/extensions/ms-python.python-2019.3.6215/pythonFiles/lib/python/ptvsd/daemon.py", line 145, in start
                raise RuntimeError('already started')
            RuntimeError: already started

请教这是什么情况呀?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • zsfcg
    17420 2019-04-01 09:06
    已采纳

    问题解决,应该是visual studio code的问题,换一个IDE就ok

    点赞 评论
  • devmiao
    devmiao 2019-03-30 23:51
    点赞 评论
  • qq_43288373
    远川流 2019-12-27 17:07

    试试:

    import multiprocessing
    multiprocessing.set_start_method('spawn',True)
    
    点赞 评论
  • sinat_28686349
    sinat_28686349 2020-01-07 15:04

    如果你的工程是基于pytorch的,那么检查自己的dataLoader,是否使用了num_workers参数。当使用该参数时,可能会报上述错误。解决办法是将num_workers设置为0

    点赞 评论

相关推荐