CUDA compute in Ubuntu, for Notebook with discrete Nvidia GPU

I’ve done two days of reading and trying. I am not inexperienced in installations, less in Ubuntu than in Windows, but no novice.
I have installed Blender in several computers in Windows and Ubuntu, all with NVIDIA and CUDA.
The different condition is a Notebook with a discrete graphics card with optimus, using it happily in Windows 7, so far, but want Ubuntu to give Blender application that extra power it has in Ubuntu.

  • MSI G70 0NE (clone named Hyrican) / MSI 1762 mobo / CPU i7-3630QM / GPU nvidia GTX 680M
  • Ubuntu 14.04.5 updated

Steps I already know about and tried, in this case.

  • Get rid of Nouveau driver
  • Use the .run nvidia file, open source
  • use the ppa open source
  • install bumblebee and bbswitch

It would take a very long post to describe each and all the steps for every one, though obviously a mistake in a step may have been the cause of failure in the end result. In short my failures were as follows:

  • nvidia 375.20 always takes me to a blank screen on boot, an X-server(?) problem and only a complete --uninstall from the console gets me back and running GUI.
  • Bumblebee and bbswitch had me working of the Intel and unable to swith to NvidiaGTX, though I think I succeeded erratically… at times.

Since the switching is not really what I am after, I basically want a more powerful platform for Blender than Windows, I decided to keep it simple and forget Bumblebee and switching, to aim for a clean NVIDIA installation only. Easy?.. right… In any case I am at a reasonable(?) juncture where some things work and I’ll take it from here:

After all the above tweeking, which took about two days!, I have installed the proprietary version, through ppa, of NVIDIA-340.98, the latest among proprietary.
I had completely uninstalled both Nouveau and all other flavors of nvidia before.
Though I also purged bumblebee and bbswitch, I kept the installation of the Intel integrated graphics, a driver called i915

The good news:
Nvidia driver is installed and stable. NVIDIA X-Server Settings app works and correctly recognizes the card
Suprisingly! the nvidia settings app switches between Intel and GTX 680M (with a logout, much like bumblebee with bbswitch would)
The bad news:
All is pointless since Blender will not recognize CUDA availability.

Here are a few screenshots:
lshw -c video shows both cards


Nvidia settings:
1st with Intel “owning” the display (notice how no other nvidia-specific settings are available)


then after selecting nvidia and logout - login


and some of the specifics from the settings listed:
(continued in following post)




But sadly, no cuda in Blender


I am calling it a day, burnt out. It is ironic when I think I do this to get things done FASTER… Hopefully there will be payback, when running under Ubuntu.

I’ll check back to see if anyone has managed some help

Are you using official Blender (tar.bz2 file)?
Anyway, I have been able to make this work on PC (Intel CPU + iGPU). But I have not been able to make it work on 14.04. This has worked only since Ubuntu 15.04:
https://devtalk.nvidia.com/default/topic/580537/linux/intel-nvida-simultaneously-is-it-possible-for-linux-desktop-/post/4562082/#4562082

So you try to use Ubuntu 16.04. You install the newest driver that exists in the official 16.04 repository (not from PPA), then install ‘nvidia-prime’ package, and you use official Blender (tar.bz2 file). If you can get it to work, you can then try installing newer driver from PPA.

Edit:
For ubuntu 14.04 it is also necessary to install ‘nvidia-modprobe’ package (investigate on the google/internet about it) for CUDA detection, and reboot the system. Remember to use official Blender

Yafu I LOVE YOU !!
it worked, if fu…ing did. nvidia-modprobe and voila. No special blender packages no other nvidia drivers nothing. Bam, it worked.
Thank you

If you come to Greece, I owe you souvlaki and drinks.

PS
I had a couple of Blenders on standby, including the tar.
The first success was from the official depository which was 2.69, already installed at the time.
I just scrapped that and used a ppa available by Thomas Schiex for the latest 2.78
The good thing about ppa and other repository versions is they install like a program in the right place and other nice strings.

Thanks again, made my day

Good!
But, have you been able to configure (and make CUDA work) with Prime on Ubuntu 14.04 (intel as primary display)?

The problem with Blender from repositories (Ubuntu or PPA) is that you need to install a bunch of packages related to CUDA toolkit. With official Blender you do not need to install CUDA toolkit. So if the user does not have CUDA Toolkit installed (or has it installed incorrectly), the most reliable way to recommend do test to the user is to use official Blender.

Regarding the first half of your question, yes I switch back and forth, nvidia-prime was installed, with nvidia-340 drivers … I think. Synaptic PM shows it in the contents of the nvidia-340 package as “recommended” not “dependant”. bbswitch-dkms is also a dependancy, so it was installed (again after I purged my attempted installation of bumblebee)
Below is a screenshot of the nvidia-340 package (as reported by Synaptic)
[ATTACH=CONFIG]462645[/ATTACH][ATTACH=CONFIG]462646[/ATTACH][ATTACH=CONFIG]462647[/ATTACH]

So far I have pinned the NVIDIA X Server Settings to the launchbar and am using that to switch, but I could add prime-indicator-plus to the installation.
So yes I have succeeded in installing with prime on ubuntu 14.04 and yes with switchable graphics to intel and back.

