Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Headless rendering #174

Closed
natschil opened this issue Dec 5, 2018 · 10 comments
Closed

Headless rendering #174

natschil opened this issue Dec 5, 2018 · 10 comments

Comments

@natschil
Copy link

natschil commented Dec 5, 2018

When trying to load GLFW.jl, I get the following on a system with ENV[DISPLAY] not set to anything.

ERROR: InitError: Exception[GLFWError(PLATFORM_ERROR, "X11: The DISPLAY environment variable is missing"), ErrorException("glfwInit failed")]

it seems like things like osmesa should make it possible to render offscreen, is it possible to use this with GLFW.jl?

@SimonDanisch
Copy link
Member

X11: The DISPLAY environment variable is missing

Yeah you need to have an environment variable "DISPLAY=:0" set ;)

@jayschwa
Copy link
Member

Closing since it looks like a solution was provided. Feel free to re-open if I am mistaken.

@h-spiess
Copy link

Hey, on Julia 1.5 when building GLMakie (v0.1.13) with GLFW (v3.4.0) setting ENV["DISPLAY"] = ":0" still doesn't work on my headless server.

(v1.5) pkg> build GLMakie
   Building ModernGL → `~/.julia/packages/ModernGL/rVuW2/deps/build.log`
   Building FFTW ────→ `~/.julia/packages/FFTW/DMUbN/deps/build.log`
   Building GLMakie ─→ `~/.julia/packages/GLMakie/Pway1/deps/build.log`
┌ Error: Error building `GLMakie`: 
│ ERROR: LoadError: OpenGL/GLFW wasn't installed correctly. This likely means,
│ you don't have an OpenGL capable Graphic Card,
│ you don't have the newest video driver installed,
│ or the GLFW build failed. If you're on linux and `]build` GLFW failed,
│ try manually adding `sudo apt-get install libglfw3` and then `]build GLMakie`.
│ If you're on a headless server, you still need to install x-server and
│ proper GPU drivers. You can take inspiration from this article
│ on how to get Makie running on a headless system:
│ https://nextjournal.com/sdanisch/makie-1.0
│ If you don't have a GPU, there is also a Cairo software backend
│ for Makie which you can use:
│ https://github.com/JuliaPlots/CairoMakie.jl.
│ Please check the below error and open an issue at:
│ https://github.com/JuliaPlots/GLMakie.jl.
│ After you fixed your OpenGL install, please run `]build GLMakie` again!
│ GLMakie will still load, but will be disabled as a default backend for Makie
│ 
│ Stacktrace:
│  [1] error(::String) at ./error.jl:33
│  [2] top-level scope at /home/spiess/.julia/packages/GLMakie/Pway1/deps/build.jl:28
│  [3] include(::String) at ./client.jl:457
│  [4] top-level scope at none:5
│ in expression starting at /home/spiess/.julia/packages/GLMakie/Pway1/deps/build.jl:19
│ caused by [exception 1]
│ InitError: Exception[GLFW.GLFWError(GLFW.PLATFORM_ERROR, "X11: Failed to open display :0"), ErrorException("glfwInit failed")]
│ Stacktrace:
│  [1] __init__() at /home/spiess/.julia/packages/GLFW/CBo9c/src/GLFW.jl:35
│  [2] _include_from_serialized(::String, ::Array{Any,1}) at ./loading.jl:697
│  [3] _require_search_from_serialized(::Base.PkgId, ::String) at ./loading.jl:782
│  [4] _require(::Base.PkgId) at ./loading.jl:1007
│  [5] require(::Base.PkgId) at ./loading.jl:928
│  [6] require(::Module, ::Symbol) at ./loading.jl:923
│  [7] top-level scope at /home/spiess/.julia/packages/GLMakie/Pway1/deps/build.jl:20
│  [8] include(::String) at ./client.jl:457
│  [9] top-level scope at none:5
│ during initialization of module GLFW
└ @ Pkg.Operations /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Pkg/src/Operations.jl:949

Do you know why this issue seems to not been solved completely?

Thanks :)

@saikhu
Copy link

saikhu commented Mar 17, 2022

I have a similar issue, trying to run 3D application using Julia but got stuck at

