Skip to content

Instantly share code, notes, and snippets.

@mikaelhg
Created August 19, 2018 23:27
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikaelhg/684f323fb07ab081d5c1be144bd9beb6 to your computer and use it in GitHub Desktop.
Save mikaelhg/684f323fb07ab081d5c1be144bd9beb6 to your computer and use it in GitHub Desktop.
clang, dkms and ERROR: could not insert 'nvidia': Exec format error

When DKMS uses clang to compile the nvidia kernel driver, you're boned.

sudo modprobe nvidia
modprobe: ERROR: could not insert 'nvidia': Exec format error

Unfortunately, dkms doesn't take CC and CXX settings from the environment.

sudo update-alternatives --config cc
sudo update-alternatives --config c++
sudo dkms remove nvidia/390.48 -k 4.15.0-32-generic
sudo dkms build nvidia/390.48 -k 4.15.0-32-generic
sudo dkms install nvidia/390.48 
sudo modprobe nvidia

And reboot.

@feltech
Copy link

feltech commented Nov 18, 2018

I've been tearing my hair out for days with this. Thanks!

@mikaelhg
Copy link
Author

In 2021, the DKMS script for nvidia explicitly switches to gcc, so this shouldn't be necessary anymore. You should see the CC= setting scrolling by when DKMS builds the module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment