Optimus laptop with blender and photogrammetry


Hopefully you found this post by searching for some combination of linux, optimus, blender, and photogrammetry (or colmap), and that means you’re experienced enough with linux that I don’t need to break down the steps of a task.

I dropped a laptop and it still works, but the structural damage is such that it’s not really portable anymore. So I’m donating it to a friend who aspires to a career in computer graphics. He wants to use it for blender and photogrammetry, and Windows isn’t a choice because I blew that off the hard drive when I got the the thing. It’s a 2yr-old HP Envy M7 with a pretty good CPU (core i7) and barely-there nvidia (940MX) in that bedevilsome muxless optimus configuration where the discrete graphics card is held hostage,

I couldn’t get optimus working under ubuntu 18.04, and it looks like the new release has some issues to work out in that respect - it’s not just me complaining. Unfortunately, that release seems to be the only one with good photogrammetry support - that’s software that makes a 3d model from a bunch of photographs, which you import into Blender. Ironic, given that most of that software was born in linux.

With ubuntu nixed, I tried openSUSE as that’s what I’m most familiar with. Whether suse-prime or bumblebee, in Leap 42.3 or Tumbleweed - I checked all 4 combinations - optimus works fine (with the usual tearing if nvidia controls the display, but my friend doesn’t need that).

[For those experienced with linux but not opensuse, install software with YaST’s Software Manager, or go to the build service software.opensuse.org/search. If using one-click install with Firefox, it’s generall best to un-check the “remain subscribed” box.]

I chose suse-prime - google the guide if you prefer optirun. First I added the community repo for the nvidia driver, then got suse-prime from the build service, then ran as root “prime-select intel” and rebooted. Blender can find the nvidia card even if intel is running the display. Here’s the part that drove me nuts: The version of Blender from the main repo (or packman) won’t work with the discrete GPU, Instead, I had to download Blender from its own website. Extract it to any old folder, and it will run from there. I made a menu entry to point to it. In Blender under File→Preferences→System, I could see my nvidia card (even with CUDA installed yet - Blender has what it needs of that code). With the BMW benchmark from Blender’s demo files page, I got 18½min on GPU. When I ran two instances, the GPU and CPU versions simultaneously, I got an extra minute on GPU and 22min on CPU, very little slowdown even with two instances because they use different resources.

Photogrammetry is the hard part. Ubuntu’s versions are snaps which should theoretically work on all distros, but that’s hit-or-miss and in this case all misses for me. They work fine on ubuntu, so I set my friend up for dual boot, but I wanted him to have an option that didn’t require reboot. Fortunately one structure-from-motion program that’s particularly well-regarded, COLMAP, is available in a Debian package, so I downloaded that and converted it to openSUSE’s rpm format with alien (available from the build service). The command as root is “alien -r <debfile>” from the folder where the file lives. Through a little trial and error, I determined that there are three libraries it needs which aren’t available from the main repo, but which can be found on the buildservice: libceres1, libflags2, and libGLEW2_0. It loads, but I don’t have the skill (or any project files handy) to put it through its paces to make sure it works in every capacity.

It can do sparse reconstruction as-is but needs CUDA for dense. You can also export the sparse cloud and do dense reconstruction with another tool like openvms, but good look getting a package that works on opensuse. There’s one for fedora, but it’s too late to start over for me, so instead I installed CUDA from the build service. Theoretically it works with the latest, but even so you’ll notice multiple community repositories - pick the one that matches your driver version. (Easiest way to check is to search for nvidia in software management - it was installed as a dependency by suse-prime.) CUDA needs two other packages from the same repo, so 1-click install is a good way to go, and then go do something else because CUDA downloads fast but takes quite a long time to install.

Does it work? Again, I have no way to test. When I click on dense reconstruction in its menu, I’m taken to a page to setup a project. EIther it detects the nvidia card and CUDA package, or it wouldn’t throw an error until I setup the project and told it to start processing. But hopefully I’ll be able to follow this post with a field report from my friend.

If any of this works for you, please lemme know how it goes.


PS: If you’ve never really considered openSUSE until ubuntu’s new release broke your optimus setup, you may have heard that it’s not the best out-of-box experience. That’s because it doesn’t ship what it shouldn’t, so google “opensuse community” for the multimedia codecs and “sleeping beauty fonts” in order to read the screen without eyestrain. Two steps, pretty quick. You’ll love some of the technical features, especially the automatic snapshots that let you roll back if you mess something up!

