Q:在跑CenterTrack的时候遇到了下面问题:
 

  File "main.py", line 101, in <module>
    main(opt)
  File "main.py", line 37, in main
    logger = Logger(opt)
  File "/home/xxx/CenterTrack/src/lib/logger.py", line 33, in __init__
    subprocess.check_output(["git", "describe"])))
  File "/home/xx/anaconda3/envs/CenterTrack/lib/python3.8/subprocess.py", line 415, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/home/xx/anaconda3/envs/CenterTrack/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', 'describe']' returned non-zero exit status 128.

解决:

1)将logger.py中的下面几行注释了

    with open(file_name, 'wt') as opt_file:
      # opt_file.write('==> commit hash: {}\n'.format(
      #   subprocess.check_output(["git", "describe"])))
      opt_file.write('==> torch version: {}\n'.format(torch.__version__))
      opt_file.write('==> cudnn version: {}\n'.format(


2)将subprocess.py中415行中的check=True改为False。

影响:

当子进程返回非零退出码时,subprocess就不会引发CalledProcessError异常。相反,它将静默失败,并继续执行剩余的代码。你将需要自己检查返回码(通过subprocess.CompletedProcess.returncode)来确定子进程是否成功执行。

这可能有助于防止一些错误,如尝试运行不存在的命令或在非Git目录中运行git describe命令等。然而,这也可能使你错过一些重要的错误信息,因为你的代码可能在出现错误的情况下仍然继续执行。你需要根据你的特定需求来决定是否要设置check=False。

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