What this is about
If you run AI at home, there is a good chance the same graphics card that draws your screen also runs your model. That works, but only if the jobs take turns and the card never runs out of room. When it does, the first thing to go may be your desktop.
This article tells what happened to us on one card, and gives you a short list of checks that would have prevented most of it.
Why it matters
A graphics card is shared, but it does not share politely. Each program asks for memory, and when the memory is gone, the card says no. The program that gets the no may be the one drawing your windows.
For us, one card drives the desktop, the terminal and every AI job. We found out the hard way what that means.
What happened
On 16 September, we counted 142 jobs that went to the card in one day. Of those, 34 failed and 5 more were cancelled. Of the failures, 20 ended on a termination signal, and 14 exited with an error code. The exit code alone told us little. At least one of those "failures" was a test script killing its own server.
When we traced individual incidents to a cause, they were all things we could have found on the CPU, before the card was asked to do anything. Here are three.
A hold nobody could see. A session wrote "GPU held" in a note on a whiteboard file. But our queue tool at that time had no way to hold the card, so the queue was empty and admitted the next job. That job ran for roughly 36 minutes against a hold that existed only as words in a file the queue never read. We added a hold and a release command to the queue the same evening. The lesson: a hold written where the queue cannot see it is not a hold. It is a note to a person who must remember to re-read it before every launch.
A setting that did not travel. Our queue runs a job in a fresh environment. We put a variable in front of the command to cap a sweep at 50 items. The variable went to the wrapper, not the job. The job saw nothing, used the default of unlimited, and ran a full 4,799-item sweep with no error at all. It ran about 96 times the work we intended. The fix is to put the setting inside the queued command.
A job too big for a shared card. On 19 September a job that asked for 22 GB on our 24 GB card ran close to the ceiling while the terminal and all its panes were open. At 04:16 the kernel logged "Not enough memory for command submission". The terminal's own graphics was refused. It exited, and every pane inside went with it. Nothing was lost but time: we resumed each session. A five-second look at the card's live memory, compared with the job's stated size, would have avoided all of it.
The checks that help
Here is a short list you can use at home.
- Look at free memory first. Read the card's used and free memory before a job. Leave room for the screen. A job that fills the card to the brim is a gamble with your desktop.
- Say how big the job is. Give your queue or script a memory figure, and compare it to the free figure before launch.
- Run a CPU preflight. Build the binary. Run the check once on the smallest input. Read back the settings from the running program, not from what you typed. A build error should never be found on the card.
- Put holds where the launcher reads them. If a note matters enough to block a launch, it must live where the launcher looks.
- Set a timeout, and know what it means. A timeout is a maximum run time, not a wait budget. Once a long picture-making server was killed mid-job, because a flag meant for short batch jobs was used on a server. The log said "timeout" plainly. The client only said connection refused, which cost us time.
- Do the CPU-side work on the CPU. Scoring, reports and log reading do not need the card.
What does belong on the card is the timed run itself, once the build works, the check passes on a small input and the settings are read back. A server can stay up while work is queued behind it, so it loads once.
How we watch the card
Our small Mojo library mojo-amdgpu reads used and free memory, busy percent, power and temperature from files the Linux driver exposes. It needs no ROCm and no extra tool, and a reading of 17 values costs about 8 microseconds in its check, so you can read it before every launch. In our setup a queue tool called gpu-wait holds jobs until the card is free, but that tool is local to us, and the checks above work with any tool that can read free memory and hold a job.
What this does not show
This is one card, one desktop, one setup, over a short period. The count of 34 failures out of 142 tells you about our day, not about yours. And the whole argument is that the failures we traced were avoidable on the CPU. We do not claim that every failure on every day is.
Words you may not know
- Queue: a line of jobs that run one at a time or as room allows.
- Preflight: checks you run before the real job.
- Termination signal: a message from the system that tells a program to stop.
- Hold: a block on starting new jobs.
- Timeout: the most time a job may run before it is stopped.
- Environment variable: a named setting passed to a program from outside.
- VRAM: the memory on the graphics card.
Try it
- Read your card's free memory with mojo-amdgpu. It works on AMD cards on Linux and has a fixture mode, so you can run its example without a card. It has moved into our
mojo-libscollection. - Write down your own preflight list for your own jobs, and run it before the next heavy one.
- Think of the failure you would least like to repeat, and write down the check that would have caught it.
Read next
- The GPU Is a Queue, the full account with all the incidents.

Komentarze
Brak komentarzy.
Zaloguj się aby skomentować.