15

I am using Ubuntu 16.04, since it is the OS that I found more convenient for working with convolutional neural networks (CNN). The process of installing Ubuntu was fine until I wanted to setup two graphic cards on the same system:

  • NVIDIA 970 GTX
  • AMD R9 380

I wanted to use my NVIDIA card only for CUDA in order to be able to use all its graphic memory and the AMD for the graphical user interface. To this end all monitors will be plugged into this card.

Problems:

  • When I install the nvidia and cuda 8.0 drivers all seems OK, but when I install the AMD driver I can not login to lightdm.
  • If I plug the monitors on the AMD cards it says that lightdm is running in low graphic mode and nothing work.
  • Modify the xorg.conf file do not makes any difference since it is overwritten by the gpu-manager

I could not find any tutorial explaining how to do so.

Marcus
  • 451
  • 1
  • 4
  • 10

1 Answers1

12

Before starting I recommend to install ssh in order to be able to shutdown the system remotely if something goes wrong. To do so use this command:

sudo apt-get install ssh

and to shutdown your system you have to ssh with another computer or mobile device and use this command:

sudo shutdown -r now

Step 1

First of all you have to remove the AMD card physically, keep your NVIDIA card and install CUDA and the NVIDIA driver. You can download cuda from here: https://developer.nvidia.com/cuda-downloads

Make sure that all is working using this command:

nvidia-smi

Step 2

At this point we have to modify grub in order to start in console mode since we are messing with graphic cards.

Using your favorite editor (in my case joe) edit the default grub configuration file:

sudo joe /etc/default/grub

And change these lines:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
#GRUB_TERMINAL=console

to these ones:

GRUB_CMDLINE_LINUX_DEFAULT="text"
GRUB_CMDLINE_LINUX="text"
GRUB_TERMINAL=console

Finally update grub using this command:

sudo update-grub

Step 3

Shutdown your system and remove the NVIDIA card and plugin the AMD card. Turn on your computer and install the latest AMD graphic drivers. In my case I installed the drivers using these commands:

wget https://www2.ati.com/drivers/linux/ubuntu/amdgpu-pro-16.40-348864.tar.xz
tar -Jxvf amdgpu-pro-16.40-348864.tar.xz
cd amdgpu-pro-16.40-348864/
./amdgpu-pro-install
sudo usermod -a -G video $USER

Restart your computer. Now you can start lightdm (the user interface) using this command:

sudo service lightdm start

All should work as expected and now you can setup your displays using the system settings.

Step 4

Shutdown your system and now add your NVIDIA card and do not remove the AMD (at this points you will have two graphic cards in your system). Turn on you computer and log in using your user name but DO NOT START LIGHTDM!!

At this point the gpu-manager has automatically setup both graphic cards for the console mode and only AMD for lightdm (since we started lightdm in the previous step). If we run lightdm at this point gpu-manager will make a mess. So now we have to completely disable the gpu-manager. To this end we have to modify grub again:

sudo joe /etc/default/grub

and replace these lines:

GRUB_CMDLINE_LINUX_DEFAULT="text"
GRUB_CMDLINE_LINUX="text"
GRUB_TERMINAL=console

by these ones:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nogpumanager"
GRUB_CMDLINE_LINUX=""
#GRUB_TERMINAL=console

Finally update grub using this command:

sudo update-grub

Step 5

Restart your system and if the lightdm do not start correctly (it appears a black screen) then you have to press Ctrl+F1, login in console mode and add this command to the rc.local file:

sudo joe /etc/rc.local

add this line before "exit 0":

service lightdm start

restart your system and all should work fine now ...

In a console you can check that both graphics cads are in use using this command:

lspci -nnk | grep -i vga -A3 | grep 'in use'

Kernel driver in use: amdgpu
Kernel driver in use: nvidia

and nvidia-smi should work fine. showing that you are using 0 megabytes of memory:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 375.26                 Driver Version: 375.26                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 970     Off  | 0000:02:00.0     Off |                  N/A |
| 30%   42C    P0    36W / 163W |      0MiB /  4036MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
Arronical
  • 19,653
  • 18
  • 73
  • 128
