Error installing CUDA 11.8 on Ubuntu 22.04

I’m trying to install CUDA 11.8 on Ubuntu 22.04 on RTX 2060 laptop.
My gcc version is 11.4.0
My kernel 6.5.0-27-generic

I have run the command sudo sh cuda_11.8.0_520.61.05_linux.run and I get an error.

cuda-installer.log
[INFO]: Driver installation detected by command: apt list --installed | grep -e nvidia-driver-[0-9][0-9][0-9] -e nvidia-[0-9][0-9][0-9]
[INFO]: Cleaning up window
[INFO]: Complete
[INFO]: Checking compiler version…
[INFO]: gcc location: /usr/bin/gcc

[INFO]: gcc version: gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)

[INFO]: Initializing menu
[INFO]: nvidia-fs.setKOVersion(2.13.5)
[INFO]: Setup complete
[INFO]: Components to install:
[INFO]: Driver
[INFO]: 520.61.05
[INFO]: Executing NVIDIA-Linux-x86_64-520.61.05.run --ui=none --no-questions --accept-license --disable-nouveau --no-cc-version-check --install-libglvnd 2>&1
[INFO]: Finished with code: 256
[ERROR]: Install of driver component failed. Consult the driver log at /var/log/nvidia-installer.log for more details.
[ERROR]: Install of 520.61.05 failed, quitting

nvidia-installer.log
→ The command cd ./kernel; /usr/bin/make -k -j12 NV_EXCLUDE_KERNEL_MODULES="" SYSSRC="/lib/modules/6.5.0-27-generic/build" SYSOUT="/lib/modules/6.5.0-27-generic/build" NV_KERNEL_MODULES="nvidia" failed with the following output:

make[1]: Entering directory ‘/usr/src/linux-headers-6.5.0-27-generic’
warning: the compiler differs from the one used to build the kernel
The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
You are using: cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

Warning: Compiler version check failed:

The major and minor number of the compiler used to
compile the kernel:

x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38

does not match the compiler used here:

cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

It is recommended to set the CC environment variable
to the compiler that was used to compile the kernel.

To skip the test and silence this warning message, set
the IGNORE_CC_MISMATCH environment variable to “1”.
However, mixing compiler versions between the kernel
and kernel modules can result in subtle bugs that are
difficult to diagnose.

*** Failed CC version check. ***

CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv.o
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-pci.o
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-dmabuf.o
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-acpi.o
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-cray.o
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-dma.o
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-i2c.o
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-mmap.o
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-p2p.o
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-pat.o
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-procfs.o
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-procfs-utils.o
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv.o] Error 1
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-usermap.o
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-dmabuf.o] Error 1
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-pci.o] Error 1
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-vm.o
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-acpi.o] Error 1
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-cray.o] Error 1
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-vtophys.o
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-interface.o
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-dma.o] Error 1
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-mlock.o
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-pci.o
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-i2c.o] Error 1
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-mmap.o] Error 1
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-registry.o
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-p2p.o] Error 1
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-pat.o] Error 1
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-usermap.o
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-modeset-interface.o
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-procfs.o] Error 1
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-pci-table.o
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-procfs-utils.o] Error 1
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-memdbg.o
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-kthread-q.o
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-usermap.o] Error 1
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-vm.o] Error 1
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-ibmnpu.o
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-vtophys.o] Error 1
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-report-err.o
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-interface.o] Error 1
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-rsync.o
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-msi.o
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-mlock.o] Error 1
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-caps.o
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-pci.o] Error 1
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-frontend.o
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-registry.o] Error 1
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-usermap.o] Error 1
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv_uvm_interface.o
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-modeset-interface.o] Error 1
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nvlink_caps.o
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-pci-table.o] Error 1
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nvlink_linux.o
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/linux_nvswitch.o
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-memdbg.o] Error 1
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/procfs_nvswitch.o
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-kthread-q.o] Error 1
CC [M] /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/i2c_nvswitch.o
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-ibmnpu.o] Error 1
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-report-err.o] Error 1
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-rsync.o] Error 1
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-msi.o] Error 1
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-frontend.o] Error 1
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv_uvm_interface.o] Error 1
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-caps.o] Error 1
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nvlink_caps.o] Error 1
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/linux_nvswitch.o] Error 1
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/procfs_nvswitch.o] Error 1
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nvlink_linux.o] Error 1
cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/i2c_nvswitch.o] Error 1
make[3]: Target ‘/tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel/’ not remade because of errors.
make[2]: *** [/usr/src/linux-headers-6.5.0-27-generic/Makefile:2039: /tmp/selfgz3398/NVIDIA-Linux-x86_64-520.61.05/kernel] Error 2
make[2]: Target ‘modules’ not remade because of errors.
make[1]: *** [Makefile:234: __sub-make] Error 2
make[1]: Target ‘modules’ not remade because of errors.
make[1]: Leaving directory ‘/usr/src/linux-headers-6.5.0-27-generic’
make: *** [Makefile:82: modules] Error 2
ERROR: The nvidia kernel module was not created.
ERROR: Installation has failed. Please see the file ‘/var/log/nvidia-installer.log’ for details. You may find suggestions on fixing installation problems in the README available on the Linux driver download page at www.nvidia.com.

