Error! Bad return status for module build on kernel: 4.13.0-37-generic (x86_64)

I’m install Cuda 9.0 on a fresh image of Unbuntu 16 but the install returns an error. Also, if I restart, the desktop will not load correctly. I’m presented with the login screen but after entering the password it tries to load the desktop but kicks back out to the login screen.


*** Reboot your computer and verify that the NVIDIA graphics driver can ***
*** be loaded. ***


INFO:Enable nvidia-387
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/lenovo_thinkpad
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/dell_latitude
Adding system user nvidia-persistenced' (UID 121) ... Adding new group nvidia-persistenced’ (GID 129) …
Adding new user nvidia-persistenced' (UID 121) with group nvidia-persistenced’ …
Not creating home directory `/’.
Loading new nvidia-387-387.26 DKMS files…
First Installation: checking all kernels…
Building only for 4.13.0-37-generic
Building for architecture x86_64
Building initial module for 4.13.0-37-generic
Error! Bad return status for module build on kernel: 4.13.0-37-generic (x86_64)
Consult /var/lib/dkms/nvidia-387/387.26/build/make.log for more information.

Following are contents of the make.log file.

DKMS make.log for nvidia-387-387.26 for kernel 4.13.0-37-generic (x86_64)
Tue Mar 20 09:49:04 CDT 2018
make[1]: Entering directory ‘/usr/src/linux-headers-4.13.0-37-generic’
SYMLINK /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-kernel.o
SYMLINK /var/lib/dkms/nvidia-387/387.26/build/nvidia-modeset/nv-modeset-kernel.o
CONFTEST: remap_pfn_range
CONFTEST: hash__remap_4k_pfn
CONFTEST: follow_pfn
CONFTEST: vmap
CONFTEST: INIT_WORK
CONFTEST: set_pages_uc
CONFTEST: set_memory_uc
CONFTEST: set_memory_array_uc
CONFTEST: change_page_attr
CONFTEST: pci_get_class
CONFTEST: pci_choose_state
CONFTEST: acpi_device_id
CONFTEST: vm_insert_page
CONFTEST: acquire_console_sem
CONFTEST: console_lock
CONFTEST: kmem_cache_create
CONFTEST: on_each_cpu
CONFTEST: smp_call_function
CONFTEST: acpi_evaluate_integer
CONFTEST: ioremap_cache
CONFTEST: acpi_walk_namespace
CONFTEST: ioremap_wc
CONFTEST: pci_domain_nr
CONFTEST: pci_dma_mapping_error
CONFTEST: sg_alloc_table
CONFTEST: sg_init_table
CONFTEST: pci_get_domain_bus_and_slot
CONFTEST: get_num_physpages
CONFTEST: efi_enabled
CONFTEST: proc_create_data
CONFTEST: pde_data
CONFTEST: proc_remove
CONFTEST: pm_vt_switch_required
CONFTEST: xen_ioemu_inject_msi
CONFTEST: phys_to_dma
CONFTEST: get_dma_ops
CONFTEST: write_cr4
CONFTEST: of_get_property
CONFTEST: of_find_node_by_phandle
CONFTEST: of_node_to_nid
CONFTEST: pnv_pci_get_npu_dev
CONFTEST: for_each_online_node
CONFTEST: node_end_pfn
CONFTEST: pci_bus_address
CONFTEST: pci_stop_and_remove_bus_device
CONFTEST: pci_remove_bus_device
CONFTEST: request_threaded_irq
CONFTEST: register_cpu_notifier
CONFTEST: cpuhp_setup_state
CONFTEST: backlight_device_register
CONFTEST: remap_page_range
CONFTEST: address_space_init_once
CONFTEST: kbasename
CONFTEST: fatal_signal_pending
CONFTEST: list_cut_position
CONFTEST: vzalloc
CONFTEST: wait_on_bit_lock_argument_count
CONFTEST: bitmap_clear
CONFTEST: usleep_range
CONFTEST: radix_tree_empty
CONFTEST: drm_dev_unref
CONFTEST: drm_reinit_primary_mode_group
CONFTEST: drm_atomic_set_mode_for_crtc
CONFTEST: drm_atomic_clean_old_fb
CONFTEST: get_user_pages_remote
CONFTEST: drm_gem_object_lookup
CONFTEST: drm_atomic_state_free
CONFTEST: drm_driver_has_gem_prime_res_obj
CONFTEST: drm_atomic_helper_disable_all
CONFTEST: drm_atomic_helper_set_config
CONFTEST: drm_atomic_helper_connector_dpms
CONFTEST: is_export_symbol_gpl_of_node_to_nid
CONFTEST: i2c_adapter
CONFTEST: pm_message_t
CONFTEST: irq_handler_t
CONFTEST: acpi_device_ops
CONFTEST: acpi_op_remove
CONFTEST: outer_flush_all
CONFTEST: proc_dir_entry
CONFTEST: scatterlist
CONFTEST: sg_table
CONFTEST: file_operations
CONFTEST: vm_operations_struct
CONFTEST: atomic_long_type
CONFTEST: pci_save_state
CONFTEST: file_inode
CONFTEST: task_struct
CONFTEST: kuid_t
CONFTEST: dma_ops
CONFTEST: dma_map_ops
CONFTEST: noncoherent_swiotlb_dma_ops
CONFTEST: vm_fault_present
CONFTEST: vm_fault_has_address
CONFTEST: kernel_write
CONFTEST: strnstr
CONFTEST: iterate_dir
CONFTEST: kstrtoull
CONFTEST: backlight_properties_type
CONFTEST: fault_flags
CONFTEST: atomic64_type
CONFTEST: address_space
CONFTEST: backing_dev_info
CONFTEST: mm_context_t
CONFTEST: vm_ops_fault_removed_vma_arg
CONFTEST: pnv_npu2_init_context
CONFTEST: drm_bus_present
CONFTEST: drm_bus_has_bus_type
CONFTEST: drm_bus_has_get_irq
CONFTEST: drm_bus_has_get_name
CONFTEST: drm_driver_has_legacy_dev_list
CONFTEST: drm_driver_has_set_busid
CONFTEST: drm_crtc_state_has_connectors_changed
CONFTEST: drm_init_function_args
CONFTEST: drm_mode_connector_list_update_has_merge_type_bits_arg
CONFTEST: drm_helper_mode_fill_fb_struct
CONFTEST: drm_master_drop_has_from_release_arg
CONFTEST: drm_mode_config_funcs_has_atomic_state_alloc
CONFTEST: drm_driver_unload_has_int_return_type
CONFTEST: kref_has_refcount_of_type_refcount_t
CONFTEST: drm_crtc_helper_funcs_has_atomic_enable
CONFTEST: dom0_kernel_present
CONFTEST: nvidia_vgpu_kvm_build
CONFTEST: nvidia_grid_build
CONFTEST: drm_available
CONFTEST: drm_atomic_available
CONFTEST: drm_atomic_modeset_nonblocking_commit_available
CONFTEST: is_export_symbol_gpl_refcount_inc
CONFTEST: is_export_symbol_gpl_refcount_dec_and_test
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-gpu-numa.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-acpi.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-cray.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-chrdev.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-dma.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-gvi.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-i2c.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-mempool.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-mmap.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-p2p.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-pat.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-procfs.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-usermap.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-vm.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-vtophys.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/os-interface.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/os-mlock.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/os-pci.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/os-registry.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/os-usermap.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-modeset-interface.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-pci-table.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-memdbg.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-report-err.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-ibmnpu.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv_uvm_interface.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nvlink_linux.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-frontend.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-kthread-q.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-kthread-q-selftest.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia/nv-instance.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm_utils.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm_common.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm_linux.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/nvstatus.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/nvCpuUuid.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_tools.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_global.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_gpu.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_gpu_isr.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_procfs.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_va_space.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_gpu_semaphore.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_mem.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_rm_mem.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_channel.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_lock.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_hal.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_range_tree.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_range_allocator.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_va_range.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_va_block.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_range_group.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_gpu_replayable_faults.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_gpu_non_replayable_faults.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_gpu_access_counters.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_perf_events.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_perf_module.o
In file included from ./arch/x86/include/asm/cpufeature.h:4:0,
from ./arch/x86/include/asm/thread_info.h:63,
from ./include/linux/thread_info.h:37,
from ./arch/x86/include/asm/preempt.h:6,
from ./include/linux/preempt.h:80,
from ./include/linux/spinlock.h:50,
from /var/lib/dkms/nvidia-387/387.26/build/common/inc/nv-lock.h:16,
from /var/lib/dkms/nvidia-387/387.26/build/common/inc/nv-linux.h:19,
from /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm_linux.h:39,
from /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_va_block.c:24:
/var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_va_block.c: In function ‘block_cpu_fault_locked’:
./arch/x86/include/asm/processor.h:818:39: error: implicit declaration of function ‘task_stack_page’ [-Werror=implicit-function-declaration]
unsigned long __ptr = (unsigned long)task_stack_page(task);
^
./arch/x86/include/asm/processor.h:895:26: note: in expansion of macro ‘task_pt_regs’
#define KSTK_EIP(task) (task_pt_regs(task)->ip)
^
/var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_va_block.c:9035:41: note: in expansion of macro ‘KSTK_EIP’
KSTK_EIP(current));
^
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_mmu.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_pte_batch.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_tlb_batch.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_push.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_pushbuffer.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_thread_context.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_tracker.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_kepler.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_kepler_ce.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_kepler_host.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_kepler_mmu.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_maxwell.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_maxwell_host.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_pascal.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_pascal_ce.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_pascal_host.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_pascal_mmu.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_pascal_fault_buffer.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_volta_host.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_volta.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_volta_fault_buffer.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_volta_access_counter_buffer.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_policy.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_perf_utils.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_kvmalloc.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_pmm_gpu.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_migrate.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_map_external.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_user_channel.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_hmm.o
CC [M] /var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_perf_heuristics.o
cc1: some warnings being treated as errors
scripts/Makefile.build:308: recipe for target ‘/var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_va_block.o’ failed
make[2]: *** [/var/lib/dkms/nvidia-387/387.26/build/nvidia-uvm/uvm8_va_block.o] Error 1
make[2]: *** Waiting for unfinished jobs…
Makefile:1550: recipe for target ‘module/var/lib/dkms/nvidia-387/387.26/build’ failed
make[1]: *** [module/var/lib/dkms/nvidia-387/387.26/build] Error 2
make[1]: Leaving directory ‘/usr/src/linux-headers-4.13.0-37-generic’
Makefile:84: recipe for target ‘modules’ failed
make: *** [modules] Error 2

Don’t try to install an R387 driver on a linux kernel 4.13 or newer. Use the latest R390 driver for your GPU. This is mentioned in a number of recent posts on this forum, and you will find descriptions of how to do this as well.

@txbob - I followed steps outlined in the following link to uninstall nouveau and install NVIDIA 390. The process worked and after reboot N390 was the loaded/active driver. https://askubuntu.com/questions/481414/install-nvidia-driver-instead-of-nouveau

But during the installation of cuda toolkit 9.1, the installer attempted to remove N390 and replace it with N387 driver. Installer failed at the same location as previously reported. Please see log

nvidia-installer log file ‘/var/log/nvidia-uninstall.log’
creation time: Tue Mar 20 13:41:33 2018
installer version: 390.42

PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

nvidia-installer command line:
/usr/bin/nvidia-uninstall
-s

Using built-in stream user interface
-> Detected 8 CPUs online; setting concurrency level to 8.
-> If you plan to no longer use the NVIDIA driver, you should make sure that no X screens are configured to use the NVIDIA X driver in your X configuration file. If you used nvidia-xconfig to configure X, it may have created a backup of your original configuration. Would you like to run nvidia-xconfig --restore-original-backup to attempt restoration of the original X configuration file? (Answer: No)
-> Parsing log file:
-> done.
-> Validating previous installation:
-> Unable to access previously installed symlink ‘/usr/lib/x86_64-linux-gnu/libGL.so’ (No such file or directory).
-> done.
WARNING: Your driver installation has been altered since it was initially installed; this may happen, for example, if you have since installed the NVIDIA driver through a mechanism other than nvidia-installer (such as your distribution’s native package management system). nvidia-installer will attempt to uninstall as best it can. Please see the file ‘/var/log/nvidia-uninstall.log’ for details.
-> Uninstalling NVIDIA Accelerated Graphics Driver for Linux-x86_64 (1.0-39042 (390.42)):
-> DKMS module detected; removing…
-> done.
-> Running depmod and ldconfig:
-> done.
-> Uninstallation of existing driver: NVIDIA Accelerated Graphics Driver for Linux-x86_64 (390.42) is complete.

If you are using the runfile installer method, simply deselect the option to install the driver bundled with the runfile installer.

If you are using the deb install method (this would be the local deb installer), and you have a R390 driver loaded already, install the meta package that doesn’t include the GPU driver, just the toolkit:

http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#package-manager-metas

sudo apt-get install cuda-9-1-toolkit

The network deb installer will install a R390 driver. I don’t recommend this if you have already installed a driver via driver runfile installer.

I encourage you to familiarize yourself with the linux install which I already linked.