You are not logged in.

#1 2023-04-12 16:39:34

TRex
Member
Registered: 2011-08-21
Posts: 21

Running CUDA applications in a systemd unit (fails)

Hi,

I'm trying to run a CUDA application (easy-diffusion, for the records) in a systemd unit. The unit:

[Unit]
Description=Easy Diffusion Service

[Service]
Type=simple
ExecStart=/opt/easy-diffusion/start.sh
WorkingDirectory=/opt/easy-diffusion/
Environment=NVIDIA_VISIBLE_DEVICES=all

[Install]
WantedBy=default.target

The outcome:

18:21:23.489 ERROR MainThread CUDA unknown error - this may be due to an incorrectly set up environment, e.g. changing env variable CUDA_VISIBLE_DEVICES after program start. Setting the available devices to be zero.
18:21:23.497 WARNING MainThread WARNING: Could not find a compatible GPU. Using the CPU, but this will be very slow!

It works running locally, so I assume either something missing in the environment or systemd running some form of isolation. I found some problems from users with docker, which is where I got the NVIDIA_VISIBLE_DEVICES from. I've created the unit as a --user unit.

Any idea?

Offline

#2 2023-04-12 16:42:57

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,292

Re: Running CUDA applications in a systemd unit (fails)

You'll probably want to enable the nvidia-persistenced.service for these kind of usecases, is that the case? It could also shoot too early if your nvidia modules aren't yet loaded/in which case  you might want to enable early module loading: https://wiki.archlinux.org/title/NVIDIA#Early_loading

Last edited by V1del (2023-04-12 16:46:25)

Offline

#3 2023-04-12 16:55:00

TRex
Member
Registered: 2011-08-21
Posts: 21

Re: Running CUDA applications in a systemd unit (fails)

For the latter: no, I'm starting it (the unit) from a running desktop, so everything is up and dandy. But thanks for the hint, it might be problematic to start it automatically (I might not want that, though - not sure yet).

Offline

Board footer

Powered by FluxBB