GPU Inference Falls Back to CPU After Reboot: A Persistent systemd Fix

    An inference service that uses the GPU in an interactive terminal may silently fall back to CPU execution after a reboot or when started as a daemon. This article explains how service-account permissions and driver initialization timing cause that behavior, how to preserve the fix with a systemd drop-in, and how to verify GPU acceleration after a cold boot.

    Symptoms and Common Misdiagnoses

    On servers with integrated or discrete GPUs, local inference and batch embedding services can suffer from a silent performance regression. The same model and startup command fully utilize the GPU in an interactive terminal, but after a reboot—or when launched through a daemon, orchestration task, or application gateway—CPU utilization spikes while GPU utilization stays near zero.

    The service does not crash, and its API continues to return responses. That makes it easy to conclude that the machine has no usable GPU or that the model does not support acceleration.

    The problem often lies not in the model weights, but in the process identity and startup timing. During interactive troubleshooting, the operator typically has administrative privileges, and the device nodes are already available. Once the application runs as a service, it uses a restricted account and may perform its initial device check before the kernel driver finishes registering the GPU.

    Many inference runtimes favor availability: if GPU initialization encounters a permission error, a missing device, or an unavailable backend, they fall back to CPU execution rather than terminate. The service appears healthy, but compute resources are wasted and latency increases.

    Do not diagnose this problem from service status alone. Check both:

    • Whether the inference process has unusually high CPU utilization.
    • Whether the GPU’s compute-engine utilization remains close to zero.

    If the failure occurs only on the first startup after a reboot or outside a login session, while a manual launch under the same account works once the device nodes exist, focus on service permissions, sandboxing, and boot ordering rather than assuming the driver is completely unavailable.

    Root Cause 1: The Service Account Cannot Access the GPU Device

    GPU compute commonly uses rendering device nodes exposed by the kernel, such as /dev/dri/renderD128. Access depends not only on administrative privileges but also on the process’s supplementary groups. On typical Linux distributions, groups such as render and video control access to relevant device nodes.

    An administrative process launched from a terminal usually has sufficient access. The same application, registered as a boot-time service, often runs under a dedicated unprivileged account that does not belong to those device-access groups.

    The service manager may also apply isolation controls, including private mounts and capability restrictions. If the process cannot open the device node, the runtime may abandon its GPU backend. The only evidence might be an easily overlooked debug message—or no message at all.

    Adding the currently logged-in user to a device group does not fix a daemon running under a different account. Running the entire service as an administrator is also a poor long-term workaround: it grants excessive privileges, and changes made directly to a packaged unit file may disappear during an upgrade.

    Keep the dedicated service account unprivileged. Add the required device-access groups through the service configuration so that the process can open the rendering device without broadening access across the system.

    Root Cause 2: The Service Starts Before the Driver Is Ready

    Correct permissions do not eliminate a startup race.

    During boot, an inference service may start as soon as its network or default-target dependencies allow. Meanwhile, the GPU driver may need several more seconds to load firmware and create its device nodes.

    The sequence can look like this:

    1. The service starts and immediately probes for a GPU.
    2. The driver has not yet registered the device node, so the probe finds no available device.
    3. The runtime selects CPU execution for the rest of that process’s lifetime.
    4. The device node appears a few seconds later, but the process does not probe again.

    The driver is eventually available; the initial check simply happened too early. Many runtimes do not automatically retry device discovery while running.

    Manually restarting the service after the failure often restores GPU acceleration because the device node now exists. The next cold boot can reproduce the same problem, making a deterministic startup race look intermittent.

    A short delay before the main process starts is a practical mitigation. Where supported, explicitly ordering the service after device readiness is preferable. Choose the delay from the time the local driver actually needs to become ready, with a small margin. A delay that is too short can still miss the device; one that is unnecessarily long slows boot and service recovery.

    Why Ad Hoc Commands Are Not a Persistent Fix

    Common workarounds include manually restarting the service after every reboot, changing group membership through login scripts, or inserting a delay into an application startup command.

    These actions can help confirm the diagnosis, but they do not establish a reliable service configuration:

    • Package upgrades may replace the distribution-provided unit file and overwrite direct edits.
    • Group-membership changes require refreshed process credentials. An existing daemon does not automatically inherit them.
    • External clients connect to the service endpoint; they do not make the server repeat GPU discovery.

    Put the device groups, documented GPU-backend setting, and startup delay in a higher-priority service-manager override instead.

    A systemd drop-in is merged with the main unit after the manager reloads its configuration. Because it is separate from the packaged unit file, it normally survives package upgrades and provides a durable operational baseline.

    Apply the Persistent Configuration

    The following example uses a generic service name. Replace your-inference.service with the actual inference unit.

    Any environment variable used to select or enable the GPU backend must come from the runtime’s official documentation. Do not invent a setting or assume that the same variable applies across runtimes.

    1. Create a Drop-In Directory

    Avoid modifying the package-provided unit directly:

    1. sudo mkdir -p /etc/systemd/system/your-inference.service.d

    2. Create the Override File

    1. sudo nano /etc/systemd/system/your-inference.service.d/override.conf

    3. Add the Service Directives

    Use the following structure. The environment line is an illustrative placeholder, not a real runtime setting. Replace both its variable name and value with the documented setting before enabling it.

    1. [Service]
    2. # Replace this placeholder with the runtime's documented GPU backend setting.
    3. # Environment="DOCUMENTED_GPU_BACKEND_VARIABLE=DOCUMENTED_VALUE"
    4. SupplementaryGroups=render video
    5. ExecStartPre=/bin/sleep 5

    These directives address separate concerns:

    • The documented environment setting explicitly selects or enables the GPU backend, where the runtime provides such a setting. Its behavior depends on the runtime; enabling a backend does not necessarily prohibit CPU fallback.
    • SupplementaryGroups adds device-access groups to this service process without promoting the dedicated account to an administrator or depending on the operator’s next login.
    • ExecStartPre runs before the main application, delaying device discovery long enough to avoid the driver-registration window.

    The 5-second delay is only a starting point. Base the final value on measurements of how long the target machine takes to expose a stable rendering device after boot.

    Use only the device groups required on that machine. If service isolation still prevents device access, group membership alone may not resolve the problem; do not respond by indiscriminately disabling isolation.

    4. Reload the Service Manager and Restart the Unit

    Reload the service manager’s configuration, then restart the inference service so the override applies.

    Saving the file alone is not enough. Without a reload and restart, the running process still uses its previous configuration and credentials.

    Verify the Fix After a Cold Boot

    Do at least one cold-boot test. Restarting the process in an already-running session does not exercise the original startup race.

    Check the following:

    • The service manager has merged the drop-in, and the effective unit configuration includes the supplementary groups and pre-start command.
    • The rendering device belongs to render or the equivalent device-access group, and the service process’s supplementary groups include it.
    • GPU utilization rises with inference requests after a cold boot, rather than the CPU remaining saturated while the GPU is idle.
    • Requests from external applications, scheduled tasks, or reverse proxies use the same accelerated execution path as manual requests.
    • Service logs contain no remaining device-open failures or backend-fallback messages.

    The absence of errors is not proof of GPU execution. Always cross-check logs and service status against actual device utilization.

    If the runtime still falls back after the delay, distinguish permissions from timing:

    A permission problem persists after the device node exists. Opening the device still fails with an access-denied error. Increasing the startup delay will not fix it.

    A timing problem disappears when the service restarts after the device appears. This indicates that the process has sufficient access, but its first probe occurred too early.

    Other failures require a different investigation. A driver that never loads, a device held exclusively by another session, or a runtime built without the required GPU backend is outside these two root causes. Confirm the kernel module and device nodes before changing service configuration further.

    Operational Considerations

    A startup delay is not a substitute for a dependency relationship. Where the system supports ordering the service after the relevant device unit, prefer explicit ordering and use a short delay only as a fallback.

    An excessive delay can cause health checks to fail before the service begins listening. In an orchestrated environment, repeated restarts may then amplify the problem rather than solve it.

    Keep supplementary groups to the minimum required set. Do not run the entire service as an administrator or remove isolation merely to make device access easier.

    GPU-backend settings must come from the runtime’s public documentation. An incorrect environment-variable name does not enable additional acceleration; it can leave the configuration looking complete while the runtime continues using its default discovery behavior.

    Likewise, do not treat a delay measured for one integrated GPU, or a device-node number observed with one driver version, as a universal constant. Device numbering can change on multi-GPU systems, and readiness time varies with firmware and kernel behavior.

    On the target machine, record when the device node appears and when the service first probes for it. Adjust dependencies or the delay to cover that window reliably.

    Finally, turn the troubleshooting process into a repeatable acceptance check: cold boot, inspect device groups, observe GPU utilization, and test requests from external callers.

    Continuing to serve requests after acceleration fails is an availability feature, not an observability guarantee. A persistent fix requires service-level permissions, appropriate startup timing, and documented backend selection—verified after reboot by actual GPU activity, not merely by a running process.