I have upgraded gcc to 12.3.0 and I get the following one in nvidia-installer.log:

→ The command cd ./kernel; /usr/bin/make -k -j12 NV_EXCLUDE_KERNEL_MODULES="" SYSSRC="/lib/modules/6.5.0-27-generic/build" SYSOUT="/lib/modules/6.5.0-27-generic/build" NV_KERNEL_MODULES="nvidia" failed with the following output:

make[1]: Entering directory ‘/usr/src/linux-headers-6.5.0-27-generic’
warning: the compiler differs from the one used to build the kernel
The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
You are using: cc (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
CC [M] /tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-mmap.o
CC [M] /tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-mlock.o
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-mmap.c: In function ‘nvidia_mmap_numa’:
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-mmap.c:446:19: error: assignment of read-only member ‘vm_flags’
446 | vma->vm_flags |= VM_MIXEDMAP;
| ^~
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-mmap.c: In function ‘nvidia_mmap_helper’:
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-mmap.c:580:23: error: assignment of read-only member ‘vm_flags’
580 | vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND;
| ^~
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-mmap.c:647:23: error: assignment of read-only member ‘vm_flags’
647 | vma->vm_flags |= (VM_IO | VM_LOCKED | VM_RESERVED);
| ^~
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-mmap.c:648:23: error: assignment of read-only member ‘vm_flags’
648 | vma->vm_flags |= (VM_DONTEXPAND | VM_DONTDUMP);
| ^~
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-mmap.c:654:23: error: assignment of read-only member ‘vm_flags’
654 | vma->vm_flags &= ~VM_WRITE;
| ^~
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-mmap.c:655:23: error: assignment of read-only member ‘vm_flags’
655 | vma->vm_flags &= ~VM_MAYWRITE;
| ^~
In file included from ./arch/x86/include/asm/preempt.h:7,
from ./include/linux/preempt.h:79,
from ./include/linux/spinlock.h:56,
from /tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/common/inc/nv-lock.h:29,
from /tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/common/inc/nv-linux.h:32,
from /tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-mlock.c:27:
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-mlock.c: In function ‘os_lock_user_pages’:
./arch/x86/include/asm/current.h:44:17: warning: passing argument 1 of ‘get_user_pages’ makes integer from pointer without a cast [-Wint-conversion]
44 | define current get_current()
| ^~~~~~~~~~~~~
| |
| struct task_struct *
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/common/inc/nv-mm.h:54:24: note: in expansion of macro ‘current’
54 | get_user_pages(current, current->mm, start, nr_pages, write, force, pages, vmas)
| ^~~~~~~
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-mlock.c:245:11: note: in expansion of macro ‘NV_GET_USER_PAGES’
245 | ret = NV_GET_USER_PAGES((unsigned long)address,
| ^~~~~~~~~~~~~~~~~
In file included from /tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/common/inc/nv-pgprot.h:30,
from /tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/common/inc/nv-linux.h:33:
./include/linux/mm.h:2430:35: note: expected ‘long unsigned int’ but argument is of type ‘struct task_struct *’
2430 | long get_user_pages(unsigned long start, unsigned long nr_pages,
| ^
In file included from /tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/common/inc/nv-linux.h:34:
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/common/inc/nv-mm.h:54:40: warning: passing argument 2 of ‘get_user_pages’ makes integer from pointer without a cast [-Wint-conversion]
54 | get_user_pages(current, current->mm, start, nr_pages, write, force, pages, vmas)
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-mlock.c:245:11: note: in expansion of macro ‘NV_GET_USER_PAGES’
245 | ret = NV_GET_USER_PAGES((unsigned long)address,
| ^
~~~~~~
./include/linux/mm.h:2430:56: note: expected ‘long unsigned int’ but argument is of type ‘struct mm_struct *’
2430 | long get_user_pages(unsigned long start, unsigned long nr_pages,
| ^~
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-mlock.c:246:29: warning: passing argument 4 of ‘get_user_pages’ makes pointer from integer without a cast [-Wint-conversion]
246 | page_count, write, force, user_pages, NULL);
| ^
~
| |
| NvU64 {aka long long unsigned int}
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/common/inc/nv-mm.h:54:53: note: in definition of macro ‘NV_GET_USER_PAGES’
54 | get_user_pages(current, current->mm, start, nr_pages, write, force, pages, vmas)
| ^~~~~~~~
./include/linux/mm.h:2431:59: note: expected ‘struct page **’ but argument is of type ‘NvU64’ {aka ‘long long unsigned int’}
2431 | unsigned int gup_flags, struct page **pages);
| ^
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/common/inc/nv-mm.h:54:9: error: too many arguments to function ‘get_user_pages’
54 | get_user_pages(current, current->mm, start, nr_pages, write, force, pages, vmas)
| ^
~~~
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-mlock.c:245:11: note: in expansion of macro ‘NV_GET_USER_PAGES’
245 | ret = NV_GET_USER_PAGES((unsigned long)address,
| ^~~~~~~~~~~~~~~~~
./include/linux/mm.h:2430:6: note: declared here
2430 | long get_user_pages(unsigned long start, unsigned long nr_pages,
| ^~~~~~~~~~~~~~
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-mmap.c: In function ‘nv_encode_caching’:
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-mmap.c:344:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
344 | if (NV_ALLOW_CACHING(memory_type))
| ^
/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-mmap.c:347:9: note: here
347 | default:
| ^~~~~~~
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/nv-mmap.o] Error 1
make[3]: *** [scripts/Makefile.build:251: /tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/nvidia/os-mlock.o] Error 1
make[3]: Target ‘/tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel/’ not remade because of errors.
make[2]: *** [/usr/src/linux-headers-6.5.0-27-generic/Makefile:2039: /tmp/selfgz20383/NVIDIA-Linux-x86_64-520.61.05/kernel] Error 2
make[2]: Target ‘modules’ not remade because of errors.
make[1]: *** [Makefile:234: __sub-make] Error 2
make[1]: Target ‘modules’ not remade because of errors.
make[1]: Leaving directory ‘/usr/src/linux-headers-6.5.0-27-generic’
make: *** [Makefile:82: modules] Error 2
ERROR: The nvidia kernel module was not created.
ERROR: Installation has failed. Please see the file ‘/var/log/nvidia-installer.log’ for details. You may find suggestions on fixing installation problems in the README available on the Linux driver download page at www.nvidia.com.

@danielfb2312 I have the exact same issue, did you find a fix? I believe gcc 12.3 is not compatible with CUDA 11.8, that is why we are getting this error