Traceback (most recent call last): File "DT_001_X01_P01.py", line 150, in DT_001_X01_P01.Module.load_model File "/home/kejia/Server/tf/Bin_x64/DeepLearning/DL_Lib_02/mmdet/apis/inference.py", line 42, in init_detector checkpoint = load_checkpoint(model, checkpoint, map_location=map_loc) File "/home/kejia/Server/tf/Bin_x64/DeepLearning/DL_Lib_02/mmcv/runner/checkpoint.py", line 529, in load_checkpoint checkpoint = _load_checkpoint(filename, map_location, logger) File "/home/kejia/Server/tf/Bin_x64/DeepLearning/DL_Lib_02/mmcv/runner/checkpoint.py", line 467, in _load_checkpoint return CheckpointLoader.load_checkpoint(filename, map_location, logger) File "/home/kejia/Server/tf/Bin_x64/DeepLearning/DL_Lib_02/mmcv/runner/checkpoint.py", line 244, in load_checkpoint return checkpoint_loader(filename, map_location) File "/home/kejia/Server/tf/Bin_x64/DeepLearning/DL_Lib_02/mmcv/runner/checkpoint.py", line 261, in load_from_local checkpoint = torch.load(filename, map_location=map_location) File "torch/serialization.py", line 594, in load return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args) File "torch/serialization.py", line 853, in _load result = unpickler.load() File "torch/serialization.py", line 845, in persistent_load load_tensor(data_type, size, key, _maybe_decode_ascii(location)) File "torch/serialization.py", line 834, in load_tensor loaded_storages[key] = restore_location(storage, location) File "torch/serialization.py", line 175, in default_restore_location result = fn(storage, location) File "torch/serialization.py", line 157, in _cuda_deserialize return obj.cuda(device) File "torch/_utils.py", line 71, in _cuda with torch.cuda.device(device): File "torch/cuda/__init__.py", line 225, in __enter__ self.prev_idx = torch._C._cuda_getDevice() File "torch/cuda/__init__.py", line 164, in _lazy_init "Cannot re-initialize CUDA in forked subprocess. " + msg) RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method ('异常抛出', None) DT_001_X01_P01 load_model ret=1, version=V1.0.0.0
时间: 2024-04-22 11:24:17 浏览: 196
根据你提供的错误信息,看起来是在使用多进程时遇到了 CUDA 初始化错误。错误信息中指出,无法在 fork 的子进程中重新初始化 CUDA。为了在多进程中使用 CUDA,你需要使用 'spawn' 启动方法。
你可以尝试在主模块中添加以下代码来设置 'spawn' 启动方法:
```python
import multiprocessing as mp
if __name__ == '__main__':
mp.set_start_method('spawn')
# 在这里编写你的主程序逻辑
```
将你的主程序逻辑放在 `if __name__ == '__main__':` 块中,并在该块中调用 `mp.set_start_method('spawn')` 来设置 'spawn' 启动方法。
在上述代码中,`mp.set_start_method('spawn')` 将设置 'spawn' 启动方法为当前进程的默认启动方法。这样,在创建子进程时就会使用 'spawn' 启动方法,避免 CUDA 初始化错误。
希望这个解决方案对你有所帮助。如果你还有其他问题,请随时提问。
相关问题
Traceback (most recent call last): File "k2.py", line 14, in <module> File "flask_socketio\__init__.py", line 187, in __init__ File "flask_socketio\__init__.py", line 243, in init_app File "socketio\server.py", line 134, in __init__ File "engineio\server.py", line 149, in __init__ ValueError: Invalid async_mode specified [12672] Failed to execute script 'k2' due to unhandled exception!
根据你提供的错误信息,问题似乎出现在 Flask-SocketIO 库的初始化过程中。错误消息中提到了一个无效的 `async_mode` 参数。
`async_mode` 参数用于指定异步模式,以确定服务器如何处理并发连接。常见的异步模式包括 "eventlet"、"gevent" 和 "threading" 等。然而,错误消息表明指定的异步模式无效。
要解决此问题,你可以尝试以下几个步骤:
1. 检查 `async_mode` 参数:确保在初始化 Flask-SocketIO 时,传递的 `async_mode` 参数是有效的。检查你的代码,确保没有拼写错误或其他语法错误。
2. 确认依赖项安装:确保你的环境中已正确安装 Flask-SocketIO 及其依赖项。可以尝试使用 `pip` 命令重新安装 Flask-SocketIO。
3. 更新库版本:尝试更新 Flask-SocketIO 和相关的库到最新版本。有时,更新库可以解决一些已知的问题。
4. 检查兼容性:确保你使用的 Flask-SocketIO 版本与其他库和 Python 解释器兼容。可以查阅 Flask-SocketIO 的文档或其它用户的反馈,了解是否有已知的兼容性问题。
如果上述步骤都无法解决问题,请提供更多关于你的代码和环境配置的信息,以便更详细地分析和帮助你解决问题。
解释下F:\python_projects\venv\Scripts\python.exe F:\result\eye_first_move_to_objects_time.py Traceback (most recent call last): File "F:\result\eye_first_move_to_objects_time.py", line 73, in <module> coordinate_x = float(fix_record[row_index][5].value) ValueError: could not convert string to float: '.' Error in atexit._run_exitfuncs: Traceback (most recent call last): File "F:\python_projects\venv\lib\site-packages\openpyxl\worksheet\_writer.py", line 32, in _openpyxl_shutdown os.remove(path) PermissionError: [WinError 32] 另一个程序正在使用此文件,进程无法访问。: 'C:\\Users\\dell\\AppData\\Local\\Temp\\openpyxl.byyckh9l' Exception ignored in: <generator object WorksheetWriter.get_stream at 0x000001FBA5104820> Traceback (most recent call last): File "F:\python_projects\venv\lib\site-packages\openpyxl\worksheet\_writer.py", line 300, in get_stream File "src\lxml\serializer.pxi", line 1834, in lxml.etree._FileWriterElement.__exit__ File "src\lxml\serializer.pxi", line 1570, in lxml.etree._IncrementalFileWriter._write_end_element lxml.etree.LxmlSyntaxError: inconsistent exit action in context manager Exception ignored in: <generator object WriteOnlyWorksheet._write_rows at 0x000001FBA5104270> Traceback (most recent call last): File "F:\python_projects\venv\lib\site-packages\openpyxl\worksheet\_write_only.py", line 75, in _write_rows File "src\lxml\serializer.pxi", line 1834, in lxml.etree._FileWriterElement.__exit__ File "src\lxml\serializer.pxi", line 1568, in lxml.etree._IncrementalFileWriter._write_end_element lxml.etree.LxmlSyntaxError: not in an element Process finished with exit code 1
这是一个 Python 程序运行时出现的错误信息。其中,第一行是命令行窗口中输入的 Python 程序执行命令,指定了 Python 解释器和要执行的 Python 文件的路径。接下来是一个 traceback,它展示了程序运行时的错误信息。在这个例子中,程序在第 73 行尝试将一个字符串转换为浮点数,但该字符串是一个点,无法转换。此外,在 traceback 中还显示了一些在程序结束时出现的异常,这些异常通常与文件操作有关。在这个例子中,程序试图删除一个文件,但该文件正在被另一个程序使用,因此无法删除。最后两行 traceback 是与 lxml 库相关的异常,这些异常可能与程序中使用的 Excel 文件有关。
阅读全文