Cuda install doesn't work -> Error: only 0 Devices available, 1 requested.

Hello,

I just installed CUDA on my Ubuntu 16.04, using the network deb from CUDA Toolkit 11.7 Update 1 Downloads | NVIDIA Developer (ubuntu 16.04 arch 64).

It installed this branch: nvidia-384, the latest, yet when I launch the nbody I get :

% ./nbody
Run "nbody -benchmark [-numbodies=<numBodies>]" to measure performance.
        -fullscreen       (run n-body simulation in fullscreen mode)
        -fp64             (use double precision floating point values for simulation)
        -hostmem          (stores simulation data in host memory)
        -benchmark        (run benchmark to measure performance)
        -numbodies=<N>    (number of bodies (>= 1) to run in simulation)
        -device=<d>       (where d=0,1,2.... for the CUDA device to use)
        -numdevices=<i>   (where i=(number of CUDA devices > 0) to use for simulation)
        -compare          (compares simulation results running once on the default GPU and once on the CPU)
        -cpu              (run n-body simulation on the CPU)
        -tipsy=<file.bin> (load a tipsy model file for simulation)

NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.

Error: only 0 Devices available, 1 requested.  Exiting.

I was just stuck at the same place minutes ago. Finally I have restarted my machine and… command ./nbody launched simulation!

PS. Before restarting:
sudo gedit ~/.bashrc

and following lines pasted at the end of my bashrc:

export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

./nbody -numbodies=4096 -benchmark
OUTPUT:

Windowed mode
Simulation data stored in video memory
Single precision floating point simulation
1 Devices used for simulation
GPU Device 0: “GeForce GTX 1060 6GB” with compute capability 6.1

Compute 6.1 CUDA device: [GeForce GTX 1060 6GB]
number of bodies = 4096
4096 bodies, total time for 10 iterations: 2.738 ms
= 61.272 billion interactions per second
= 1225.430 single-precision GFLOP/s at 20 flops per interaction

./nbody -numbodies=4096 -cpu -benchmark
OUTPUT:

Windowed mode
Simulation data stored in video memory
Single precision floating point simulation
1 Devices used for simulation
Simulation with CPU
number of bodies = 4096
4096 bodies, total time for 10 iterations: 7487.320 ms
= 0.022 billion interactions per second
= 0.448 single-precision GFLOP/s at 20 flops per interaction

It seems only 1 out of 12 cpu cores (threads) is used for this simulation.

Setup:
Ubuntu 16.04, Xeon 5645, PNY gtx 1060 6GB

I have to reinstall my linux, my version doesn’t support yet the GPU drivers.

Wanted to try it on WSL, bad idea !

EDIT: I installed a real Ubuntu and it worked perfectly fine after rebooting such as you said ;)

I also got the same error.

This was the code I used to install:

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600

wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb

sudo dpkg -i cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-10-2-local-10.2.89-440.33.01/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda

I used Additional drivers option in software and updates in ubuntu to load nvidia drivers.

First I got the same error [I had already exported paths]. Then I found that it was because I enabled Secure boot.

So I disabled Secure Boot.

Now it works flawless.