You are not logged in.

#1 2011-10-26 15:01:06

spektre
Member
From: Sweden
Registered: 2009-05-24
Posts: 31

[SOLVED]How to use "nvidia" sometime and "xf86-video-intel" sometimes?

I have Arch on an external hard drive and move it between different machines every day. In the labs at school they use intel cards, and at home I use nvidia. It worked fine up until a couple of days ago, when I suddenly needed xf86-video-intel installed when booting at school, and replace it with nvidia when booting at home. The alternative was to have a completely garbled screen both in console and X when at a machine with non-matching drivers.

It would be nice to be able to have both intel and nvidia drivers installed, but when I try to do this, pacman says that libgl conflicts with nvidia-utils. I read this topic, but it didn't make me any wiser on what the right way would be to do this.

So, what would be the ultimate way to use the same system on machines with both intel and nvidia cards, with focus on performance for the latter case?

Last edited by spektre (2011-11-05 08:55:02)

Offline

#2 2011-10-29 10:31:06

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: [SOLVED]How to use "nvidia" sometime and "xf86-video-intel" sometimes?

There's another short, two-year-old thread here: https://bbs.archlinux.org/viewtopic.php?id=78565

Perhaps it will give you some help?

Offline

#3 2011-10-29 11:35:05

axel668
Member
Registered: 2009-08-15
Posts: 168

Re: [SOLVED]How to use "nvidia" sometime and "xf86-video-intel" sometimes?

if you don't have a special xorg configuration, shouldn't X pick the right driver automatically, if you have both installed ?


"A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila."
(Mitch Ratcliffe)

Offline

#4 2011-10-29 12:06:27

Gusar
Member
Registered: 2009-08-25
Posts: 3,606

Re: [SOLVED]How to use "nvidia" sometime and "xf86-video-intel" sometimes?

axel668 wrote:

if you don't have a special xorg configuration, shouldn't X pick the right driver automatically, if you have both installed ?

The problem is not the driver, it's the GL libs. Open drivers use mesa libs, the proprietary nvidia driver provides it's own. Gentoo uses it's eselect mechanism to switch between GL libs, but Arch doesn't have anything like eselect.

Offline

#5 2011-10-29 18:17:41

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: [SOLVED]How to use "nvidia" sometime and "xf86-video-intel" sometimes?

Here is my /etc/rc.local that does this. It only does the switch if the packages to be installed are present in the cache, so that it is not reliant on having network access. It also en/disables the file /etc/xorg.conf.d/nvidia.conf depending on the active card, since my system has some custom options set for the Nvidia card, but none for the Intel card (which "just works").

#!/bin/bash

# Swap out graphics driver packages if the cards have been switched in BIOS.
# Dodgy but functional.

# Retrieve the version of a package in the sync database.
get_sync_version()
{
    local name="$1"
    local name_ver="$(pacman -Sl | cut -d ' ' -f 2-3 | grep "^$name ")"

    [[ -n $name_ver ]] && echo "${name_ver##*' '}"
}

# Attempt to locate the package with the given name and version in the cache.
locate_in_cache()
{
    local name="$1";
    local version="$2"
    ls /var/cache/pacman/pkg | grep "^$name-$version-"
}

# Test existence of given package with same version in both sync db and cache.
do_existence_tests()
{
    pkg="$1"
    verb="$2"
    local ver="$(get_sync_version "$pkg")"

    if [[ -z $ver ]]; then
        >&2 echo "rc.local: error: Package to be $verb ($pkg) does not exist" \
            "in sync db."
        return 1
    elif ! locate_in_cache "$pkg" "$ver" >/dev/null; then
        >&2 echo "rc.local: error: Package to be $verb ($pkg $ver)" \
            "does not exist in cache."
        return 1
    fi
}

removepkg=''
installpkg=''
renamefrom=''
renameto=''
renamebase=/etc/X11/xorg.conf.d/nvidia.conf
if lspci | grep -q "VGA compatible controller: nVidia"; then
    removepkg=libgl
    installpkg=nvidia-utils
    renamefrom=$renamebase.disabled
    renameto=$renamebase
elif lspci | grep -q "VGA compatible controller: Intel"; then
    removepkg=nvidia-utils
    installpkg=libgl
    renamefrom=$renamebase
    renameto=$renamebase.disabled
else
    >&2 echo "rc.local: error: Couldn't determine active graphics card."
    >&2 echo "rc.local: error: Can't swap in appropriate drivers."
    exit 1
fi

# If removepkg is not installed and installpkg is already installed, do nothing.
do_remove=0
do_install=0
do_rename=0
if pacman -Q | grep -q "^$removepkg "; then
    echo "rc.local: Will remove $removepkg."
    do_remove=1
fi
if ! pacman -Q | grep -q "^$installpkg "; then
    echo "rc.local: Will install $installpkg."
    do_install=1
fi

if [[ ! -e $renamefrom && ! -e $renameto ]]; then
    >&2 echo "rc.local: File to be renamed ($renamefrom) does not exist."
    exit 1
