我经常在没有X11的Linux群集计算节点上运行jupyter ipython笔记本电脑,没有问题。但是,在同一设置上运行R内核不是很好。
机器详细信息是:
- Centos 7.2
- r 3.3.1,带有X11,PNG和开罗能力
- Anaconda 4.0.0(Python 2.7.11)
刚刚启动笔记本会导致第一个单元格在日志中运行的第一个单元格之后崩溃:
unable to open connection to X11 display ''
我可以通过使用xvfb-run jupyter notebook
启动笔记本来使它起作用。这使我可以在单元格中运行r命令,但是当我尝试产生剧情时,我会得到以下
Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : X11 font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 1 at size 9 could not be loaded
我想,如果我可以安装x11字体,它将起作用,但这是在集群的计算节点上,我没有安装它们的管理特权。
使用R内核配置Jupyter笔记本以在没有X11的Linux计算机上制作图形的正确方法是什么?
我认为我在没有显示硬件且没有物理输入设备的Linux计算机上运行笔记本时发现了Irkernel所需的最小配置。
在虚拟Framebuffer X服务器下运行笔记本, XVFB :
xvfb-run jupyter notebook
使用开罗而不是x11:
# Run this in a notebook cell, or put in .Rprofile
options(bitmapType="cairo")
设置 jupyter.plot_mimetype 。SVG看起来好多了,对我来说效果很好。PNG也可以:
# Run this in a notebook cell, or put in .Rprofile
# svg much clearer, but won't rescale (scrolling works though)
options(jupyter.plot_mimetypes = "image/svg+xml")
# png had some artifacts, but had the nice feature that it would
# resize when the browser window changes size
#options(jupyter.plot_mimetypes = 'image/png')
# can easily resize plots (have to re-plot) with this:
#options(repr.plot.width=14, repr.plot.height=4)