Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
nVidia Optimus and CUDA
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Spiros
Apprentice
Apprentice


Joined: 11 Mar 2008
Posts: 189
Location: Zurich

PostPosted: Tue Jan 17, 2012 9:36 pm    Post subject: nVidia Optimus and CUDA Reply with quote

I'm planing to buy a Lenovo ThinkPad T420s with Optimus (i.e. in this case integrated Intel graphics and nVidia NVS 4200M). I know that Optimus under Linux is still not really working, or hacky. But I'm not really interested in high performance graphics. Instead, I would really like to be able to develop and run CUDA or OpenCL applications on this discrete graphics device and let everything else run on the Intel chip.

Is this possible? Are there any caveats?

I'm also interested in having a long-life battery. Can I hope that the disrete graphics is "turned off" while normally working on my laptop? I'm sure that the Intel graphics is more than sufficient for me.
_________________
Spiros
Back to top
View user's profile Send private message
Gusar
Advocate
Advocate


Joined: 09 Apr 2005
Posts: 2665
Location: Slovenia

PostPosted: Tue Jan 17, 2012 11:20 pm    Post subject: Re: nVidia Optimus and CUDA Reply with quote

Spiros wrote:
Can I hope that the disrete graphics is "turned off" while normally working on my laptop?

It's not, but you can turn it off manually using either acpi_call or the recently developed bbswitch module.

As for CUDA, no idea really. I'd say it should be possible but I don't know details.
Back to top
View user's profile Send private message
rmorell
n00b
n00b


Joined: 19 Jan 2012
Posts: 2

PostPosted: Thu Jan 19, 2012 6:00 pm    Post subject: Re: nVidia Optimus and CUDA Reply with quote

Hi Spiros,

Spiros wrote:
I would really like to be able to develop and run CUDA or OpenCL applications on this discrete graphics device and let everything else run on the Intel chip.

Is this possible? Are there any caveats?


Yes, this is possible. The only sticking point is getting everything installed and set up properly; it's not particularly well-documented right now, unfortunately.

The gentoo x11-drivers/nvidia-drivers ebuild should install everything you need, but will also symlink your system's OpenGL files to nvidia's. This will prevent the Intel OpenGL from working. To switch back to the Mesa OpenGL implementation that works on Intel, use:
Code:
# eselect opengl set xorg-x11

after installing nvidia-drivers.

One additional step that may be necessary on Optimus hardware that you might not realize on nvidia-only hardware is that the nvidia kernel module needs to be loaded and the /dev/nvidiactl and /dev/nvidia[0-9]+ device nodes need to be created, which can generally only be done as root. The nvidia driver components are able to do this themselves, but only when run as root. (On a system where you run an X server with nvidia's driver, since the X server is a setuid root binary, this is always the case.) In the absence of an X server running the nvidia driver, you need to perform this manually before being able to run CUDA or OpenCL apps as an unprivileged (non-root) user.

One way to do that is to run something like:
Code:
# nvidia-xconfig --query-gpu-info

as root (but note that you don't want to run nvidia-xconfig without --query-gpu-info since that will cause the intel driver to stop loading by default in your X config). Another option is to write some udev rules to do this, or add to /etc/conf.d/local.start.

Gentoo's ebuild additionally will create the /dev/nvidia* device nodes with the group "video" and restrict access to only those users in that group. So you'll need to add any users you'd like to run CUDA or OpenCL apps to the "video" group.

After that, you should be able to use CUDA and OpenCL as any user in the "video" group.

Spiros wrote:
I'm also interested in having a long-life battery. Can I hope that the disrete graphics is "turned off" while normally working on my laptop? I'm sure that the Intel graphics is more than sufficient for me.


Right now, the discrete GPU is always on in Optimus laptops. There are hacks to disable it as mentioned in this thread, but I recommend not using them since they can lead to system instability. nvidia hopes to have a better solution for power (turning off the GPU when not in use) soon.

(note: I work on the NVIDIA Linux graphics device driver team)
Back to top
View user's profile Send private message
Spiros
Apprentice
Apprentice


Joined: 11 Mar 2008
Posts: 189
Location: Zurich

PostPosted: Thu Jan 19, 2012 11:24 pm    Post subject: Reply with quote

Thank you both.

rmorell: thank you very much. Your explanations are just perfect! I will try as soon as possible (i.e. as soon as I get my laptop).
_________________
Spiros
Back to top
View user's profile Send private message
WuDDjA
n00b
n00b


Joined: 30 Aug 2005
Posts: 42

PostPosted: Fri Jan 20, 2012 9:26 am    Post subject: Reply with quote

I got the module and the bumblebee daemon working a few days ago on my Alienware Optimus chipset and I am about to write an article on the Gentoo Wiki.
At the moment everything is working perfectly on my system.

  • on boot an initscript I've written starts the bumblebeed
  • the daemon disables the nvidia card by using the bbswitch module
  • with "optirun" as a pre command I am able to start applications with nvidia native driver
  • after closing the application the bumblebee daemon unloads the nvidia driver and disables the nvidia card


The reason for me to spend days to get this software to work was the battery power.
Without disabling the nvidia card my battery life is shrinking by 4 hours

Shall I let you know when the wiki article is finished?
Back to top
View user's profile Send private message
rmorell
n00b
n00b


Joined: 19 Jan 2012
Posts: 2

PostPosted: Fri Jan 20, 2012 5:44 pm    Post subject: Reply with quote

WuDDjA wrote:

  • on boot an initscript I've written starts the bumblebeed
  • the daemon disables the nvidia card by using the bbswitch module
  • with "optirun" as a pre command I am able to start applications with nvidia native driver
  • after closing the application the bumblebee daemon unloads the nvidia driver and disables the nvidia card


Since this thread specifically mentioned CUDA, one warning about bumblebee's "power saving" option: in addition to the system unstability that I mentioned (which may vary from system to system, so maybe you get lucky), bumblebee generally doesn't know about CUDA applications, unlike OpenGL applications. So if you try to run CUDA applications while bumblebee has disabled the power to the GPU, at best they will fail, and at worst your system will become unresponsive.

It may be possible to run a CUDA application under bumblebee's `optirun` wrapper to get the power turned on (I've never tried this, though, and it might not be sufficient).

As I mentioned in my earlier post, we hope to have a better solution for this soon, so bumblebee doesn't have to go behind the driver's back to lower power usage.
Back to top
View user's profile Send private message
Spiros
Apprentice
Apprentice


Joined: 11 Mar 2008
Posts: 189
Location: Zurich

PostPosted: Mon Jan 23, 2012 7:13 pm    Post subject: Reply with quote

WuDDjA: this seems REALLY interesting! Yes, please let me know if you can!

Anyway, if I can turn on the GPU by just giving some commands, work with CUDA and then shut it down when I'm finished, I could live with that. I'm not scared of ha[/list][/list]ving an unstable system, I can live with some instabilities (I always do, actually).

After Googling a bit I found two interesting references. The first one just says "Everything is working properly (also CUDA)". The second one gives some more explanations.

[list]
[*] https://lists.launchpad.net/hybrid-graphics-linux/msg01217.html
[*] http://www.ruyk.com/tech/?p=68
[list=]
_________________
Spiros
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum