Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【已顺利训练】Windows踩坑记录 #440

Closed
xwxmars opened this issue Aug 17, 2022 · 19 comments
Closed

【已顺利训练】Windows踩坑记录 #440

xwxmars opened this issue Aug 17, 2022 · 19 comments

Comments

@xwxmars
Copy link

xwxmars commented Aug 17, 2022

好不容易装好了环境跑通了demo,看很多朋友都有windows运行的问题,分享一下我的踩坑(排坑)记录,希望有帮助。

先检查:
pytorch<=1.10(原因见issue #151
cuda和pytorch版本是否匹配
在命令行输入nvcc -V检查cuda是否可用,输入cl检查msvc是否可用(别的c++ compiler理论上也可以但我用的是这个)
正常输出:
nvcc
cl
确保这些所有就应该能够正常运行。以下是具体报错和解决办法。

首先列出所有问题:

  1. OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.
  2. UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。(注意这个是cl,问题4是running build_ext)
  3. ImportError: cannot import name 'nms_rotated_ext' from partially initialized module 'utils.nms_rotated' (most likely due to a circular import)
  4. running build_ext
    error: [WinError 2] 系统找不到指定的文件。
  5. fatal error C1083: 无法打开包括文件: “THC/THC.h”: No such file or directory

1. OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.
原因:没有安装cuda或cuda没有加入环境变量
解决:(临时解决)在命令行输入 set CUDA_HOME=/usr/local/cuda-X.X,建议搜索如何添加cuda到环境变量一劳永逸解决。
Ps. 我后来发现是cuda装在了anaconda里面,真实环境里根本没有cuda

2. UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。
原因:没装msvc或者没有配置到环境变量
解决:如果没装MSVC或其她compiler,先安装;如果装好了依然报这个错,将cl.exe添加到path环境变量。配好之后在命令行输入cl,正常输出见开头。

3. ImportError: cannot import name 'nms_rotated_ext' from partially initialized module 'utils.nms_rotated' (most likely due to a circular import)
原因:nms_rotated_ext是从yolov5_obb-master\utils\nms_rotated\src里面的cpp或cu文件编译过来的,需要先进行编译,python才能读懂。因为编码问题,poly_nms_cuda.cu那个文件需要换成 #224 中的版本。
解决:在命令行cd utils\nms_rotated转到setup.py所在的文件夹,然后输入python setup.py develop

4. running build_ext
error: [WinError 2] 系统找不到指定的文件。
原因:msvc或cuda compiler不可用
解决:重装。验证msvc:命令行输入cl;验证cuda:命令行输入nvcc -V

5. fatal error C1083: 无法打开包括文件: “THC/THC.h”: No such file or directory
原因:见 #151 ,pytorch>=1.11弃用了一些文件,请使用pytorch<=1.10,我用的是1.10.2(和cuda11.3)
题外话:装cuda和pytorch花了很长时间,torch官网没有1.10.2的命令,我尝试装1.10.0和1.10.1,运行detect的时候报错CUDA version (11.3) mismatches the version that was used to compile PyTorch (10.2),最后输入conda install pytorch==1.10.2 torchvision torchaudio cudatoolkit=11.3 装好了(记得换清华源

@xwxmars xwxmars closed this as completed Aug 17, 2022
@Royalbx
Copy link

Royalbx commented Sep 14, 2022

第四个问题怎么解决呀?重装是重装什么?

@YoonaIAN
Copy link

您好,我在第三个问题运行python setup.py develop报这样的错误是为什么呢?
runtimeerror:error compiling objects forextension

@WanFeng123313
Copy link

您好,我在第三个问题运行python setup.py develop报这样的错误是为什么呢? runtimeerror:error compiling objects forextension

你好,我运行python setup.py develop也报错了,请问你解决了吗?

@Royalbx
Copy link

Royalbx commented Nov 7, 2022 via email

@WanFeng123313
Copy link

已经解决了 在 2022-11-04 22:22:39,"WanFeng123313" @.> 写道: 你好,我运行python setup.py develop也报错了,请问你解决了吗? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>
请问你是怎么解决的?我那天试了一天都没解决掉

@Royalbx
Copy link

Royalbx commented Nov 7, 2022 via email

@XUAN6288
Copy link

XUAN6288 commented Nov 8, 2022

用的vs还是pycharm,MSVC安装失败,尝试了很多次,可以发一份编译好的文件给我吗?

@Royalbx
Copy link

Royalbx commented Nov 8, 2022 via email

@YoonaIAN
Copy link

YoonaIAN commented Nov 9, 2022

你好,我在第三个问题运行 python setup.py 开发报这样的错误是为? runtimeerror:error compile objects forextension

你好,我运行python setup.py develop也报错了,请问你解决了吗?

我还是不行,没有解决这个问题

@Royalbx
Copy link

Royalbx commented Nov 9, 2022 via email

@WanFeng123313
Copy link

在setup.py中把 cmdclass={'build_ext': BuildExtension}改为cmdclass={'build_ext': BuildExtension.with_options(use_ninja=False)} | | 卜玺 | | @.*** | ---- 回复的原邮件 ---- | 发件人 | @.> | | 发送日期 | 2022年11月7日 20:06 | | 收件人 | @.> | | 抄送人 | @.> , @.> | | 主题 | Re: [hukaixuan19970627/yolov5_obb] 【已顺利训练】Windows踩坑记录 (Issue #440) | 已经解决了 在 2022-11-04 22:22:39,"WanFeng123313" @.> 写道: 你好,我运行python setup.py develop也报错了,请问你解决了吗? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.> 请问你是怎么解决的?我那天试了一天都没解决掉 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

谢谢,谢谢,我也成功运行了

@whiterAutumn
Copy link

if you are in this situation. Windows compiles successfully, but there is a problem in training. The loss does not drop. The same data, models and parameters can be trained normally under Ubuntu.
Epoch gpu_mem box obj cls theta labels img_size
52/2999 5.44G 0.1232 0.3267 0.02696 0.7272 33 1280: 100%|██████████| 14/14 [00:17<00:00, 1.26s/it]
Class Images Labels P R HBBmAP@.5 HBBmAP@.5:.95: 100%|██████████| 7/7 [00:04<00:00, 1.63it/s]
all 53 0 0 0 0 0

Epoch gpu_mem box obj cls theta labels img_size
53/2999 5.44G 0.1231 0.3131 0.02698 0.7273 33 1280: 100%|██████████| 14/14 [00:17<00:00, 1.27s/it]
Class Images Labels P R HBBmAP@.5 HBBmAP@.5:.95: 100%|██████████| 7/7 [00:04<00:00, 1.59it/s]
all 53 0 0 0 0 0

Epoch gpu_mem box obj cls theta labels img_size
54/2999 5.44G 0.1232 0.3001 0.02696 0.7272 21 1280: 100%|██████████| 14/14 [00:17<00:00, 1.28s/it]
Class Images Labels P R HBBmAP@.5 HBBmAP@.5:.95: 100%|██████████| 7/7 [00:04<00:00, 1.63it/s]
all 53 0 0 0 0 0

@Kev1nDeng
Copy link

卡了一周多终于解决了,感谢!

@BuFanZHANG
Copy link

第四个问题怎么解决呀?重装是重装什么?

你好,请问这个问题解决了嘛,我也在这一步出现了问题?如果解决了具体是如何解决的呢

@Kev1nDeng
Copy link

第四个问题怎么解决呀?重装是重装什么?

你好,请问这个问题解决了嘛,我也在这一步出现了问题?如果解决了具体是如何解决的呢

把msvc装好就行了

@BigBeardYT
Copy link

您好,拜托您百忙之中看了我这个问题,看了所有提问都没人问这个:
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

@BuFanZHANG
Copy link

您好,拜托您百忙之中看了我这个问题,看了所有提问都没人问这个: error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

安装visual studio 2019里的用于C++的组件,安装后在去搜一下配置环境变量

@wszswppx
Copy link

你好,我在编译pytorch3d的时候出现了问题4:

running build_ext
error: [WinError 2] 系统找不到指定的文件。

但是我的cl命令和nvcc -V输出都正常:
image
image

cl编译cpp文件也可以:
image
请问您知道这是什么原因吗?

@BuFanZHANG
Copy link

你好,我在编译pytorch3d的时候出现了问题4:

running build_ext
error: [WinError 2] 系统找不到指定的文件。

但是我的cl命令和nvcc -V输出都正常: image image

cl编译cpp文件也可以: image 请问您知道这是什么原因吗?

之前我遇到是因为vs版本不对,使用2019版本,然后编译文件用issues 里的那个,跟着教程走一遍就行了

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

No branches or pull requests

10 participants