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

Error plotting a *large* matrix #335

Closed
giordano opened this issue Apr 6, 2019 · 18 comments
Closed

Error plotting a *large* matrix #335

giordano opened this issue Apr 6, 2019 · 18 comments

Comments

@giordano
Copy link

giordano commented Apr 6, 2019

While trying to reproduce this issue, I gave Makie.jl a try, however it fails to plot, with heatmap, a matrix with size 24900 x 26620 (but also 170000 x 17000):

julia> using AbstractPlotting, GLMakie, Makie

julia> heatmap(rand(Float32, 24900, 26620))
Error showing value of type Scene:
ERROR: glTexImage 2D: width too large. Width: 24900
[...]

Images this large are relatively common in astronomy and currently I don't see any tool in Julia able to visualise them.

@asinghvi17
Copy link
Member

asinghvi17 commented Apr 6, 2019

#291 (comment) may have a solution to this (probably have to replace 3d with 2d but otherwise...)

@giordano
Copy link
Author

giordano commented Apr 6, 2019

I'm talking about a 2D image, not a 3D one, thus I guess that glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE) is unrelated. BTW:

julia> glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE)
-1

@asinghvi17
Copy link
Member

asinghvi17 commented Apr 6, 2019

That's weird, the heatmap command 'works' on my machine (although its output is suspect). Are you plotting on a headless system or something? glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE) should return a number >= 64...

On my machine:

using Makie
heatmap(rand(Float32, 24900, 26620))

yields
Screen Shot 2019-04-06 at 5 50 44  37400PM

@asinghvi17
Copy link
Member

Also, what I meant to show when linking to that was

vol = rand(506, 720, 1440)
ranges = (1:256, 1:256, 1:256)
scene = volume(ranges..., vol[ranges...])
for i in 1:3
    global ranges
    ranges = ntuple(3) do j
        s = j == i ? last(ranges[j]) : 1
        e = j == i ? size(vol, j) : last(ranges[j])
        s:e
    end
    volume!(ranges..., vol[ranges...])
end

scene

for which you could do the same in 2 dimensions with heatmaps.

@giordano
Copy link
Author

giordano commented Apr 6, 2019

Are you plotting on a headless system or something?

Not sure what you mean by "headless system", it's a MacBook running Arch Linux.

@asinghvi17
Copy link
Member

Hmm...does Makie work otherwise?

(What I meant by a headless system is one with no display, like an SSH-only server or something).

If your Macbook Air is old enough, it may not support OpenGL, meaning Makie might not work there..

@giordano
Copy link
Author

giordano commented Apr 6, 2019

julia> using Makie, GLMakie, ModernGL

julia> heatmap(rand(Float32, 10_000, 10_000))

image

@asinghvi17
Copy link
Member

Perhaps this approach might work?

using Makie
heatmap(rand(Float32, 10_000, 10_000))
heatmap!(10000:20000, 10000:20000, rand(Float32, 10000, 10000))
heatmap!(10000:20000, 0:10000, rand(Float32, 10000, 10000))
heatmap!(00000:10000, 10000:20000, rand(Float32, 10000, 10000))

which yields

Screen Shot 2019-04-06 at 8 11 01  08200PM

@asinghvi17
Copy link
Member

asinghvi17 commented Apr 7, 2019

Essentially, assemble the whole plot from slices of data, thereby making the texture non continuous and circumventing the OpenGL error. Doing it in one command fails on mine too (although silently). Perhaps this is something we should add to the docs!

@SimonDanisch
Copy link
Member

yeah this is too big for the gpu and needs tiling!

@asinghvi17
Copy link
Member

Is there a value that can be accessed which gives the max 2d texture size (similar to glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE))?

asinghvi17 added a commit to asinghvi17/MakieGallery.jl that referenced this issue Apr 7, 2019
@giordano
Copy link
Author

giordano commented Apr 7, 2019

yeah this is too big for the gpu and needs tiling!

I guess it uses a different way to plot figures, but matplotlib has no problem to deal with matrices this large and is also relatively fast.

These large matrices are not rare in astronomy and it would be great if it were possible to handle them more easily.

@asinghvi17
Copy link
Member

I suspect that could be written into a recipe (something like bigheatmap)?

SimonDanisch pushed a commit to JuliaPlots/MakieGallery.jl that referenced this issue May 9, 2019
@asinghvi17
Copy link
Member

asinghvi17 commented Jul 12, 2019

Since heatmap is a primitive, would we have to build this into every backend?
tiled-heatmap

@asinghvi17
Copy link
Member

We could recursively break up too-large heatmaps. Not sure if that's doable, though - might need some massaging on the AbstractPlotting end

@SimonDanisch
Copy link
Member

I think something like that should be handled by another package creating a recipe to view very large arrays

@tecosaur
Copy link

tecosaur commented Feb 13, 2023

I just ran into this issue when trying to run heatmap on a large matrix of mine (30k x 30k). Is the current suggestion that somebody creates a GLMakieLargeHeatmapTilingWorkaround.jl package that just contains the equivalent of:

for xslice in Iterators.partition(axes(mat, 1), 10000)
    for yslice in Iterators.partition(axes(mat, 2), 10000)
        heatmap!(ax, xslice, yslice, mat[xslice, yslice])
    end
end

@asinghvi17
Copy link
Member

Yes, I would go with that for now.

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

4 participants