Skip to content

Conversation

@ailuntz
Copy link
Contributor

@ailuntz ailuntz commented Jan 8, 2026

问题描述

修复 issue #815 中报告的问题:使用 --use_gpu False 参数时,系统仍然尝试使用 GPU 并报错。

修改内容

  1. 修复参数解析bug:将 --use_gputype=bool 改为 action='store_true',避免命令行字符串 "False" 被解析为 True
  2. 添加 --no_use_gpu 选项:提供更直观的方式禁用 GPU
  3. 修复 --use_dtw 参数:同样的 type=bool 问题
  4. 添加设备判断:在调用 empty_cache() 前检查 use_gpu,避免 CPU 模式下调用 CUDA API

测试

修复后,用户可以通过以下方式强制使用 CPU:

python run.py --task_name long_term_forecast --no_use_gpu ...

Fixes #815

- 修复 --use_gpu 参数使用 type=bool 导致无法正确解析 False 的问题
- 添加 --no_use_gpu 选项以方便禁用 GPU
- 修复 --use_dtw 参数的相同问题
- 在 empty_cache() 前添加 use_gpu 判断,避免 CPU 模式下调用 CUDA API

Fixes thuml#815
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

用了--use_gpu False還是跑去使用gpu

1 participant