We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 0: invalid continuation byte
在windows11上面，我使用`pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.11.0/index.html`安装了`mmcv-full 1.5.0`。
之后使用[测试脚本](https://github.com/open-mmlab/mmcv/blob/master/.dev_scripts/check_installation.py)测试是否安装成功，出现了如下错误:
```bash
C:\Users\ZhangQu\.conda\envs\mmlab\python.exe D:/masterResearch/envtest/check_mmcv.py
Start checking the installation of mmcv-full ...
CPU ops were compiled successfully.
CUDA ops were compiled successfully.
mmcv-full has been installed successfully.

Traceback (most recent call last):
  File "D:\masterResearch\envtest\check_mmcv.py", line 40, in <module>
    env_info_dict = collect_env()
  File "C:\Users\ZhangQu\.conda\envs\mmlab\lib\site-packages\mmcv\utils\env.py", line 91, in collect_env
    env_info['MSVC'] = cc.decode(encoding).partition('\n')[0].strip()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 0: invalid continuation byte

Process finished with exit code 1
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mmcv/utils/env.py`
Content:
```
1 # Copyright (c) OpenMMLab. All rights reserved.
2 """This file holding some environment constant for sharing by other files."""
3 
4 import os.path as osp
5 import subprocess
6 import sys
7 from collections import defaultdict
8 
9 import cv2
10 import torch
11 
12 import mmcv
13 from .parrots_wrapper import get_build_config
14 
15 
16 def collect_env():
17     """Collect the information of the running environments.
18 
19     Returns:
20         dict: The environment information. The following fields are contained.
21 
22             - sys.platform: The variable of ``sys.platform``.
23             - Python: Python version.
24             - CUDA available: Bool, indicating if CUDA is available.
25             - GPU devices: Device type of each GPU.
26             - CUDA_HOME (optional): The env var ``CUDA_HOME``.
27             - NVCC (optional): NVCC version.
28             - GCC: GCC version, "n/a" if GCC is not installed.
29             - MSVC: Microsoft Virtual C++ Compiler version, Windows only.
30             - PyTorch: PyTorch version.
31             - PyTorch compiling details: The output of \
32                 ``torch.__config__.show()``.
33             - TorchVision (optional): TorchVision version.
34             - OpenCV: OpenCV version.
35             - MMCV: MMCV version.
36             - MMCV Compiler: The GCC version for compiling MMCV ops.
37             - MMCV CUDA Compiler: The CUDA version for compiling MMCV ops.
38     """
39     env_info = {}
40     env_info['sys.platform'] = sys.platform
41     env_info['Python'] = sys.version.replace('\n', '')
42 
43     cuda_available = torch.cuda.is_available()
44     env_info['CUDA available'] = cuda_available
45 
46     if cuda_available:
47         devices = defaultdict(list)
48         for k in range(torch.cuda.device_count()):
49             devices[torch.cuda.get_device_name(k)].append(str(k))
50         for name, device_ids in devices.items():
51             env_info['GPU ' + ','.join(device_ids)] = name
52 
53         from mmcv.utils.parrots_wrapper import _get_cuda_home
54         CUDA_HOME = _get_cuda_home()
55         env_info['CUDA_HOME'] = CUDA_HOME
56 
57         if CUDA_HOME is not None and osp.isdir(CUDA_HOME):
58             try:
59                 nvcc = osp.join(CUDA_HOME, 'bin/nvcc')
60                 nvcc = subprocess.check_output(f'"{nvcc}" -V', shell=True)
61                 nvcc = nvcc.decode('utf-8').strip()
62                 release = nvcc.rfind('Cuda compilation tools')
63                 build = nvcc.rfind('Build ')
64                 nvcc = nvcc[release:build].strip()
65             except subprocess.SubprocessError:
66                 nvcc = 'Not Available'
67             env_info['NVCC'] = nvcc
68 
69     try:
70         # Check C++ Compiler.
71         # For Unix-like, sysconfig has 'CC' variable like 'gcc -pthread ...',
72         # indicating the compiler used, we use this to get the compiler name
73         import sysconfig
74         cc = sysconfig.get_config_var('CC')
75         if cc:
76             cc = osp.basename(cc.split()[0])
77             cc_info = subprocess.check_output(f'{cc} --version', shell=True)
78             env_info['GCC'] = cc_info.decode('utf-8').partition(
79                 '\n')[0].strip()
80         else:
81             # on Windows, cl.exe is not in PATH. We need to find the path.
82             # distutils.ccompiler.new_compiler() returns a msvccompiler
83             # object and after initialization, path to cl.exe is found.
84             import os
85             from distutils.ccompiler import new_compiler
86             ccompiler = new_compiler()
87             ccompiler.initialize()
88             cc = subprocess.check_output(
89                 f'{ccompiler.cc}', stderr=subprocess.STDOUT, shell=True)
90             encoding = os.device_encoding(sys.stdout.fileno()) or 'utf-8'
91             env_info['MSVC'] = cc.decode(encoding).partition('\n')[0].strip()
92             env_info['GCC'] = 'n/a'
93     except subprocess.CalledProcessError:
94         env_info['GCC'] = 'n/a'
95 
96     env_info['PyTorch'] = torch.__version__
97     env_info['PyTorch compiling details'] = get_build_config()
98 
99     try:
100         import torchvision
101         env_info['TorchVision'] = torchvision.__version__
102     except ModuleNotFoundError:
103         pass
104 
105     env_info['OpenCV'] = cv2.__version__
106 
107     env_info['MMCV'] = mmcv.__version__
108 
109     try:
110         from mmcv.ops import get_compiler_version, get_compiling_cuda_version
111     except ModuleNotFoundError:
112         env_info['MMCV Compiler'] = 'n/a'
113         env_info['MMCV CUDA Compiler'] = 'n/a'
114     else:
115         env_info['MMCV Compiler'] = get_compiler_version()
116         env_info['MMCV CUDA Compiler'] = get_compiling_cuda_version()
117 
118     return env_info
119
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/mmcv/utils/env.py b/mmcv/utils/env.py
--- a/mmcv/utils/env.py
+++ b/mmcv/utils/env.py
@@ -81,13 +81,15 @@
             # on Windows, cl.exe is not in PATH. We need to find the path.
             # distutils.ccompiler.new_compiler() returns a msvccompiler
             # object and after initialization, path to cl.exe is found.
+            import locale
             import os
             from distutils.ccompiler import new_compiler
             ccompiler = new_compiler()
             ccompiler.initialize()
             cc = subprocess.check_output(
                 f'{ccompiler.cc}', stderr=subprocess.STDOUT, shell=True)
-            encoding = os.device_encoding(sys.stdout.fileno()) or 'utf-8'
+            encoding = os.device_encoding(
+                sys.stdout.fileno()) or locale.getpreferredencoding()
             env_info['MSVC'] = cc.decode(encoding).partition('\n')[0].strip()
             env_info['GCC'] = 'n/a'
     except subprocess.CalledProcessError:

{"golden_diff": "diff --git a/mmcv/utils/env.py b/mmcv/utils/env.py\n--- a/mmcv/utils/env.py\n+++ b/mmcv/utils/env.py\n@@ -81,13 +81,15 @@\n             # on Windows, cl.exe is not in PATH. We need to find the path.\n             # distutils.ccompiler.new_compiler() returns a msvccompiler\n             # object and after initialization, path to cl.exe is found.\n+            import locale\n             import os\n             from distutils.ccompiler import new_compiler\n             ccompiler = new_compiler()\n             ccompiler.initialize()\n             cc = subprocess.check_output(\n                 f'{ccompiler.cc}', stderr=subprocess.STDOUT, shell=True)\n-            encoding = os.device_encoding(sys.stdout.fileno()) or 'utf-8'\n+            encoding = os.device_encoding(\n+                sys.stdout.fileno()) or locale.getpreferredencoding()\n             env_info['MSVC'] = cc.decode(encoding).partition('\\n')[0].strip()\n             env_info['GCC'] = 'n/a'\n     except subprocess.CalledProcessError:\n", "issue": "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 0: invalid continuation byte\n\u5728windows11\u4e0a\u9762\uff0c\u6211\u4f7f\u7528`pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.11.0/index.html`\u5b89\u88c5\u4e86`mmcv-full 1.5.0`\u3002\r\n\u4e4b\u540e\u4f7f\u7528[\u6d4b\u8bd5\u811a\u672c](https://github.com/open-mmlab/mmcv/blob/master/.dev_scripts/check_installation.py)\u6d4b\u8bd5\u662f\u5426\u5b89\u88c5\u6210\u529f\uff0c\u51fa\u73b0\u4e86\u5982\u4e0b\u9519\u8bef:\r\n```bash\r\nC:\\Users\\ZhangQu\\.conda\\envs\\mmlab\\python.exe D:/masterResearch/envtest/check_mmcv.py\r\nStart checking the installation of mmcv-full ...\r\nCPU ops were compiled successfully.\r\nCUDA ops were compiled successfully.\r\nmmcv-full has been installed successfully.\r\n\r\nTraceback (most recent call last):\r\n  File \"D:\\masterResearch\\envtest\\check_mmcv.py\", line 40, in <module>\r\n    env_info_dict = collect_env()\r\n  File \"C:\\Users\\ZhangQu\\.conda\\envs\\mmlab\\lib\\site-packages\\mmcv\\utils\\env.py\", line 91, in collect_env\r\n    env_info['MSVC'] = cc.decode(encoding).partition('\\n')[0].strip()\r\nUnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 0: invalid continuation byte\r\n\r\nProcess finished with exit code 1\r\n```\n", "before_files": [{"content": "# Copyright (c) OpenMMLab. All rights reserved.\n\"\"\"This file holding some environment constant for sharing by other files.\"\"\"\n\nimport os.path as osp\nimport subprocess\nimport sys\nfrom collections import defaultdict\n\nimport cv2\nimport torch\n\nimport mmcv\nfrom .parrots_wrapper import get_build_config\n\n\ndef collect_env():\n    \"\"\"Collect the information of the running environments.\n\n    Returns:\n        dict: The environment information. The following fields are contained.\n\n            - sys.platform: The variable of ``sys.platform``.\n            - Python: Python version.\n            - CUDA available: Bool, indicating if CUDA is available.\n            - GPU devices: Device type of each GPU.\n            - CUDA_HOME (optional): The env var ``CUDA_HOME``.\n            - NVCC (optional): NVCC version.\n            - GCC: GCC version, \"n/a\" if GCC is not installed.\n            - MSVC: Microsoft Virtual C++ Compiler version, Windows only.\n            - PyTorch: PyTorch version.\n            - PyTorch compiling details: The output of \\\n                ``torch.__config__.show()``.\n            - TorchVision (optional): TorchVision version.\n            - OpenCV: OpenCV version.\n            - MMCV: MMCV version.\n            - MMCV Compiler: The GCC version for compiling MMCV ops.\n            - MMCV CUDA Compiler: The CUDA version for compiling MMCV ops.\n    \"\"\"\n    env_info = {}\n    env_info['sys.platform'] = sys.platform\n    env_info['Python'] = sys.version.replace('\\n', '')\n\n    cuda_available = torch.cuda.is_available()\n    env_info['CUDA available'] = cuda_available\n\n    if cuda_available:\n        devices = defaultdict(list)\n        for k in range(torch.cuda.device_count()):\n            devices[torch.cuda.get_device_name(k)].append(str(k))\n        for name, device_ids in devices.items():\n            env_info['GPU ' + ','.join(device_ids)] = name\n\n        from mmcv.utils.parrots_wrapper import _get_cuda_home\n        CUDA_HOME = _get_cuda_home()\n        env_info['CUDA_HOME'] = CUDA_HOME\n\n        if CUDA_HOME is not None and osp.isdir(CUDA_HOME):\n            try:\n                nvcc = osp.join(CUDA_HOME, 'bin/nvcc')\n                nvcc = subprocess.check_output(f'\"{nvcc}\" -V', shell=True)\n                nvcc = nvcc.decode('utf-8').strip()\n                release = nvcc.rfind('Cuda compilation tools')\n                build = nvcc.rfind('Build ')\n                nvcc = nvcc[release:build].strip()\n            except subprocess.SubprocessError:\n                nvcc = 'Not Available'\n            env_info['NVCC'] = nvcc\n\n    try:\n        # Check C++ Compiler.\n        # For Unix-like, sysconfig has 'CC' variable like 'gcc -pthread ...',\n        # indicating the compiler used, we use this to get the compiler name\n        import sysconfig\n        cc = sysconfig.get_config_var('CC')\n        if cc:\n            cc = osp.basename(cc.split()[0])\n            cc_info = subprocess.check_output(f'{cc} --version', shell=True)\n            env_info['GCC'] = cc_info.decode('utf-8').partition(\n                '\\n')[0].strip()\n        else:\n            # on Windows, cl.exe is not in PATH. We need to find the path.\n            # distutils.ccompiler.new_compiler() returns a msvccompiler\n            # object and after initialization, path to cl.exe is found.\n            import os\n            from distutils.ccompiler import new_compiler\n            ccompiler = new_compiler()\n            ccompiler.initialize()\n            cc = subprocess.check_output(\n                f'{ccompiler.cc}', stderr=subprocess.STDOUT, shell=True)\n            encoding = os.device_encoding(sys.stdout.fileno()) or 'utf-8'\n            env_info['MSVC'] = cc.decode(encoding).partition('\\n')[0].strip()\n            env_info['GCC'] = 'n/a'\n    except subprocess.CalledProcessError:\n        env_info['GCC'] = 'n/a'\n\n    env_info['PyTorch'] = torch.__version__\n    env_info['PyTorch compiling details'] = get_build_config()\n\n    try:\n        import torchvision\n        env_info['TorchVision'] = torchvision.__version__\n    except ModuleNotFoundError:\n        pass\n\n    env_info['OpenCV'] = cv2.__version__\n\n    env_info['MMCV'] = mmcv.__version__\n\n    try:\n        from mmcv.ops import get_compiler_version, get_compiling_cuda_version\n    except ModuleNotFoundError:\n        env_info['MMCV Compiler'] = 'n/a'\n        env_info['MMCV CUDA Compiler'] = 'n/a'\n    else:\n        env_info['MMCV Compiler'] = get_compiler_version()\n        env_info['MMCV CUDA Compiler'] = get_compiling_cuda_version()\n\n    return env_info\n", "path": "mmcv/utils/env.py"}], "after_files": [{"content": "# Copyright (c) OpenMMLab. All rights reserved.\n\"\"\"This file holding some environment constant for sharing by other files.\"\"\"\n\nimport os.path as osp\nimport subprocess\nimport sys\nfrom collections import defaultdict\n\nimport cv2\nimport torch\n\nimport mmcv\nfrom .parrots_wrapper import get_build_config\n\n\ndef collect_env():\n    \"\"\"Collect the information of the running environments.\n\n    Returns:\n        dict: The environment information. The following fields are contained.\n\n            - sys.platform: The variable of ``sys.platform``.\n            - Python: Python version.\n            - CUDA available: Bool, indicating if CUDA is available.\n            - GPU devices: Device type of each GPU.\n            - CUDA_HOME (optional): The env var ``CUDA_HOME``.\n            - NVCC (optional): NVCC version.\n            - GCC: GCC version, \"n/a\" if GCC is not installed.\n            - MSVC: Microsoft Virtual C++ Compiler version, Windows only.\n            - PyTorch: PyTorch version.\n            - PyTorch compiling details: The output of \\\n                ``torch.__config__.show()``.\n            - TorchVision (optional): TorchVision version.\n            - OpenCV: OpenCV version.\n            - MMCV: MMCV version.\n            - MMCV Compiler: The GCC version for compiling MMCV ops.\n            - MMCV CUDA Compiler: The CUDA version for compiling MMCV ops.\n    \"\"\"\n    env_info = {}\n    env_info['sys.platform'] = sys.platform\n    env_info['Python'] = sys.version.replace('\\n', '')\n\n    cuda_available = torch.cuda.is_available()\n    env_info['CUDA available'] = cuda_available\n\n    if cuda_available:\n        devices = defaultdict(list)\n        for k in range(torch.cuda.device_count()):\n            devices[torch.cuda.get_device_name(k)].append(str(k))\n        for name, device_ids in devices.items():\n            env_info['GPU ' + ','.join(device_ids)] = name\n\n        from mmcv.utils.parrots_wrapper import _get_cuda_home\n        CUDA_HOME = _get_cuda_home()\n        env_info['CUDA_HOME'] = CUDA_HOME\n\n        if CUDA_HOME is not None and osp.isdir(CUDA_HOME):\n            try:\n                nvcc = osp.join(CUDA_HOME, 'bin/nvcc')\n                nvcc = subprocess.check_output(f'\"{nvcc}\" -V', shell=True)\n                nvcc = nvcc.decode('utf-8').strip()\n                release = nvcc.rfind('Cuda compilation tools')\n                build = nvcc.rfind('Build ')\n                nvcc = nvcc[release:build].strip()\n            except subprocess.SubprocessError:\n                nvcc = 'Not Available'\n            env_info['NVCC'] = nvcc\n\n    try:\n        # Check C++ Compiler.\n        # For Unix-like, sysconfig has 'CC' variable like 'gcc -pthread ...',\n        # indicating the compiler used, we use this to get the compiler name\n        import sysconfig\n        cc = sysconfig.get_config_var('CC')\n        if cc:\n            cc = osp.basename(cc.split()[0])\n            cc_info = subprocess.check_output(f'{cc} --version', shell=True)\n            env_info['GCC'] = cc_info.decode('utf-8').partition(\n                '\\n')[0].strip()\n        else:\n            # on Windows, cl.exe is not in PATH. We need to find the path.\n            # distutils.ccompiler.new_compiler() returns a msvccompiler\n            # object and after initialization, path to cl.exe is found.\n            import locale\n            import os\n            from distutils.ccompiler import new_compiler\n            ccompiler = new_compiler()\n            ccompiler.initialize()\n            cc = subprocess.check_output(\n                f'{ccompiler.cc}', stderr=subprocess.STDOUT, shell=True)\n            encoding = os.device_encoding(\n                sys.stdout.fileno()) or locale.getpreferredencoding()\n            env_info['MSVC'] = cc.decode(encoding).partition('\\n')[0].strip()\n            env_info['GCC'] = 'n/a'\n    except subprocess.CalledProcessError:\n        env_info['GCC'] = 'n/a'\n\n    env_info['PyTorch'] = torch.__version__\n    env_info['PyTorch compiling details'] = get_build_config()\n\n    try:\n        import torchvision\n        env_info['TorchVision'] = torchvision.__version__\n    except ModuleNotFoundError:\n        pass\n\n    env_info['OpenCV'] = cv2.__version__\n\n    env_info['MMCV'] = mmcv.__version__\n\n    try:\n        from mmcv.ops import get_compiler_version, get_compiling_cuda_version\n    except ModuleNotFoundError:\n        env_info['MMCV Compiler'] = 'n/a'\n        env_info['MMCV CUDA Compiler'] = 'n/a'\n    else:\n        env_info['MMCV Compiler'] = get_compiler_version()\n        env_info['MMCV CUDA Compiler'] = get_compiling_cuda_version()\n\n    return env_info\n", "path": "mmcv/utils/env.py"}]}