elif [[ -e $renamefrom && -e $renameto ]]; then
    >&2 echo "rc.local: Target of renaming ($renameto) already exists."
    exit 1
elif [[ -e $renamefrom && ! -e $renameto ]]; then
    echo "rc.local: Will rename $renamefrom to $renameto."
    do_rename=1
fi

if (($do_remove)); then
    do_existence_tests "$removepkg" removed || exit $?
fi
if (($do_install)); then
    do_existence_tests "$installpkg" added || exit $?
fi

if (($do_remove)); then
    pacman -Rdd --noconfirm "$removepkg" >/dev/null || exit $?
    echo "rc.local: Removed $removepkg."
fi
if (($do_install)); then
    pacman -Sdd --noconfirm "$installpkg" >/dev/null || exit $?
    echo "rc.local: Installed $installpkg."
fi
if (($do_rename)); then
    mv $renamefrom $renameto || exit $?
    echo "rc.local: Moved $renamefrom to $renameto."
fi

I strongly recommend writing your own so that you can adapt it to your needs, but it should give you a general idea of what you need to do.

Last edited by Peasantoid (2011-10-29 23:34:41)

Offline

#6 2011-10-30 19:10:21

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 13,389

Re: [SOLVED]How to use "nvidia" sometime and "xf86-video-intel" sometimes?


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#7 2011-10-30 19:16:31

Gusar
Member
Registered: 2009-08-25
Posts: 3,606

Re: [SOLVED]How to use "nvidia" sometime and "xf86-video-intel" sometimes?

Lone_Wolf wrote:

Err, Bumblebee is for Optimus machines, a completely different scenario from what spektre wants.

Offline

#8 2011-10-30 19:22:49

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 13,389

Re: [SOLVED]How to use "nvidia" sometime and "xf86-video-intel" sometimes?

spektre wrote:

So, what would be the ultimate way to use the same system on machines with both intel and nvidia cards, with focus on performance for the latter case?

machines with both intel and nvidia cards very often use the optimus technology, also i do remember seeing examples of non-optimus machines where switching between intel and nvidia is possible with bumblebee.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#9 2011-10-30 19:28:56

Gusar
Member
Registered: 2009-08-25
Posts: 3,606

Re: [SOLVED]How to use "nvidia" sometime and "xf86-video-intel" sometimes?

Read his entire post. He's not dealing with an Optimus machine, his situation is moving the same installation to different machines, where some have intel and others nvidia graphics.

Offline

#10 2011-10-30 23:01:37

Awebb
Member
Registered: 2010-05-06
Posts: 6,688

Re: [SOLVED]How to use "nvidia" sometime and "xf86-video-intel" sometimes?

That doesn't make looking at Bumblebee a bad idea.

Offline

#11 2011-10-30 23:14:47

Gusar
Member
Registered: 2009-08-25
Posts: 3,606

Re: [SOLVED]How to use "nvidia" sometime and "xf86-video-intel" sometimes?

Awebb wrote:

That doesn't make looking at Bumblebee a bad idea.

With Bumblebee, you need to launch each app you wish to have on the nvidia card with "optirun app", which is cumbersome. Also, there's a performance penalty from needing to use VirtualGL. There's also no VDPAU. And what if you want to run your entire environment with opengl (like when you're using compiz or some other compositor), is that even possible with Bumblebee?

Switching around GL libs with a homebrew eselect-like thingy is way more elegant.

Last edited by Gusar (2011-10-30 23:18:28)

Offline

#12 2011-11-02 14:55:32

spektre
Member
From: Sweden
Registered: 2009-05-24
Posts: 31

Re: [SOLVED]How to use "nvidia" sometime and "xf86-video-intel" sometimes?

Wow, didn't receive any replies at first so I didn't bother to check in for a while. I'm going to try Peasantoid's script and see how it works. Looks like it should do the trick, and I don't even need the nvidia.conf part as I don't have any custom settings.

Is there any other way to keep both libs installed at the same time and switch properly between them? I guess there's no need to if the script works like it should, but it would also be interesting to know.

Thanks!

Offline

#13 2011-11-02 16:10:19

Gusar
Member
Registered: 2009-08-25
Posts: 3,606

Re: [SOLVED]How to use "nvidia" sometime and "xf86-video-intel" sometimes?

spektre wrote:

Is there any other way to keep both libs installed at the same time and switch properly between them?

What Gentoo does is install each of the libs in different places, then eselect creates symlinks to the libs you want to use. In Arch, this would require editing PKGBUILDs and then writing your own eselect-like script for symlink creation.

Offline

#14 2011-11-02 23:20:49

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: [SOLVED]How to use "nvidia" sometime and "xf86-video-intel" sometimes?

spektre wrote:

Is there any other way to keep both libs installed at the same time and switch properly between them? I guess there's no need to if the script works like it should, but it would also be interesting to know.

To my knowledge, there is no clean way of doing that. Since libgl and nvidia-utils contain conflicting files, you can't just force-install them together. You could certainly hack up something like what Gusar described, but updates would require manual intervention.

It's all Nvidia's fault for doing dodgy nonsense like requiring a custom libgl.

Offline

Board footer

Powered by FluxBB