Ubuntu 14.04: optimus + CUDA

Hello,

I installed Ubuntu 14.04 and I’m trying to get optimus + CUDA working.
My laptop is a Dell M6700. (nvidia K3000M)

First I installed the proprietary drivers using the Ubuntu manager like here:
http://askubuntu.com/questions/450758/has-nvidia-331-38-support-for-optimus
PRIME profiles is set to NVIDIA

The .deb installer does not work for the moment; I guess because the “PPA” has not been updated for
Ubuntu 14.04. I removed the .deb after trying to install CUDA with it.

So I installed CUDA using the run (x64) for Ubuntu 13.04
http://developer.download.nvidia.com/compute/cuda/6_0/rel/installers/cuda_6.0.37_linux_64.run

Here’s the procedure :
Ctrl + Alt + 1 to switch to a terminal

sudo service lightdm stop
sudo chmod +x cuda*.run
sudo ./cuda*.run --override

I got a warning message stating: You are attempting to install on an unsupported configuration
I used override option because Ubuntu 14.04 is shipped with gcc 4.8.2.
I installed everything but the driver, I kept default paths.

Here is the complete install log:
https://mega.co.nz/#!9ZlAxSDb!u5yRtGFt1fdp5v3EoVtbkfbzCGRHl5gzhDDfiEaM96Q

Then

sudo service lightdm start
export PATH=/usr/local/cuda-6.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-6.0/lib64:$LD_LIBRARY_PATH
sudo ldconfig
cd ~/NVIDIA_CUDA-6.0_Samples/1_Utilities/deviceQuery
make -j4 && ./deviceQuery

The output is :

Here is the nvidia-bug-report log (sudo /usr/lib/nvidia-331/bin/nvidia-bug-report.sh)
https://mega.co.nz/#!IAsnUSKJ!eYN6cvFjXVL87yTcMqUUTfwSTVi_SyxQ4Eyn85qwPcc

Any help is appreciated; I can provide as much information as you want.
Bye !

Try executing:

  1. modprobe nvidia (or nvidia-331, or nvidia-current, whatever the name of the module is)
    and run ./deviceQuery … does it work now?

  2. sudo nvidia-smi
    and run ./deviceQuery … does it work now?

  3. sudo ./deviceQuery
    does it work now?

$ ./deviceQuery 
./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

cudaGetDeviceCount returned 3
-> initialization error
Result = FAIL
sudo ./deviceQuery 
./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

modprobe: ERROR: ../libkmod/libkmod-module.c:809 kmod_module_insert_module() could not find module by name='nvidia_331_uvm'
modprobe: ERROR: could not insert 'nvidia_331_uvm': Function not implemented
cudaGetDeviceCount returned 3
-> initialization error
Result = FAIL
  1. It looks like the discrete GPU is off :
$ sudo nvidia-smi
Fri Apr 25 09:11:41 2014       
+------------------------------------------------------+                       
| NVIDIA-SMI 331.38     Driver Version: 331.38         |                       
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Quadro K3000M       Off  | 0000:01:00.0     Off |                  N/A |
| N/A   35C    P8    N/A /  N/A |    362MiB /  2047MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Compute processes:                                               GPU Memory |
|  GPU       PID  Process name                                     Usage      |
|=============================================================================|
|  No running compute processes found                                         |
+-----------------------------------------------------------------------------+
$ sudo ./deviceQuery 
./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

modprobe: ERROR: ../libkmod/libkmod-module.c:809 kmod_module_insert_module() could not find module by name='nvidia_331_uvm'
modprobe: ERROR: could not insert 'nvidia_331_uvm': Function not implemented
cudaGetDeviceCount returned 3
-> initialization error
Result = FAIL

I also tried :

sudo nvidia-xconfig 

Using X configuration file: "/etc/X11/xorg.conf".

WARNING: Unable to find CorePointer in X configuration; attempting to add new CorePointer section.

WARNING: The CorePointer device was not specified explicitly in the layout; using the first mouse device.

WARNING: Unable to find CoreKeyboard in X configuration; attempting to add new CoreKeyboard section.

WARNING: The CoreKeyboard device was not specified explicitly in the layout; using the first keyboard device.

Backed up file '/etc/X11/xorg.conf' as '/etc/X11/xorg.conf.nvidia-xconfig-original'
Backed up file '/etc/X11/xorg.conf' as '/etc/X11/xorg.conf.backup'
New X configuration file written to '/etc/X11/xorg.conf'

This resulted in 640480 resolution (I can’t change) and it’s not working.
new xorg.conf (640
480)
xorg.conf backup

Thank you for the suggestions !

[b]EDIT: I gave a try at installing nvidia-331_uvm (+modprobe) and running deviceQuery again ! This does not change anything.

I’ll try updating drivers and see what it does.[/b]

The fact that you got the “modprobe: ERROR: could not insert ‘nvidia_331_uvm’: Function not implemented”, means that you’re on the right track.

Go here: [url]334.21 driver returns 999 on cuInit (CUDA) - Linux - NVIDIA Developer Forums

You need to make sure that nvidia-uvm gets compiled and you’re able to modprobe it successfully. Next, you might have to fix the nvidia nodes with the right permissions via the advice of the thread above.

Thanks for the reply; the uvm module was successfully installed in the kernel :

Loading new nvidia-331-uvm-331.38 DKMS files...
First Installation: checking all kernels...
Building only for 3.13.0-24-generic
Building for architecture x86_64
Building initial module for 3.13.0-24-generic
Done.

nvidia-331-uvm:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/3.13.0-24-generic/updates/dkms/

depmod....

DKMS: install completed.

Now I always get the same message (sudo or not)

$ sudo ./deviceQuery 
./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

cudaGetDeviceCount returned 3
-> initialization error
Result = FAIL

I don’t know why 3 devices ?!
This thread states that upgrading drivers solves the issue. I tried to install the embedded driver in the CUDA toolkit (331.62) but I can’t get it working.

Maybe I should wait for an official 14.04 package !

It’s not saying 3 devices, it’s saying it returned error code 3, which is ‘initialization error’.

Did you try to invoke nvidia-smi as root before trying deviceQuery again? I didn’t see you mention that you had done that. Otherwise, I’m not sure what else would be the issue, perhaps someone else can comment.

Heyyo,

I don’t know if there’s a compatibility problem with Cuda 6.0 and Linux drivers, but I could never get it to work myself tbh… 5.5 has worked perfect for me, but you have to create links in .bashrc otherwise I couldn’t use anything Cuda.

Open up Terminal and do this…

cd
nano .bashrc

and in that file? add this somewhere (I’m using 5.5 as an example but if you wish to try 6.0 then change the 5.5 parts to 6.0)

PATH=$PATH:/usr/local/cuda-5.5/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-5.5/lib64:/lib

and then…

source .bashrc

I think you have to reboot after doing that… I could be wrong, but nothing wrong with rebooting for good luck right!? :P

Oh yes it’s an error code, I misread. I gave a try; no change,

$ sudo nvidia-smi
Wed Apr 30 11:21:02 2014       
+------------------------------------------------------+                       
| NVIDIA-SMI 331.38     Driver Version: 331.38         |                       
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Quadro K3000M       Off  | 0000:01:00.0     Off |                  N/A |
| N/A   39C    P8    N/A /  N/A |    244MiB /  2047MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Compute processes:                                               GPU Memory |
|  GPU       PID  Process name                                     Usage      |
|=============================================================================|
|  No running compute processes found                                         |
+-----------------------------------------------------------------------------+
$ ./deviceQuery 
./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

cudaGetDeviceCount returned 3
-> initialization error
Result = FAIL

$ sudo ./deviceQuery 
./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

cudaGetDeviceCount returned 3
-> initialization errror
Result = FAIL

@ThE_MarD

Everytime I start a terminal I do (which is a temporary equivalent to your suggestion)

export PATH=/usr/local/cuda-6.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-6.0/lib64:$LD_LIBRARY_PATH

Any other suggestion is appreciated :)

EDIT:

Just restart your terminal, .bashrc is called every time you start a bash terminal !

It seems to be some permission stuff.
Try to run the deviceQuery once with sudo.
Also is the module nvidia_uvm module loaded?

I dug a little deeper.

First of all the nvidia-uvm module is apperently necessary.

Load the nvidia-uvm module :

sudo modprobe nvidia-uvm

Init the /dev node with (you can put this in the rc.local if you want to) :

sudo mknod -m 0666 /dev/nvidia-uvm c 250 0

Edit:
It seems that there is a new 337.19 package on xorg-edgers which fixes the building on the 3.13 kernel

Ubuntu 14.04 and nvidia prime, only CUDA 5.0 not CUDA 6.0

sudo apt-get purge bumblebee* nvidia*
sudo apt-get install nvidia-prime prime-indicator

if you get:
cudaGetDeviceCount returned 35
→ CUDA driver version is insufficient for CUDA runtime version
Result = FAIL

Now install the package
sudo apt-get install libcuda1-331-updates

worked for me

NOTE: Driver Version: 331.38 does not support CUDA 6.0 only CUDA 5.5

I’m having the same problem… I reinstall the Linux to try again, how can I start to install Cuda ?? if I try to run the .run file he says “You are attempting to install on an unsupported configuration”

