了解内核-前端通信——为什么我的前端冻结?
编辑:只需确认是否可以重现此内容就会很有用。只需一台计算机即可尝试此操作(无需远程连接)。
更新 似乎其他人无法在 Mac 或 Win7 上重现此问题,因此它要么是 WinXP 特定的,要么是我的机器特定的。此时我要放弃了。
最好有一个关于前端和内核如何通信的教程,这样我们就可以调试远程内核问题。任何此类一般性答案(或其他地方教程的链接)都是非常受欢迎的。我已经了解 Sascha Kratky 的远程内核策略。
现在是实际问题:当我以任何方式连接到远程计算机时(例如使用远程内核策略),前端迟早会冻结。我怎样才能防止这种情况发生?
以下是如何在单台计算机上重现问题(无需远程连接):
创建新的内核配置(评估菜单 -> 内核配置选项...)
选择高级选项。
MLOpen 的参数:
-LinkName "8000@YOUR-IP-HERE,8001@YOUR-IP-HERE" -LinkMode Listen -LinkProtocol TCPIP -LinkHost“您的 IP-此处”-LinkOptions MLDontInteract
(将
YOUR-IP-HERE
替换为您计算机的 IP 地址。在 Windows 上,您可以通过在命令窗口中键入ipconfig
来获取此地址。)启动内核的 Shell 命令:留空(我们将手动执行)
打开一个新笔记本,将笔记本的内核设置为您刚刚设置的内核,然后评估某些内容(
1+1
)。现在我们需要在连接超时之前手动启动内核。因此,在命令行模式下启动一个新内核(
math
),并评估以下内容:link=LinkConnect["8000,8001",LinkProtocol->"TCPIP"] (* 连接到前端链接 *) $ParentLink = 链接; (*设置前端链接为父链接*)
现在连接已建立,一切似乎都正常工作(除了前端粉红色消息窗口中的一条消息)
评估
Manipulate[n, {n, 0, 100, 1}]
。首先,这似乎也有效。现在使用滑块。前端迟早会冻结并需要被杀死。对我来说,上下拖动滑块大约 10 秒而不释放它总是足够的。
为什么前端会冻结? 如何在前端和内核之间创建 TCPIP 模式连接,以使一切正常工作?
一些注意事项:
- 我使用的是 Windows XP。
- 如果我使用 LinkProtocol -> ,问题就不会出现。 “共享内存”。
- 使用评估中止计算 ->中止评估确实可以正常工作。
- 我已使用
Links[]
验证已创建MathLink`$PreemptiveLink
和MathLink`$ServiceLink
以及LinkConnectedQ[]
> 对它们返回True
。
再次请注意,只有在连续拖动 Manipualate
滑块几秒钟而不释放它后,前端才会冻结。
EDIT: Just a confirmation whether you can reproduce this or not would be useful. Only a single computer is needed to try this (no remote connection necessary).
Update It seems other can't reproduce this on Mac or Win7, so it's either WinXP-specific or specific to my machine. At this point I'm giving up.
It would be good to have a tutorial on how the Front End and the Kernel communicate, so we can debug remote kernel issues. Any such general answers (or links to tutorials elsewhere) are most welcome. I am already aware of Remote Kernel Strategies by Sascha Kratky.
Now the practical question: When I connect to a remote machine in any way (e.g. using remote kernel strategies), the front end will sooner or later freeze up. How can I prevent this?
Here's how to reproduce the problem on a single machine (no remote connection needed):
Create a new kernel configuration (Evaluation menu -> Kernel Configuration Options...)
Select Advanced Options.
Arguments to MLOpen:
-LinkName "8000@YOUR-IP-HERE,8001@YOUR-IP-HERE" -LinkMode Listen -LinkProtocol TCPIP -LinkHost "YOUR-IP-HERE" -LinkOptions MLDontInteract
(Replace
YOUR-IP-HERE
with your computer's IP address. On Windows you can get this by typingipconfig
in a command window.)Shell command to launch kernel: leave empty (we will do it manually)
Open a new notebook, set the notebook's kernel to the one you just set up, and evaluate something (
1+1
).Now we need to launch the kernel manually, before the connection times out. So start a new kernel (
math
) in command line mode, and evaluate the following:link=LinkConnect["8000,8001",LinkProtocol->"TCPIP"] (* connect to front end link *) $ParentLink = link; (* set the front end link as parent link *)
Now the connection is established, and everything appears to work correctly (save for the one message in the front end's pink message window)
Evaluate
Manipulate[n, {n, 0, 100, 1}]
. First, this appears to work too. Now play with the slider. Sooner or later the front end will freeze and needs to be killed. For me, dragging the slider up and down for ~10 seconds without releasing it always suffices.
Why does the Front End freeze? How can I create a TCPIP-mode connection between the front end and the kernel in a way that everything will be working correctly?
Some notes:
- I'm on Windows XP.
- The problem never appears if I use
LinkProtocol -> "SharedMemory"
. - Aborting calculations using Evaluation -> Abort Evaluation does work correctly.
- I have verified using
Links[]
thatMathLink`$PreemptiveLink
andMathLink`$ServiceLink
are created andLinkConnectedQ[]
returnsTrue
on them.
Again, note that the Front End will freeze only after dragging the Manipualate
slider continuously for a few seconds without releasing it.
Link to same question on MathGroup.
Related: Firewall settings for remote kernel to work (Mathematica)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(不是答案,但很难将其写为评论)
仅供参考,这里有一些有关前端如何与内核对话的信息
http://reference.wolfram.com/mathematica/tutorial/AdvancedDynamicFunctionality.html
大约向下一半,上面写着
,还有更多。也许会有帮助。此外,第 31 页的 PDF 文件中也有相同的信息:
http://www.wolfram.com /learningcenter/tutorialcollection/DynamicInteractivity/
内核和前端之间的实际消息传递协议必须非常先进。
(not an answer, but hard to write this as comment)
fyi, there is a little bit on information about how the frontend talks to the kernel here
http://reference.wolfram.com/mathematica/tutorial/AdvancedDynamicFunctionality.html
about half way down, it says
and more there. May be that will help. Also, same information is in the PDF file on page 31:
http://www.wolfram.com/learningcenter/tutorialcollection/DynamicInteractivity/
The actual messaging protocol between the kernel and front end must be very advanced.