What @paolod said. Plus, there’s nvdia-smi
:
root@eagle:~# nvidia-smi
Thu Nov 25 22:07:39 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.82.00 Driver Version: 470.82.00 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:09:00.0 On | N/A |
| 0% 37C P8 7W / 120W | 413MiB / 6077MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1353 G /usr/lib/xorg/Xorg 176MiB |
| 0 N/A N/A 2456 G /usr/bin/kwin_x11 16MiB |
| 0 N/A N/A 2521 G /usr/bin/plasmashell 28MiB |
| 0 N/A N/A 2653 G telegram-desktop 1MiB |
| 0 N/A N/A 2862 G ...AAAAAAAAA= --shared-files 20MiB |
| 0 N/A N/A 9543 G /usr/bin/krunner 6MiB |
| 0 N/A N/A 22164 G /usr/lib/firefox/firefox 156MiB |
+-----------------------------------------------------------------------------+
To query only memory usage:
root@eagle:~# nvidia-smi -q -d MEMORY
==============NVSMI LOG==============
Timestamp : Thu Nov 25 22:08:36 2021
Driver Version : 470.82.00
CUDA Version : 11.4
Attached GPUs : 1
GPU 00000000:09:00.0
FB Memory Usage
Total : 6077 MiB
Used : 452 MiB
Free : 5625 MiB
BAR1 Memory Usage
Total : 256 MiB
Used : 7 MiB
Free : 249 MiB
Here is the output of the same commands, while darktable is processing a high-resulution image with diffuse or sharpen, which needs so much memory that the photo needs to be processed in pieces (using tiling):
root@eagle:~# nvidia-smi
Thu Nov 25 22:10:40 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.82.00 Driver Version: 470.82.00 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:09:00.0 On | N/A |
| 0% 52C P2 86W / 120W | 5762MiB / 6077MiB | 100% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1353 G /usr/lib/xorg/Xorg 176MiB |
| 0 N/A N/A 2456 G /usr/bin/kwin_x11 16MiB |
| 0 N/A N/A 2521 G /usr/bin/plasmashell 27MiB |
| 0 N/A N/A 2653 G telegram-desktop 1MiB |
| 0 N/A N/A 2862 G ...AAAAAAAAA= --shared-files 18MiB |
| 0 N/A N/A 9543 G /usr/bin/krunner 8MiB |
| 0 N/A N/A 22164 G /usr/lib/firefox/firefox 136MiB |
| 0 N/A N/A 24973 C ...able-master/bin/darktable 5367MiB |
+-----------------------------------------------------------------------------+
root@eagle:~# nvidia-smi -q -d MEMORY
==============NVSMI LOG==============
Timestamp : Thu Nov 25 22:10:35 2021
Driver Version : 470.82.00
CUDA Version : 11.4
Attached GPUs : 1
GPU 00000000:09:00.0
FB Memory Usage
Total : 6077 MiB
Used : 5762 MiB
Free : 315 MiB
BAR1 Memory Usage
Total : 256 MiB
Used : 7 MiB
Free : 249 MiB
The aim is to set the parameter so that you make use of almost all the memory on the card. Too high, and you don’t make full use of the RAM; too low, and you get the dreaded couldn’t enqueue kernel -4
error when darktable tries to allocate more than there is available. Here, I could lower the headroom a bit (I ‘waste’ about 300 MB of the 6 GB), but, depending on the number of applications I have running, the baseline will be different. If you decide to shut down everything else, and only have darktable running when processing images, you need not be that conservative, I think (losing 300 MB of your 2 GB might be a noticeable difference).
Also important to know (if you’re running on an old machine with little RAM – until this spring I had 4 GB only) is that you may get a could not create context for device 0: -6
error if you do not have enough computer memory free. That happened with my old machine; closing a few apps and re-launching darktable got OpenCL working again.