Regarding the second part of your question: Not sure what you mean by primary Intel, ubuntu 14.4 installations without prime default to nvidia (with nouveau) and no Intel, at least that is the first and only display that is usable. I had been following the instructions on this YouTube video. That recommended the latest nvidia drivers open-source (those drivers didn’t work) from the ppa and bumblebee. I proceeded with the nvidia-340 proprietary drivers from the ppa. Later in the process, after nvidia-340 and bumblebee (min 6.04 in video), I added intel “recognition” sudo prime-select intel ,but note that nvidia drivers were loaded first. That seems to have added the Intel display driver i915?
The switching under Bumblebee did not work properly, I removed and purged it, as I did with bbswitch. And I re-installed nvidia-340 drivers. (prime and bbswitch were dependent and also re-installed - no bumblebee though) after adding nvidia mod-probe, at your suggestion (@Yafu), it all works beautifully.

And btw I tested with the blender tar, as well, it works fine.

I decided to make a guide of what worked:

Start with the latest, updated Ubuntu 14.04. If you have just installed your display will be driven by your discrete nvidia gtx gpu, under nouveau drivers.
My description uses Synaptic Package Manager for the installations, so add that first from the Software Center, if you want to follow exactly. You could use apt-get install instead, but I won’t provide details along that line.

  • Open Synaptic and choose to list packages sorted by checkbox. If you have any dependancy issues they will show up first with [!]
    If you have broken packages they will show up in [red]
    Fix them! reboot
  • Open the Software&Updates, under Other Software add ppa:graphics-drivers and reload. This will make additional graphics drivers available
  • Go to Additional Drivers tab and select NVIDIA binary driver - version 340.98 - the latest PROPRIETARY at the time of this writing. Select and apply. Reboot. This went very smoothly in my case, none of the known Nouveau driver issues or X problems, you don’t do anything manually. On reboot it all worked (nouveau blacklisted, kernel for x ok, conf ok etc…etc)
  • Open Synaptic under search type “Prime”, you should see that nvidia-prime is installed
    Then type “bbswitch”, that should be also installed
  • Open terminal and run ‘sudo prime-select intel’ When finished reboot

Open NVIDIA X Server Settings, you should be set to switch!

  • Use Synaptic to add nvidia-modprobe

You are set for Blender CUDA

  • Add prime-indicator-plus if you want an icon indicator for prime on you (I haven’t so can’t tell you more)

Please note that strayed often when finding-out this procedure. So actually I have re-constructed what I believe is the sum of the safe-road. I have not actually done just this sequence. Also take a look at yours and mine hardware for differences, I don’t know how broadly this applies. Hope it works for many other optimus (on-board and discrete nvidia GPU) notebooks.

  • I have added prime-indicator-plus

It works just as it’s equivalent in NVIDIA X-Server Settings. While writing this I switched to take screen shots of the menu bar:


I had to log out and back in to take the shots above

  • Log out and back in does not retain open programs

When I log back in, the programs that were open when I logged out are now closed. I get a “clean” start.
I wonder if there is a way to retain the previous session, generally for log out / in under Linux and whether that would work with the switch.

  • I tested Blender under Intel, obviously the CUDA option was not available

I tried the switch Intel>Nvidia with Blender open. That crashed the system, I tried several times before and several after with “lesser” more mainstream programs running, like screen-shots, nautilus, calculator, running while switching. Those were smoothly turned off, on log out.

  • Benchmarks and performance:

Ubuntu 14.04 (X64) with Blender 2.78a performance with Blenchmark was 2’:50" (170s) [edit: time down to 151s, maybe new libs, from updated packages? or just deviations? - that’s a lot of deviation…] whereas with Windows 7 (ProX64) it is 2’:34" (154s) … hmmm was all this for nothing? *note in Windows I have Afterburner overclocking core +135
Nope, where Blender under Linux shines, is with scenes heavier than the Blenchmark. Using my latest archviz, an interior of about 70MB and with lowres (40%X1920X1080) and few samples (96), Ubuntu 1’:19" and Windows 1’:55". And by previous experience it gets even better with larger scenes and quality renders, of full resolution and many samples.
And it is not only about the render time, that time is a time I don’t use my computer, usually overnight - all the more important when 3D orbits and pans view manipulations start stuttering in Windows, my experience is, you have plenty more to go before Ubuntu slows down.
*Would appreciate others’ comments on this Windows / Linux comparison.

Questions, to be answered :

  • Question 1 , Running specific profiles by program

Can optimus switching be specific by program? meaning one program running in an intel display the other in nvidia and both showing simultaneously in program windows?
There are settings for profiles in NVIDIA X-Server graphics. I wonder if that means power settings for nvidia alone or the ability to use both gpu’s concurrently.
Under Windows 7 with the NVIDIA driver it is easy to set the application to run under the NVIDIA driver, that is how I have Blender set up. But I wonder if is actually just that window running with NVIDIA. I see it work but I’m not sure exactly how. I don’t know how much switching, actually goes on transparently, if any at all.
I have noticed one glitch though: if you run Blender full-screen Alt-F11 (not just full-sized window) and run Preferences, it crashes. It does’t happen with other windowed processes like save or open file or append etc… etc.
Also I think Blender runs faster in full-screen mode, though obviously, under CUDA, therefore nvidia, in all cases.

  • Question 2 , Overclocking?

Are there drivers or programs (like Afterburner) to speed up Nvidia in Ubuntu?

Attachments


With the ppa setup I went through the first update of NVIDIA automatically with the recommended updates
From 340.98 to 340.101

I managed to get Ubuntu 16.10 up and running MSI GP62-6QF this week without much trouble, with nvidia-375 drivers, bumblebee and gnome on wayland session. Works perfectly!

I noticed by coincidence that when Windows 10 goes to sleep, and the system is restarted to ubuntu, the nvidia card locked by Windows. Shutting windows down, re-enabled CUDA.