Cuda Toolkit 9.1 on Ubuntu 16.04: installation failed

Dear all,

I’m really new into the Ubuntu world and I’m not able to install the Cuda Toolkit9.1 requested by my application.
I downloaded it from the website and type this command:
sudo sh cuda_9.1.85_387.26_linux.run

The installation seems to begin but at the end, there is an error message:

Do you accept the previously read EULA?
accept/decline/quit: accept

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 387.26?
(y)es/(n)o/(q)uit: y

Do you want to install the OpenGL libraries?
(y)es/(n)o/(q)uit [ default is yes ]: y

Do you want to run nvidia-xconfig?
This will update the system X configuration file so that the NVIDIA X driver
is used. The pre-existing X configuration file will be backed up.
This option should not be used on systems that require a custom
X configuration, such as systems with multiple GPU vendors.
(y)es/(n)o/(q)uit [ default is no ]: 

Install the CUDA 9.1 Toolkit?
(y)es/(n)o/(q)uit: y

Enter Toolkit Location
 [ default is /usr/local/cuda-9.1 ]: 

Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y

Install the CUDA 9.1 Samples?
(y)es/(n)o/(q)uit: y

Enter CUDA Samples Location
 [ default is /home/unloc ]: 

Installing the NVIDIA display driver...
It appears that an X server is running. Please exit X before installation. If you're sure that X is not running, but are getting this error, please delete any X lock files in /tmp.

===========
= Summary =
===========

Driver:   Installation Failed
Toolkit:  Installation skipped
Samples:  Installation skipped

Thanks for your help
Sébastien

You need to execute init 3 mode to proceed with X driver installation;
Otherwise use deb/ppa methods:
https://askubuntu.com/questions/967332/how-can-i-install-cuda-9-on-ubuntu-17-10

But you will have to remove installed nvidia components most likely:
[url]Installation Guide Linux :: CUDA Toolkit Documentation
Refer to [url]"NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver" Ubuntu 16.04 - CUDA Setup and Installation - NVIDIA Developer Forums