ERROR: LoadError: InitError: Exception[GLFW.GLFWError(GLFW.PLATFORM_ERROR, "X11: Failed to open display :2.0"), ErrorException("glfwInit failed")]
Stacktrace:
 [1] __init__()
   @ GLFW ~/.julia/packages/GLFW/BWxfF/src/GLFW.jl:35
 [2] _include_from_serialized(path::String, depmods::Vector{Any})
   @ Base ./loading.jl:768
 [3] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String)
   @ Base ./loading.jl:854
 [4] _tryrequire_from_serialized(modkey::Base.PkgId, build_id::UInt64, modpath::String)
   @ Base ./loading.jl:783
 [5] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String)
   @ Base ./loading.jl:843
 [6] _require(pkg::Base.PkgId)
   @ Base ./loading.jl:1097
 [7] require(uuidkey::Base.PkgId)
   @ Base ./loading.jl:1013
 [8] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:997
during initialization of module GLFW

@SimonDanisch
Copy link
Member

Why do you have :2.0 for display?

@saikhu
Copy link

saikhu commented Mar 18, 2022

Why do you have :2.0 for display?

because i'm using GNU/Linux 5.4.0-100-generic x86_64 (with slim /usr/bin/slim). For GUI I'm using TigerVNC server:

vncserver -list

TigerVNC server sessions:

X DISPLAY #	PROCESS ID
:2		162220

for remote session i'm using Macbook default screen sharing (vnc).

@garibarba
Copy link

This is still an issue for me. I cannot work around it by just setting DISPLAY=:0 or unsetting it. Besides X forwarding, the only way around this I've found is to use Xvfb -s '-screen 0 1024x768x24' together with DISPLAY=:0.

@xlxs4
Copy link

xlxs4 commented Dec 15, 2023

Exception[GLFW.GLFWError(GLFW.PLATFORM_ERROR, "X11: Failed to open display :0"), ErrorException("glfwInit failed")]. Xvfb works as expected.

@tkgunaratne
Copy link

tkgunaratne commented May 31, 2024

@garibarba "This is still an issue for me. I cannot work around it by just setting DISPLAY=:0 or unsetting it. Besides X forwarding, the only way around this I've found is to use Xvfb -s '-screen 0 1024x768x24' together with DISPLAY=:0."

Can you please elaborate a bit how you achieved this? I'm having the same issue with a headless server.

@jmanthony3
Copy link

I have this issue as well. I copy/pasted the appropriate section for GLMakie from the suggested YAML file for setting up a headless GitHub action with some modifications. There were some difficulties parsing paths in pkg"dev . ./MakeCore ./GLMakie ./ReferenceTests and I added Pkg.update() on the next line too because of an error complaining that ReferenceTests was unregistered. Referencing the code section below which comprises my CI.yml file, there is a definition for DISPLAY=:0 and a command for '-screen 0 1024x768x24'.

name: CI
on:
  push:
    branches:
      - main
    tags: ['*']
  pull_request:
  workflow_dispatch:
concurrency:
  # Skip intermediate builds: always.
  # Cancel intermediate builds: only if it is a pull request build.
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
  test:
    name: GLMakie Julia ${{ matrix.version }}
    env:
      MODERNGL_DEBUGGING: "true" # turn on errors when running OpenGL tests
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        version:
          - '1' # automatically expands to the latest stable 1.x release of Julia
        os:
          - ubuntu-20.04
        arch:
          - x64
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - uses: julia-actions/setup-julia@v2
        with:
          version: ${{ matrix.version }}
          arch: ${{ matrix.arch }}
      - uses: julia-actions/cache@v2
      - run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev xsettingsd x11-xserver-utils
      - name: Install Julia dependencies
        shell: julia --project=monorepo {0}
        run: |
          using Pkg;
          # dev mono repo versions
          pkg"registry up"
          Pkg.update()
          pkg"dev . MakieCore GLMakie ReferenceTests"
          Pkg.update()
      - name: Run the tests
        id: referencetests
        continue-on-error: true
        run: >
          DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --color=yes --project=monorepo -e 'using Pkg; Pkg.test("GLMakie", coverage=true)'
          && echo "TESTS_SUCCESSFUL=true" >> $GITHUB_ENV
      - name: Upload test Artifacts
        uses: actions/upload-artifact@v4
        with:
          name: ReferenceImages_GLMakie_${{ matrix.version }}
          path: |
            ./GLMakie/test/reference_images/
      - name: Fail after artifacts if tests failed
        if: ${{ env.TESTS_SUCCESSFUL != 'true' }}
        run: exit 1
      - uses: julia-actions/julia-processcoverage@v1
      - uses: codecov/codecov-action@v4
        with:
          file: lcov.info

