win7 使用mxnet退出时python无法退出

本文介绍了在使用MXNet框架时遇到的LibMxNet.dll卸载期间出现死锁的问题及解决方案。通过使用Python的signal模块可以有效地终止进程,此外还推荐了在Win10或Linux系统下运行MXNet。

github上也常见类似的问题

链接1:mxnet/issues/11163.
链接2:mxnet/issues/9271.

// 问题描述
Deadlock in LibMxNet.dll during unload due to synchronization call in destructor

解决方法

方法1:

Python使用signal模块来终止自身的进程

其实这种场景还是不少的,经常需要终止自身进程。这个时候需要使用到signal模块,并结合自身的os模块来杀进程。

// demo
from mxnet import gluon
print("hello python")

import os, signal
if os.sys.platform.startswith("win"):    
    os.kill(os.getpid(), signal.SIGTERM) # signal.SIGTERM或者SIGILL都可以终止自身进程

方法2:

使用win 10 或 Linux 系统运行mxnet。

(torch_test) C:\software\d2l-1.0.3>python setup.py install running install C:\Users\26342\miniconda3\envs\torch_test\Lib\site-packages\setuptools\_distutils\cmd.py:90: SetuptoolsDeprecationWarning: setup.py install is deprecated. !! ******************************************************************************** Please avoid running ``setup.py`` directly. Instead, use pypa/build, pypa/installer or other standards-based tools. See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details. ******************************************************************************** !! self.initialize_options() C:\Users\26342\miniconda3\envs\torch_test\Lib\site-packages\setuptools\_distutils\cmd.py:90: EasyInstallDeprecationWarning: easy_install command is deprecated. !! ******************************************************************************** Please avoid running ``setup.py`` and ``easy_install``. Instead, use pypa/build, pypa/installer or other standards-based tools. See https://github.com/pypa/setuptools/issues/917 for details. ******************************************************************************** !! self.initialize_options() running bdist_egg running egg_info writing d2l.egg-info\PKG-INFO writing dependency_links to d2l.egg-info\dependency_links.txt writing requirements to d2l.egg-info\requires.txt writing top-level names to d2l.egg-info\top_level.txt reading manifest file 'd2l.egg-info\SOURCES.txt' adding license file 'LICENSE' adding license file 'LICENSE-SAMPLECODE' adding license file 'LICENSE-SUMMARY' writing manifest file 'd2l.egg-info\SOURCES.txt' installing library code to build\bdist.win-amd64\egg running install_lib running build_py creating build\bdist.win-amd64\egg creating build\bdist.win-amd64\egg\d2l copying build\lib\d2l\jax.py -> build\bdist.win-amd64\egg\d2l copying build\lib\d2l\mxnet.py -> build\bdist.win-amd64\egg\d2l copying build\lib\d2l\tensorflow.py -> build\bdist.win-amd64\egg\d2l copying build\lib\d2l\torch.py -> build\bdist.win-amd64\egg\d2l copying build\lib\d2l\__init__.py -> build\bdist.win-amd64\egg\d2l byte-compiling build\bdist.win-amd64\egg\d2l\jax.py to jax.cpython-312.pyc byte-compiling build\bdist.win-amd64\egg\d2l\mxnet.py to mxnet.cpython-312.pyc byte-compiling build\bdist.win-amd64\egg\d2l\tensorflow.py to tensorflow.cpython-312.pyc byte-compiling build\bdist.win-amd64\egg\d2l\torch.py to torch.cpython-312.pyc byte-compiling build\bdist.win-amd64\egg\d2l\__init__.py to __init__.cpython-312.pyc creating build\bdist.win-amd64\egg\EGG-INFO copying d2l.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO copying d2l.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO copying d2l.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO copying d2l.egg-info\requires.txt -> build\bdist.win-amd64\egg\EGG-INFO copying d2l.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO copying d2l.egg-info\zip-safe -> build\bdist.win-amd64\egg\EGG-INFO creating 'dist\d2l-1.0.3-py3.12.egg' and adding 'build\bdist.win-amd64\egg' to it removing 'build\bdist.win-amd64\egg' (and everything under it) Processing d2l-1.0.3-py3.12.egg Removing c:\users\26342\miniconda3\envs\torch_test\lib\site-packages\d2l-1.0.3-py3.12.egg error: [WinError 32] 另一个程序正在使用此文件,进程无法访问。: 'c:\\users\\26342\\miniconda3\\envs\\torch_test\\lib\\site-packages\\d2l-1.0.3-py3.12.egg'
09-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值