-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[Enhancement] Fix collect_env on Windows #1789
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
mmcv/utils/env.py
Outdated
gcc = gcc.decode('utf-8').strip() | ||
first_line = gcc.find('\n') | ||
gcc = gcc[:first_line].strip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for your contribution. mmcv compiled with cl.exe
in windows, it could be better if collect_env
can output the
information of 'cl.exe'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually there are multiple cl.exe on one machine (multiple VS version and cross-compliation tools) and cl is not avaliable in common shell environment. So it would be not an easy task and might even output misleading information.
The main reason I need to patch this is, when I use mmcv
lite version on Windows, it complains that no CUDA runtime is found, probably because of the missing tail
and head
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But on windows, mmcv does not compiled with gcc
, so it is confusing if it happens to output mingw gcc
information. Should we choose how to export gcc
information via sys.platform
? We can make env_info['GCC'] = 'n/a'
as before. Besides, how does “no CUDA runtime is found” occurs?
@@ -56,16 +56,20 @@ def collect_env(): | |||
if CUDA_HOME is not None and osp.isdir(CUDA_HOME): | |||
try: | |||
nvcc = osp.join(CUDA_HOME, 'bin/nvcc') | |||
nvcc = subprocess.check_output( | |||
f'"{nvcc}" -V | tail -n1', shell=True) | |||
nvcc = subprocess.check_output(f'"{nvcc}" -V', shell=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be better if we can get the last line of nvcc -V
which is consistent with the former version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Linux
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_19:24:38_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89
On Windows (11.5)
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Thu_Nov_18_09:52:33_Pacific_Standard_Time_2021
Cuda compilation tools, release 11.5, V11.5.119
Build cuda_11.5.r11.5/compiler.30672275_0
Not sure what it looks like on other Windows machines. but the last line on Linux match with the second last line on Windows.
I will add 'Cuda compilation tools' to the output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK~ thanks for your explanation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May leave comments in the code to explain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Since
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UnicodeDecodeError
was raised on my computer.
>>> from mmcv.utils import collect_env
>>> collect_env()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\codebases\mmcv\mmcv\utils\env.py", line 89, in collect_env
env_info['MSVC'] = cc.decode('utf-8').partition('\n')[0].strip()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 0: invalid continuation byte
mmcv/utils/env.py
Outdated
encoding = locale.getdefaultlocale()[1] | ||
env_info['MSVC'] = cc.decode(encoding).partition('\n')[0].strip() | ||
env_info['GCC'] = 'n/a' | ||
del ccompiler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to manually delete ccompiler
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not. I did this because that initialize()
call took a few seconds, so I thought this object may take some unnecessary memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be released by gc in later so we can remove this line.
Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
Motivation
collect_env()
usetail
andhead
which is not available on most Windows machines.Modification
Remove the
tail
andhead
, and use string find to extract env infos.BC-breaking (Optional)
No
Use cases (Optional)
Checklist
Before PR:
After PR: