zeio

zeio

XLA runs out of memory during inference

Hi, I am trying to evaluate trained model by calling Axon.build and then calling resulting predict_fn function multiple times (once for each evaluation step). Each step involves generating predictions for some number of objects and according to the documentation looks like this:

prediction = predict_fn.(state, tensor)

After the predictions are generated I update the metrics and generate predictions again for other objects. The problem is that after ~ 1800 out of ~ 10 000 evaluation steps the program crashes because xla runs out of memory. Apparently the problem is that my data is witten to the GPU, but afterwards the memory required for predictions computations is not released. I’ve already tried to set preallocate to false in config, but that doesn’t help though it is more clearn now that there is a memory leak. What should I do in this case, is there any solution?

My setup:

Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]
Elixir 1.14.1 (compiled with Erlang/OTP 24)

:axon, "~> 0.2"
:nx, "~> 0.2"
:exla, "~> 0.2"

The error message:

** (RuntimeError) Out of memory while trying to allocate 31129600 bytes.
BufferAssignment OOM Debugging.
BufferAssignment stats:
             parameter allocation:   15.61MiB
              constant allocation:         0B
        maybe_live_out allocation:   14.84MiB
     preallocated temp allocation:   29.69MiB
  preallocated temp fragmentation:         0B (0.00%)
                 total allocation:   60.15MiB
              total fragmentation:         8B (0.00%)
Peak buffers:
	Buffer 1:
		Size: 29.69MiB
		XLA Label: fusion
		Shape: f32[38,1024,2,100]
		==========================

	Buffer 2:
		Size: 14.84MiB
		XLA Label: fusion
		Shape: f32[38,1024,1,100]
		==========================

	Buffer 3:
		Size: 14.72MiB
		Entry Parameter Subshape: f32[38588,100]
		==========================

	Buffer 4:
		Size: 608.0KiB
		Entry Parameter Subshape: s64[38,1024,2]
		==========================

	Buffer 5:
		Size: 304.0KiB
		Entry Parameter Subshape: s64[38,1024,1]
		==========================

	Buffer 6:
		Size: 4.3KiB
		Entry Parameter Subshape: f32[11,100]
		==========================

	Buffer 7:
		Size: 8B
		XLA Label: tuple
		Shape: (f32[38,1024,1,100])
		==========================


    (exla 0.4.0) lib/exla/executable.ex:56: EXLA.Executable.unwrap!/1
    (exla 0.4.0) lib/exla/executable.ex:19: EXLA.Executable.run/3
    (exla 0.4.0) lib/exla/defn.ex:308: EXLA.Defn.maybe_outfeed/7
    (nx 0.4.0) lib/nx/defn.ex:442: Nx.Defn.do_jit_apply/3
    (grapex 0.1.0) lib/grapex/models/testers/entity_based.ex:26: Grapex.Models.Testers.EntityBased.generate_predictions_for_testing/5
    (grapex 0.1.0) lib/grapex/models/testers/entity_based.ex:84: Grapex.Models.Testers.EntityBased.test_one_triple/6
    (grapex 0.1.0) lib/grapex/models/testers/entity_based.ex:114: Grapex.Models.Testers.EntityBased.evaluate/3

Most Liked

outlog

outlog

can you try running exla from main? an exla OOM issue was recently fixed Refactor EXLA execution and fix a memory leak (#993) · elixir-nx/nx@45fa92b · GitHub

zeio

zeio

Created an issue on github

Where Next?

Popular in Questions Top

New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52673 488
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement