Reputation: 3255
I have a laptop running Ubuntu 18.04 with both Intel and NVIDIA graphics cards
00:02.0 VGA compatible controller: Intel Corporation 4th Gen Core Processor Integrated Graphics Controller (rev 06)
01:00.0 VGA compatible controller: NVIDIA Corporation GM204M [GeForce GTX 970M] (rev a1)
I would like to use the Intel card for my actual graphics display, and my NVIDIA card for simultaneously running GPGPU things (e.g. TensorFlow models, other CUDA stuff, OpenCL). Is this possible? How would I go about this?
Ideally, I'd be able to turn the NVIDIA GPU on and off easily, so that I can just turn it on when I need to run something on it, and turn it off after to save power.
Currently, I have it set up with nvidia-prime
so that I can switch between one card or the other (I need to reboot in between). However, if I've loaded the Intel card for graphics (prime-select intel
), then the NVIDIA kernel drivers never get loaded and I can't access the NVIDIA GPU (nvidia-smi
doesn't work).
I tried loading the NVIDIA kernel module with sudo modprobe nvidia
when running the graphics on Intel, but I get ERROR: could not insert 'nvidia': No such device
.
Upvotes: 1
Views: 1124
Reputation: 139
Short answer: You can give a try to my modified version of prime-select, which adds an 'hybrid' profile (graphics on Intel, TensorFlow and other CUDA stuff on Nvidia GPU). https://github.com/lperez31/prime-select-hybrid
Long answer:
I came around the same issue and found several blogs talking about different solutions, but I wanted a more straightforward solution, and I didn't want to have to switch between profiles each time I needed TensorFlow to run on Nvidia GPU.
When setting the 'intel' profile, prime-select blacklists three modules: nvidia, nvidia-drm and nvidia-modeset. It also removes the three aliases to these modules. Thus, when running in intel profile, the sudo modprobe nvidia
command should fail. Indeed, if the alias would not have been removed, this command should do the trick.
In order to use Intel for graphics and Nvidia GPU for TensorFlow, the 'hybrid' profile in the modified version of prime-select above blacklists nvidia-drm and nvidia-modeset modules, but not nvidia module. Thus nvidia drivers are loaded, but as nvidia-drm (Display Rendering Manager) is not loaded, the graphics remain on Intel GPU.
If you don't want to use my version of prime-select, you could just edit /usr/bin/prime-select and comment the two following lines:
blacklist nvidia
alias nvidia off
With these lines commented, nvidia-smi
command should run even in 'intel' profile, you should be able to use CUDA stuff on Nvidia GPU and your graphics will use Intel.
Upvotes: 0
Reputation: 5764
Yes, this is indeed possible. It is called "Nvidia Optimus" and means that the integrated Intel GPU is used by default to save power and the dedicated Nvidia GPU is used only for high-performance applications. Here are guides on how to set it up in Linux:
The Ultimate Guide to Setting Up Nvidia Optimus on Linux
Upvotes: 0