[SOLVED] Power down offscreen card after use.

Hi, first post here. I’ll try to be as specific as possible.

What I have:
Mint Linux, Dell m6700 with k3000m in prime Intel powersave mode. NVidia driver version 387.34

What I want to do:
Run the notebook in prime Intel powersave mode, occasionaly offload tasks via CUDA or OpenCL to the k3000m, also debugging on the card.

What I currently do:

This script, named “with-cuda”

#!/bin/bash
# run a program with access to CUDA
# e.g. with-cuda ./deviceQuery
ver=387
libs=/tmp/nvidia-libs-$ver-$UID/
mkdir -p $libs
ln -fs /usr/lib/nvidia-$ver/*nv* $libs
export LD_LIBRARY_PATH=$libs
nvidia-smi # trigger loading nvidia modules as non-root
exec $@
unshadows the nvdia specific libraries (but not libGL et at), activates the card and executes a consumer. 

What works:
Everything works as intended, can launch nsight and debug CUDA, OpenCL works too.

What does not work:
Turning off the card again. Loading the kernel modules powers the card on, but unloading them does not power the card down, as it seems as I figured by inspecting the power stats of my battery: Idle consumption after boot is ~16W (Intel graphics only), but remains ~24W after executing anything using “with-cuda”

What I tried:
unloading the kernel modules
=> no idle power reduction

# env LD_LIBRARY_PATH=/usr/lib/nvidia-387 nvidia-smi drain -p 0000:01:00.0 -m 0
Successfully set GPU 0000:01:00.0 drain state to: not draining.
# env LD_LIBRARY_PATH=/usr/lib/nvidia-387 nvidia-smi drain -p 0000:01:00.0 -r
Failed to remove the specified GPU.
	=> no idle power reduction

What I would like to know:
A way to power down the card when not in use anymore, because it increases idle consumption in battery mode by 50%.

try using nvidia-prime

[url]drivers - How can I switch back to Nvidia card from Intel with Nvidia-prime - Ask Ubuntu

I’m using prime obviously: “Mint Linux, Dell m6700 with k3000m in prime Intel powersave mode. NVidia driver version 387.34”

I’m aware that you are “using” prime, but my suggestion is to do explicitly this:

sudo prime-select intel

when you want to shut off the NVIDIA adapter. Nowhere in your description of “What I tried” did you indicate that you tried that.

The suggestion is contained in the linked forum article. Did you read it?

The poster there indicated the same issue you are concerned about (power draw) and indicated that that suggestion “worked”.

Rather than use your script to turn the NVIDIA GPU on, use the prime-select command. Rather than trying to unload the drivers to turn it off again, use the prime-select command.

Thanks for the clarification. I’ve read the article, but it lookes like the poster back then had a problem with switching between intel and nvidia prime profiles, hitting a bug in a 4 year old driver. This seemed unrelated to my problem (I don’t switch profiles, don’t run the server on the nvidia card etc.). However, switching the profiles, as suggested, has no effect on idle energy consumption on my computer.

What works however is: Logging off from the session (with or without prime-select issued beforehand) brings consumption back to the old level again - which is a bit surprising, because I don’t why restarting an x11-xorg-intel server should power down the unrelated nvidia card - (probably part of the prime setup to disable the unselected video adapter?) - but on the other hand it indicates, that it should indeed be possible to power down the card as I would like to.

Allright, inspecting /var/log/syslog revealed, that initializing the offline card makes systemd start a couple of nvidia related services and during logging off the session, it cleans them up again. During the cleanup it unloads the nvidia modules and uses bbswitch to power the card down.

I verfied that

rmmod nvidia_uvm nvidia_drm nvidia_modeset nvidia

echo OFF >/proc/acpi/bbswitch

in fact powers down the card. Also the card would power up again when I’m using the “with-cuda” script. So I think this solves my problem.