Ubuntu 20.04 cuda 11-4 installation crashes on NVidia demo code add.cu

Hello Cuda Linux developers,

I am new the community and am posting in this forum because it is the only one that mentions Linux explicitly in its title. This is not a graphics question.

I’m trying to execute a hello-world like cuda source on my Ubuntu 20.04 box. The graphics card is
09:00.0 VGA compatible controller: NVIDIA Corporation GP107 [GeForce GTX 1050 Ti] (rev a1)
09:00.1 Audio device: NVIDIA Corporation GP107GL High Definition Audio Controller (rev a1)
All hardware and the OS installation are less than a month old.

The code from the simple tutorial at An Even Easier Introduction to CUDA | NVIDIA Developer Blog
compiles with my nvcc (/usr/local/cuda-11.4/bin/nvcc)

but crashes early in execution

cudaMallocManaged(&x, Nsizeof(float));
cudaMallocManaged(&y, N
sizeof(float));
// initialize x and y arrays on the host
for (int i = 0; i < N; i++) {
x[i] = 1.0f; // THIS LINE EXECUTES OK AND PRINTS x[i] CORRECTLY
y[i] = 2.0f; // CRASHES HERE ON FIRST PASS THROUGH LOOP
}

It seems to me that there is a problem with cudaMallocManaged allocating arrays back-to-back.

Or maybe there is a problem somewhere else under the sun. Maybe the installation itself?

I followed the cuda ubuntu installation instructions available from the ubuntu package downloader at
nvidia.com:
CUDA Toolkit 11.4 Update 2 Downloads | NVIDIA Developer

All steps worked fine until the last one
sudo apt-get -y install cuda, which failed with the following unhelpful error message

Reading package lists… Done
Building dependency tree
Reading state information… Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
cuda : Depends: cuda-11-4 (>= 11.4.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Several others have seen this message, and everyone seems to have a completely different remedy for it. In my case, I just made sure that I had all available and relevant cuda packages, so there would be nothing missing. Indeed,
after many rounds of installing bits cuda available from various packages repositories, I can safely say that I have much of 11-4 already installed. I followed the post-install instructions as well. So . . . I’m good, right? and the
package manager, which fails to find any specific issue, is somehow mixed up.

Anyhow, I’m not able to get the “hello-world” of the cuda universe to execute, and there is no apparent way
forward. Comments, anyone?

Peter Leopold
Portland ME and Cambridge MA

It did finally start working after I installed and uninstalled several ubuntu repository drivers. The 20.04 drivers from nvidia were never able to install cleanly. There was always some dependency error that kept them from going in. The same was true for the ubuntu drivers, but there were just enough hints regarding required upgrades than, when I followed them all and was still unable to get a clean install, the resulting accumulated installations/de-installation attempts left me with a working add.cu example. So. There you have it.

More details on the ordeal here: An Even Easier Introduction to CUDA - #134 by peterleopold23