Marcus
  • 451
  • 1
  • 4
  • 10
  • I've been trying to get this to work for a couple days. Which kernel did you use on Ubuntu 16.04? – Aaron Skomra Jul 14 '17 at 20:02
  • Have you succeeded? – Szymon Roziewski Sep 06 '17 at 16:20
  • First of all make sure that both cards works with ubuntu 16.04. Try to setup each card alone using their drivers. Then it is possible that you might have to uninstall the ATI drivers in order to start the process described in here. When I say alone I mean remove both graphics cards from the PC and then add only one. – Marcus Sep 08 '17 at 08:26
  • I no longer have this computer so I can not tell you the kernel version ... – Marcus Sep 08 '17 at 08:28
  • wow this like the holy grail! – Bent Cardan Feb 04 '18 at 06:30
  • sorry I'm new at Ubuntu, I'm having trouble at step 4 how do I turn on the computer, log in using my username and don't start lightdm? I did all the steps except for this one after step 3 I didn't log in but my computer restarted to the user interface. I press crtl+f1 to do step 4, but now I'm stuck in a login loop. I login, loads and comes back to the login interface, can someone help me? – Ale Feb 15 '18 at 13:53
  • Step 2 to 4 can only be done in console mode (runlevel 3), if the method proposed in Step 2 doen't work, you can try [this](https://www.if-not-true-then-false.com/2012/howto-change-runlevel-on-grub2/) or [this](https://superuser.com/questions/1106174/boot-ubuntu-16-04-into-command-line-do-not-start-gui) – Marcus Feb 16 '18 at 14:49
  • Not understanding the purpose of some of these steps, they seem extraneous, I was able to skip a few and still have it working. One recommendation I might add is dont forgot the page size flag in grub otherwise you'll suffer in AMD performance. `amdgpu.vm_fragment_size=9` – Joseph Persico Apr 14 '18 at 16:21
  • @Marcus Hi, I will be trying this with Ubuntu 18.04 with RTX 2070 (for CUDA) and Sapphire RX 570 Nitro+ 8GB (for Display). Will any of what you said above change if I connect my 4k display directly to the RX 570 instead of the MB? Or is this the setup you assumed in your answer? – d84_n1nj4 Dec 04 '18 at 18:42
  • 1
    @d84_n1nj4 I didn't try on ubuntu 18.04, maybe it works directly without having to do all these steps ... it would be nice if you could share your experience. – Marcus Dec 05 '18 at 19:54
  • 1
    @Marcus I’ll do that. Should have it started/done by Monday. Well, as soon as Amazon ships my backordered 4K monitor > – d84_n1nj4 Dec 05 '18 at 19:58
  • 2
    @Marcus it actually worked directly after connection--I didn't have to go through any steps ^^ – d84_n1nj4 Dec 20 '18 at 14:05
  • @d84_n1nj4, good news! Ubuntu is evolving fast! – Marcus Dec 21 '18 at 19:35
  • @d84_n1nj4: I am in the same situation. I have two RTX card right now, but I'm gonna install a radeon 4550 for driving the display (I have three x16 slots) . If I am not misunderstanding you, the AMD drivers will be automatically installed, and this won't break the nvidia drivers. Am I right? Thanks! – MadHatter Mar 14 '19 at 16:02
  • @MadHatter That's correct. I connected the hdmi cable directly to the amd graphics card. Booted the system up for the first time, and installed the needed nvidia drivers. Then the rtx 2070 worked without giving resources towards the display. – d84_n1nj4 Mar 14 '19 at 16:07
  • Thanks. I installed the 4550 a few minutes ago. Now, it works with the mesa driver, but max res is stuck to 1080p, while i have a 21:9 display with 2560x1080 native res. Any clue about how to fix this? Did your 18.04 install the mesa driver for the amd card? Again, thanks! (The two nvidias do work perfectly for computing). – MadHatter Mar 14 '19 at 23:24