I use Linux 14.04 64 bits

Heyyo,

This is true, I’ve had cuda 5.5 work fine but cuda 6.0 won’t work for me neither and I think I’m also running 331.38 as well.

Here is a quick guide on how to install nvidia drivers + CUDA 5.5 on Ubuntu 14.04 with a machine using prime technology:

Only if you already have nvidia drivers; purge them:

sudo apt-get --purge remove nvidia-*

Install the proprietary driver with the Software & updates program :
External Media
Reboot, take a look at “X server settings” application and you should be able to see “PRIME Profiles”, keep NVIDIA (performance mode).

Download CUDA toolkit 5.5 (cuda_5.5.22_linux_64.run)

Switch to a virtual terminal (Ctrl + Alt + 1 for example) and login; then

sudo service lightdm stop
sudo ./cuda_5.5.22_linux_64.run -override

The -override option is mandatory because Ubuntu 14.04 ships with gcc 4.8.2 which is not recognized as supported by the CUDA .run installer.

When prompted if you want to install the nvidia driver embedded into the .run package; answer no (your version is newer and natively supports prime).

Set up everything else (install the examples) like you want.
Copying the log from the tmp folder to your home folder is a good practice (there are pieces of advice concerning PATH etc…)

The installer will warn you that the installation is incomplete; this is because you have chosen not to install the driver; no worries!

When everything is done reboot (not sure if needed) and test if CUDA works (easy if you have installed nvidia samples!)

Note that I personally didn’t have to modify the PATH nor anything else to get CUDA working; you might need to follow the steps in the installation log to get CUDA working fine.

Compile an example:

cd NVIDIA_CUDA-5.5_Samples/1_Utilities/deviceQuery
make
./deviceQuery

Output example:

./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "Quadro K3000M"
  CUDA Driver Version / Runtime Version          6.0 / 5.5
  CUDA Capability Major/Minor version number:    3.0
  Total amount of global memory:                 2048 MBytes (2147287040 bytes)
  ( 3) Multiprocessors, (192) CUDA Cores/MP:     576 CUDA Cores
  GPU Clock rate:                                654 MHz (0.65 GHz)
  Memory Clock rate:                             1400 Mhz
  Memory Bus Width:                              256-bit
  L2 Cache Size:                                 524288 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
  Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 2 copy engine(s)
  Run time limit on kernels:                     Yes
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  Device supports Unified Addressing (UVA):      Yes
  Device PCI Bus ID / PCI location ID:           1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 6.0, CUDA Runtime Version = 5.5, NumDevs = 1, Device0 = Quadro K3000M
Result = PASS

If someone managed to install and get CUDA 6 working with Ubuntu 14.04 (+ prime) please post detailed instructions here!

Ubuntu 14.04 + Optimus + Cuda 6.5

Success with installation of CUDA 6.5 using the `deb’ method specifically for Ubuntu 14.04, 64-bit (CUDA Toolkit 11.7 Update 1 Downloads | NVIDIA Developer) on to an Acer Aspire S3-392G (735M) Optimus laptop, installed the 340 driver (BTW this was done with legacy BIOS settings for secure boot).

The prime-select utility from the shell, followed by logout and login allows toggle between nvidia graphics and intel (verifed by looking at system info). However no option to toggle appear in the nvidia-settings utility.

In nvidia mode, I can verify the samples build and run, and can use nsight eclipse edition build and run the samples. However cannot yet debug a kernel (not had time to investigate).

Would like to use integrated intel graphics for display and nvidia for CUDA development (not interested in displaying graphics i do algorithms development). At the moment in intel graphics mode, queryDevice fails. Does anyone has a pointer on how to do this?

Had the issue: modprobe: ERROR: could not insert ‘nvidia_331_uvm’ myself and after re-installing cuda
i noticed the obvious fact that the PATH and LD_LIBRARY_PATH needs to include /usr/local/cuda7.0/bin and /usr/local/cuda7.0/lib64 respectively. So update to etc/environment resolved it. Basic error on my part but now the gpu is found…

If you’re using NVIDIA prime and it’s set to use the Intel GPU, then your video card has probably been disabled via bbswitch. Thus “no such device”. See the documentation on bbswitch for how to reenable it.

Then you should be able to load the NVIDIA module using modprobe, which will also create the device nodes.

So I just leave Prime in Intel mode, and manually turn the card back on and load the module when I need to do computations on the card. Kind of a hack, but it works.

For more information on what Prime actually does, see my askubuntu post:

http://askubuntu.com/questions/741047/cant-get-cuda-to-work-with-nvidia-prime