Here’s a personal tip: During install, when you setup your user account, un-check the box that uses it for admin. Then it’ll create a separate root account (though you can use the same password). Whenever you use root-priviliged software (mostly YaST components but there are a few more like unetbootin), you get the properties of the root account. So logout, then log back in as root just this one time, and set the behavior to match. If you normally activate on double-click, you don’t want root to activate on single-click! Then change the color scheme to something that contrasts what you normally use, and you’ll always have a visual cue to be extra careful.

To begin with I did not read the rest of your post, thus the following is only about what I quote here.

There is not such a box to set the first user account that you should enter on installation for admin. For the simple reason that openSUSE does not have such a thing as admin users (other distributions seem to have them).

Also the root account is always created (I do not know about any Unix/Linux system that does not have it).

The only box there is is to use the same password for both that user account and the root account. That is on by default (which is a bad idea IMO). Indeed it is better to uncheck that. The installer will then ask for e password for the root account (that you then should make diiferent then the one for the user account of course). Both accounts, the user and root will be created in all cases. The only thing is that they will have different passwords or not.

The advice to log in as root is a very bad one. It even seems that you propagate to log in as root in the GUI, which is even worse.

Please read SDB:Login as root - openSUSE Wiki

>To begin with I did not read the rest of your post, thus the following is only about what I quote here.

Hi Henk, thanks for the reply.

>There is not such a box… The only box there is to use the same password for both that user account and the root account. That is on by default (which is a bad idea IMO). Indeed it is better to uncheck that.

That’s exactly what I was thinking of. I recall leaving it unchecked by accident one, and finding that in this case, response to input in YaST tracked my settings in the user account, but perhaps I mis-remember.

>The advice to log in as root is a very bad one.

I agree with you in general, but in this one case, I’ll have to respectfully disagree, If I fail to align the root account’s response to input with my user account, especially the KDE mouse default of single-click to activate, then I wind up launching something - as root - that I only meant to select. That justifies logging in as root, one time only. .


That sounds like nonsense to me. As root NEVER logs in in the GUI and thus NEVER logs in in KDE, there is no KDE configuration (nor any other GUI configuration) for root. So nothing to change there.

I always had so called “single click” in my users GUI and starting YaST from it never showed anything about not understanding that.

If you run an application (like YaST) as root in a user session, it will use root’s config files/setings.
As I understand it, he doesn’t want to have the default settings though, but rather some changes, like double-click to open files/icons instead of single-click.

But, you don’t have to login as root to change root’s settings.
Just run “kdesu systemsettings5” in the user session.

Wow, that’s obvious in retrospect but I never thought of it, and it’s clearly a better way. Thank you.

I hope there’s some discussion on the main point, though, getting at least one photogrammetry package running under openSUSE. Those people who’ve reported successful compile from source make it sound like quite a chore, with technical challenges beyond the skill of novices, so I’m really excited that alien worked. I’ll try to test it myself, when I get some more free time, but that’s a month out at least. This experience has gotten me wondering about how packages are built and if it might be within my capacity to learn. -GEF

So, hacking COLMAP with alien doesn’t work; the prohgram just crashes. What does work?

Snaps, sort of. The latest version I could find on the build service. Don’t forget to run, as root, “systemctl enable snapd” and “systemctl start snapd” after installation.

Theoretically, you should be able to run any command from a snap by typing “snap run” in fornt of it, but I find that this throws an error of “can’t find <command> in <directory>” even when you can see for yourself that the executable is there. That rules out all the command-line utilities. However, some programs seem to work, though as I said above, I lack the skill to put e’m through their paces. Try these

snap install cloudcompare
snap install meshlab-mardy
snap install colmap-mardy

Then reboot. The menu entries won’t show up until you do, for some reason, and you want the syntax to launch the snap correctly to be automatically generated.

Mardy’s version of meshlab is newer than the version in the openSUSE community repos as of this writing, but his version of COLMAP is old. At least it seems to work, though I haven’t tested dense reconstruction because I don’t have an nvidia GPU anymore. Mardy’s version of visualsfm works on ubuntu, but on openSUSE it seems to be missing a font, so nothing’s readable, and something about the implementation keeps the log file from writing.