Install nvidia profile to get around cuda p2 state issue, even without vulkan video encoding

This commit is contained in:
dec05eba
2026-05-02 01:57:17 +02:00
parent 2f23dcf29a
commit 02ed0cd4fc
3 changed files with 42 additions and 3 deletions

View File

@@ -164,8 +164,10 @@ GPU Screen Recorder has much better performance than OBS Studio even with versio
It is recommended to save the video to a SSD because of the large file size, which a slow HDD might not be fast enough to handle. Using variable framerate mode (-fm vfr) which is the default is also recommended as this reduces encoding load. Ultra quality is also overkill most of the time, very high (the default) or lower quality is usually enough.\ It is recommended to save the video to a SSD because of the large file size, which a slow HDD might not be fast enough to handle. Using variable framerate mode (-fm vfr) which is the default is also recommended as this reduces encoding load. Ultra quality is also overkill most of the time, very high (the default) or lower quality is usually enough.\
Note that for best performance you should close other screen recorders such as OBS Studio when using GPU Screen Recorder even if they are not recording, since they can affect performance even when idle. This is the case with OBS Studio. Note that for best performance you should close other screen recorders such as OBS Studio when using GPU Screen Recorder even if they are not recording, since they can affect performance even when idle. This is the case with OBS Studio.
## Note about optimal performance on NVIDIA ## Note about optimal performance on NVIDIA
NVIDIA driver has a "feature" (read: bug) where it will downclock memory transfer rate when a program uses cuda (or nvenc, which uses cuda), such as GPU Screen Recorder. NVIDIA driver has a "feature" (read: bug) where it will downclock memory transfer rate when a program uses cuda (or nvenc, which uses cuda), such as GPU Screen Recorder. This can affect game performance.
This issue doesn't happen with vulkan video encoding so you may have better performance in games when recording with vulkan video. GPU Screen Recorder installs an NVIDIA profile on the system (`~/.nv/nvidia-application-profiles-rc.d/10-gsr-cuda-no-stable-perf-limit`) to get around this issue but this requires a relatively
new NVIDIA driver version (~580). If you have an older NVIDIA driver then you can choose to record with vulkan video encoding instead as it doesn't have this issue.
You can use vulkan video encoding by adding `_vulkan` at the end of the video codec option, for example: `-k h264_vulkan` or a full command example: `gpu-screen-recorder -w screen -k h264_vulkan -o video.mp4`. You can use vulkan video encoding by adding `_vulkan` at the end of the video codec option, for example: `-k h264_vulkan` or a full command example: `gpu-screen-recorder -w screen -k h264_vulkan -o video.mp4`.
Vulkan video encoding in GPU Screen Recorder supports `h264`, `hevc` and `av1` (along with `hdr` and `10bit` options), assuming your gpu drivers, ffmpeg and vulkan is up to date. Vulkan video encoding in GPU Screen Recorder supports `h264`, `hevc` and `av1` (along with `hdr` and `10bit` options), assuming your gpu drivers, ffmpeg and vulkan is up to date.

View File

@@ -280,7 +280,7 @@ HDR options not available on X11 or portal capture. 10-bit capture reduces bandi
.br .br
Vulkan codec options are experimental. They may not work properly on your system because of GPU driver issues. Vulkan codec options are experimental. They may not work properly on your system because of GPU driver issues.
.br .br
Using vulkan codecs may result in better gaming performance, especially on NVIDIA as it doesn't suffer from an issue known as "cuda p2 state" Using vulkan codecs may result in better gaming performance with older NVIDIA gpu drivers, as vulkan video encoding doesn't suffer from an issue known as "cuda p2 state"
.br .br
where the GPU gets downclocked when using nvenc (regular video codecs on NVIDIA). where the GPU gets downclocked when using nvenc (regular video codecs on NVIDIA).

View File

@@ -3571,7 +3571,43 @@ static void validate_args_with_capture_sources(args_parser &arg_parser, const st
} }
static void install_cuda_no_stable_perf_limit() { static void install_cuda_no_stable_perf_limit() {
const char *home = getenv("HOME");
if(!home) {
fprintf(stderr, "gsr warning: install_cuda_no_stable_perf_limit: $HOME not set\n");
return;
}
char nv_profiles_path[4096];
snprintf(nv_profiles_path, sizeof(nv_profiles_path), "%s/.nv/nvidia-application-profiles-rc.d", home);
if(create_directory_recursive(nv_profiles_path) != 0) {
fprintf(stderr, "gsr warning: install_cuda_no_stable_perf_limit: failed to create directory: %s\n", nv_profiles_path);
return;
}
snprintf(nv_profiles_path, sizeof(nv_profiles_path), "%s/.nv/nvidia-application-profiles-rc.d/10-gsr-cuda-no-stable-perf-limit", home);
FILE *f = fopen(nv_profiles_path, "wb");
if(!f) {
fprintf(stderr, "gsr warning: install_cuda_no_stable_perf_limit: failed to create file: %s\n", nv_profiles_path);
return;
}
const char *profile_data =
"{\n"
" \"profiles\": [\n"
" {\n"
" \"name\": \"CudaNoStablePerfLimit\",\n"
" \"settings\": [\"0x166c5e\", 0]\n"
" }\n"
" ],\n"
" \"rules\": [\n"
" { \"pattern\": \"gpu-screen-recorder\", \"profile\": \"CudaNoStablePerfLimit\" }\n"
" ]\n"
"}\n";
fwrite(profile_data, 1, strlen(profile_data), f);
fclose(f);
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
@@ -3593,6 +3629,7 @@ int main(int argc, char **argv) {
signal(SIGRTMIN+6, save_replay_30_minutes_handler); signal(SIGRTMIN+6, save_replay_30_minutes_handler);
set_display_server_environment_variables(); set_display_server_environment_variables();
install_cuda_no_stable_perf_limit();
// Linux nvidia driver 580.105.08 added the environment variable CUDA_DISABLE_PERF_BOOST to disable the p2 power level issue, // Linux nvidia driver 580.105.08 added the environment variable CUDA_DISABLE_PERF_BOOST to disable the p2 power level issue,
// where running cuda (which includes nvenc) causes the gpu to be forcefully set to p2 power level which on many nvidia gpus // where running cuda (which includes nvenc) causes the gpu to be forcefully set to p2 power level which on many nvidia gpus