All of my apt-get operations are failing, because somewhere there seems to be a file calling ld.so with a file that no longer exist. This means I can no longer use apt-get to install or update my dependencies!

I'm running Lubuntu 16.04.

I believe this started to occur because of an auto-update that occurred with Nvidia CUDA. Starting last week, I started seeing this line show up in my terminal after running commands that have nothing to do with CUDA.

ERROR: ld.so: object '/usr/lib/nvidia-375/libnvidia-ml.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

I went to look into this and found that the file /usr/lib/nvidia-375/libnvidia-ml.so did not exist on my system, that instead there was a libnvidia-ml.so file in a folder that seemed to be for an update of the same package, /usr/lib/nvidia-382.

I thought that with a reboot and some updates this problem would go away, but today I realize that I can no longer do most apt-get commands. For example, when I run an install command, I get a huge log output, that includes the above line hundreds of times, and the installation ultimately fails.

I've copy-and-pasted one of those outputs into a gist (it was too big to put inside this post). This was the result from output from trying to run sudo apt-get install vlc (but it fails similarly with any install). https://gist.github.com/travellingprog/00a08cff1019f7a12d36b975dff62c92

I don't even use CUDA these days, so this is especially annoying. One of the things I tried was to uninstall nvidia-382. The uninstallation itself seems to have worked, and it seems to have removed CUDA 9 along with it, but the problem still persists.

The thing is I have no idea what package or file keeps asking for this non-existing file in /usr/lib/nvidia-375.

Can someone please help?

Update 2017-11-01

I seem to get this error anytime I run a sudo command.

I tried running ldd /usr/bin/sudo and ldd /usr/bin/apt-get and neither of them list this Nvidia file. I looked in the folder /etc/ld.so.conf.d and found a file called cuda-9-0.conf, despite the fact that CUDA should be removed. So I renamed it to cuda-9-0.backup and ran sudo ldconfig.

This didn't fix it, I still get the error message on every sudo command.

I also decided to check the cache, and I'm not sure if this is pointing to the issue:

# sudo ldconfig -p | grep nvidia
ERROR: ld.so: object '/usr/lib/nvidia-375/libnvidia-ml.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
libnvidia-gtk3.so.384.81 (libc6,x86-64) => /usr/lib/libnvidia-gtk3.so.384.81
libnvidia-gtk2.so.384.81 (libc6,x86-64) => /usr/lib/libnvidia-gtk2.so.384.81
  • Try the options from: askubuntu.com/questions/833862/… Nov 3, 2017 at 19:03
  • Are you purging when you remove stuff you don't need anymore? sudo apt purge $PACKAGE_NAME? Sometimes it helps if files aren't properly removed to install the package again first (eg sudo apt-get install --reinstall $PACKAGE_NAME) and then to purge the package. I often then use locate -i $BINARY_NAME to find anything left over that needs manually deleting.
    – pbhj
    Nov 6, 2017 at 15:36

3 Answers 3


You seem to have set the LD_PRELOAD environment variable somewhere:

$ /bin/true
$ export LD_PRELOAD=/usr/lib/nvidia-375/libnvidia-ml.so
$ /bin/true
ERROR: ld.so: object '/usr/lib/nvidia-375/libnvidia-ml.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.

I'd suggest that you check your shell initialization files (~/.{bashrc,profile}, /etc/{bash.bashrc,profile,profile.d/*}). Or run this command:

PS4=' ${BASH_SOURCE}:${LINENO} ' bash -lixc exit |& grep LD_PRELOAD
  • why do you do /bin/true either side of the export?
    – pbhj
    Nov 6, 2017 at 15:30
  • 2
    @pbhj because /bin/true is a command that otherwise has minimal dependencies and is guaranteed to succeed. And, of course, in the first try it had no problems, but after the export, I got the same error as OP.
    – muru
    Nov 6, 2017 at 15:32
  • 1
    Ah, apologies, skimmed over that too fast, I thought you were suggesting a fix there! Yes, testing to show the potential origin of the error. env | grep LD_PRELOAD would show it too, also env -i $COMMAND should work with a clean environment and so not have the preload (env -u LD_PRELOAD $COMMAND might be better).
    – pbhj
    Nov 6, 2017 at 23:11
  • 1
    I wish I could give the bounty to both you and @pbhj . My user shell initialization files had nothing, and env | grep LD_PRELOAD returned nothing either, but then I found that sudo env | grep LD_PRELOAD did show the environment variable LD_PRELOAD as set to the non-existing libnvidia-ml.so. After digging to figure out where root-only environment variables could be set, found LD_PRELOAD being set in /etc/environment. Thank you so much to both of you for steering me in the right direction! Nov 8, 2017 at 19:58

Thanks to @muru's answer and @pbhj's comment to that answer, I found that the issue was that the environment variable LD_PRELOAD was being set to "/usr/lib/nvidia-375/libnvidia-ml.so" in the file /etc/environment.

I most likely added the line in that file myself a long time ago, when I first set up CUDA. I'm guessing this was a hack to an issue I was having at that time, that required setting LD_PRELOAD at the sudo level.

As @muru demonstrated, it is pretty easy to reproduce the error message by setting the LD_PRELOAD environment variable to a file that does not exist. Still, my shell initialization files did not set it, and env | grep LD_PRELOAD returned nothing.

However, (thanks to @pbhj's comment), I found out that while running sudo apt-get update would display the error a ton of times in the output, sudo env -u LD_PRELOAD apt-get update only displayed it once, at the very top of the output. Then I found that sudo env | grep LD_PRELOAD showed that it was indeed set to the non-existing file, for sudo commands.

Aside from /etc/environment, anyone having this issue should also look at the file /etc/sudoers (which you should edit with sudo visudo) and any files in the folder /etc/sudoers.d/.


Have you tried with:

dpkg-reconfigure nvidia-***

This may solve your issue reconfiguring and re-installing if needed!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.