From the latest run of the CI workflow, I get the error message below that prevents ReferenceTests from precompiling which means running the tests also fail.

✗ GLMakie
  ✗ BammannChiesaJohnsons
  296 dependencies successfully precompiled in 344 seconds. 9 already precompiled.
  1 dependency had output during precompilation:
┌ MKL_jll
│  Downloading artifact: IntelOpenMP
└  

The following 2 direct dependencies failed to precompile:

GLMakie [e9467ef8-e4e7-5192-8a1a-b1aee30e663a]

Failed to precompile GLMakie [e9467ef8-e4e7-5192-8a1a-b1aee30e663a] to "/home/runner/.julia/compiled/v1.10/GLMakie/jl_cXSUNg".
┌ Warning:     OpenGL/GLFW wasn't loaded correctly or couldn't be initialized.
│     This likely means, you're on a headless server without having OpenGL support setup correctly.
│     Have a look at the troubleshooting section in the readme:
│     https://github.com/MakieOrg/Makie.jl/tree/master/GLMakie#troubleshooting-opengl.
└ @ GLMakie ~/.julia/dev/Makie/GLMakie/src/gl_backend.jl:4
ERROR: LoadError: InitError: Exception[GLFW.GLFWError(65550, "X11: The DISPLAY environment variable is missing"), ErrorException("glfwInit failed")]
Stacktrace:
  [1] __init__()
    @ GLFW ~/.julia/packages/GLFW/wmoTL/src/GLFW.jl:35
  [2] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1134
  [3] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1122
  [4] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1067
  [5] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base ./loading.jl:1581
  [6] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1938
  [7] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1812
  [8] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
  [9] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [10] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1803
 [11] macro expansion
    @ ./loading.jl:1790 [inlined]
 [12] macro expansion
    @ ./lock.jl:267 [inlined]
 [13] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1753
 [14] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [15] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [16] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1746
 [17] top-level scope
    @ ~/.julia/dev/Makie/GLMakie/src/gl_backend.jl:2
 [18] include(mod::Module, _path::String)
    @ Base ./Base.jl:495
 [19] include(x::String)
    @ GLMakie ~/.julia/dev/Makie/GLMakie/src/GLMakie.jl:1
 [20] top-level scope
    @ ~/.julia/dev/Makie/GLMakie/src/GLMakie.jl:81
 [21] include
    @ ./Base.jl:495 [inlined]
 [22] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2222
 [23] top-level scope
    @ stdin:3
during initialization of module GLFW
in expression starting at /home/runner/.julia/dev/Makie/GLMakie/src/gl_backend.jl:1
in expression starting at /home/runner/.julia/dev/Makie/GLMakie/src/GLMakie.jl:1
in expression starting at stdin:3
BammannChiesaJohnsons [056ed34d-f5e1-4b0f-b3f6-c7e5e8ee168e]

Failed to precompile BammannChiesaJohnsons [056ed34d-f5e1-4b0f-b3f6-c7e5e8ee168e] to "/home/runner/.julia/compiled/v1.10/BammannChiesaJohnsons/jl_SDX3ih".
┌ Warning:     OpenGL/GLFW wasn't loaded correctly or couldn't be initialized.
│     This likely means, you're on a headless server without having OpenGL support setup correctly.
│     Have a look at the troubleshooting section in the readme:
│     https://github.com/MakieOrg/Makie.jl/tree/master/GLMakie#troubleshooting-opengl.
└ @ GLMakie ~/.julia/dev/Makie/GLMakie/src/gl_backend.jl:4
ERROR: LoadError: InitError: Exception[GLFW.GLFWError(65550, "X11: The DISPLAY environment variable is missing"), ErrorException("glfwInit failed")]
Stacktrace:
  [1] __init__()
    @ GLFW ~/.julia/packages/GLFW/wmoTL/src/GLFW.jl:35
  [2] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1134
  [3] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1122
  [4] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1067
  [5] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base ./loading.jl:1581
  [6] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1938
  [7] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1812
  [8] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
  [9] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [10] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1803
 [11] macro expansion
    @ ./loading.jl:1790 [inlined]
 [12] macro expansion
    @ ./lock.jl:267 [inlined]
 [13] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1753
 [14] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [15] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [16] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1746
 [17] top-level scope
    @ ~/.julia/dev/Makie/GLMakie/src/gl_backend.jl:2
 [18] include(mod::Module, _path::String)
    @ Base ./Base.jl:495
 [19] include(x::String)
    @ GLMakie ~/.julia/dev/Makie/GLMakie/src/GLMakie.jl:1
 [20] top-level scope
    @ ~/.julia/dev/Makie/GLMakie/src/GLMakie.jl:81
 [21] include
    @ ./Base.jl:495 [inlined]
 [22] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
    @ Base ./loading.jl:2222
 [23] top-level scope
    @ stdin:3
during initialization of module GLFW
in expression starting at /home/runner/.julia/dev/Makie/GLMakie/src/gl_backend.jl:1
in expression starting at /home/runner/.julia/dev/Makie/GLMakie/src/GLMakie.jl:1
in expression starting at stdin:3
ERROR: LoadError: Failed to precompile GLMakie [e9467ef8-e4e7-5192-8a1a-b1aee30e663a] to "/home/runner/.julia/compiled/v1.10/GLMakie/jl_7bOsPA".
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
    @ Base ./loading.jl:2468
  [3] compilecache
    @ ./loading.jl:2340 [inlined]
  [4] (::Base.var"#968#969"{Base.PkgId})()
    @ Base ./loading.jl:1974
  [5] mkpidlock(f::Base.var"#968#969"{Base.PkgId}, at::String, pid::Int32; kwopts::@Kwargs{stale_age::Int64, wait::Bool})
    @ FileWatching.Pidfile /opt/hostedtoolcache/julia/1.10.5/x64/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:93
  [6] #mkpidlock#6
    @ /opt/hostedtoolcache/julia/1.10.5/x64/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:88 [inlined]
  [7] trymkpidlock(::Function, ::Vararg{Any}; kwargs::@Kwargs{stale_age::Int64})
    @ FileWatching.Pidfile /opt/hostedtoolcache/julia/1.10.5/x64/share/julia/stdlib/v1.10/FileWatching/src/pidfile.jl:111
  [8] #invokelatest#2
    @ ./essentials.jl:894 [inlined]
  [9] invokelatest
    @ ./essentials.jl:[889](https://github.com/jmanthony3/BammannChiesaJohnsons.jl/actions/runs/11184179812/job/31094388050#step:6:890) [inlined]
 [10] maybe_cachefile_lock(f::Base.var"#968#969"{Base.PkgId}, pkg::Base.PkgId, srcpath::String; stale_age::Int64)
    @ Base ./loading.jl:2983
 [11] maybe_cachefile_lock
    @ ./loading.jl:2980 [inlined]
 [12] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1970
 [13] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1812
 [14] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [15] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [16] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1803
 [17] macro expansion
    @ ./loading.jl:1790 [inlined]
 [18] macro expansion
    @ ./lock.jl:267 [inlined]
 [19] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1753
 [20] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [21] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [22] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1746
 [23] include(mod::Module, _path::String)
    @ Base ./Base.jl:495
 [24] include(x::String)
    @ BammannChiesaJohnsons ~/work/BammannChiesaJohnsons.jl/BammannChiesaJohnsons.jl/src/BammannChiesaJohnsons.jl:1
 [25] top-level scope
    @ ~/work/BammannChiesaJohnsons.jl/BammannChiesaJohnsons.jl/src/BammannChiesaJohnsons.jl:9
 [26] include
    @ ./Base.jl:495 [inlined]
 [27] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2222
 [28] top-level scope
    @ stdin:3
in expression starting at /home/runner/work/BammannChiesaJohnsons.jl/BammannChiesaJohnsons.jl/src/BCJ_GUI.jl:4
in expression starting at /home/runner/work/BammannChiesaJohnsons.jl/BammannChiesaJohnsons.jl/src/BammannChiesaJohnsons.jl:1
in expression starting at stdin:3

What am I missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants