steffel

steffel

I have successfully fine-tuned the BERT model using my CPU. I would like to try fine-tuning using my GPU an RTX4090 with 24GB RAM. I am getting an out-of-memory error. I am a little surprised but I would like to make sure the memory is truly the issue and it’s not a misconfiguration.
The out-of-memory error raised on loading the model

{:ok, model} = Bumblebee.load_model({:hf, "bert-base-cased"}, spec: spec)

Thanks

Showing Posts 1 to 10

outlog

outlog

have you configured it to run on GPU and not CPU?

eg the appropriate XLA_TARGET ?

maybe post more code..

steffel

steffel OP

The code is the one from the example here with the difference I have updated the libraries in order to be able to use cuda 12.

XLA_TARGET is set to cuda120 with my version of cuda being cuda 12.2. Should I downgrade to cuda 12.0? From my understanding cuda120 is CUDA 12.0+ so 12.0 and above.
Running nvidia-smi I can see the GPU memory is filled up.

steffel

steffel OP

I have managed to get it to run using XLA_TARGET=cuda so it will compile it’s own version.

To get it to work, the batch size needs to be decreased, on my GPU it’s a batch size of 4.

jonatanklosko

jonatanklosko

Creator of Livebook

@steffel this is very interesting, the model is like 0.5gb, so loading it should be far from running out of memory. Note that XLA preallocates memory upfront, so your GPU memory usage will bump to a high value, but an OOM is definitely unexpected.

What is the CUDA and cuDNN version you built with locally to make it work?

jonatanklosko

jonatanklosko

Creator of Livebook

@steffel can you please run with XLA_ARCHIVE_URL=https://static.jonatanklosko.com/builds/xla_extension-x86_64-linux-gnu-cuda120.tar.gz and see if it makes a difference?

steffel

steffel OP

Regarding the versions:
Cuda compilation tools, release 12.2, V12.2.140
Build cuda_12.2.r12.2/compiler.33191640_0
cudnn: v8

steffel

steffel OP

The model loads without any memory issues.
Now when it comes to training the model I am using mrm8488/codebert-base-finetuned-detect-insecure-code that is based on roberta-base when compiling myself I am not able to push the sequence_length up to 1024 (batch_size=1) with your version it works. I would like to know what is different.

jonatanklosko

jonatanklosko

Creator of Livebook

Oh, so just to make sure we are on the same page, the original OOM was during loading or training?

The archive I sent is precompiled using CUDA 12.1, rather than 12.0. According to Jax README it should still be compatible with CUDA 12.0, in which case we would be fine precompiling with 12.1. I will need to do some further tests.

steffel

steffel OP

First I had an OOM during loading.
I managed to solve it using my own built version of xla extension.
I was able to train using a batch_size=1 and sequence_length=64 or 128.
With sequence_length above 128, I am getting an OOM error during training.
Something like that:

** (RuntimeError) Out of memory while trying to allocate 4290931080 bytes.
BufferAssignment OOM Debugging.
BufferAssignment stats:
             parameter allocation:    1.86GiB
              constant allocation:     2.2KiB
        maybe_live_out allocation:    1.86GiB
     preallocated temp allocation:    4.00GiB
  preallocated temp fragmentation:     9.1KiB (0.00%)
                 total allocation:    7.71GiB
              total fragmentation:  656.76MiB (8.32%)
steffel

steffel OP

The OOM while training seems to be back, I am a little confused.
Here is my livemd if that can help.

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews