如何在mac上远程连接linux服务器并得到图形输出
参考:
https://zhuanlan.zhihu.com/p/265207166
https://zhuanlan.zhihu.com/p/311227197
https://www.codenong.com/cs109806294
环境
本地:macOS
远端:linux
操作
- 在本地安装了XQuartz并打开,在安全性设置中打开“允许从网络客户端连接”
- 本地执行
export DISPLAY=:0
- 连接远端服务器
ssh -Y user@ip
还有很多方法可以完成输出,不太懂x11的工作原理。比如可以在xquartz的终端里执行
host +
,在远端export DISPLAY=local_ip:0
,然后就可以在远端执行图像输出程序了。或者直接用xquartz的终端连接。
之后就可以把远端的图片显示到本地了。
glut使用注意
经过上述方法设置之后,pyplot
等可以正常输出,但是glxgears
以及使用glut
的程序会报错
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
X Error of failed request: GLXBadContext
Major opcode of failed request: 149 (GLX)
Minor opcode of failed request: 6 (X_GLXIsDirect)
Serial number of failed request: 43
Current serial number in output stream: 42
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 149 (GLX)
Minor opcode of failed request: 24 (X_GLXCreateNewContext)
Value in failed request: 0x0
Serial number of failed request: 42
Current serial number in output stream: 43
参考https://unix.stackexchange.com/questions/429760/opengl-rendering-with-x11-forwarding这篇博客,在本地执行defaults write org.xquartz.X11 enable_iglx -bool true
,之后就可以输出了。