Last active
August 30, 2018 16:24
-
-
Save ZhijieWang/60cf77a1a6c7edae3c24ee1d140fd968 to your computer and use it in GitHub Desktop.
Instruction on setting up AMD and NVIDIA GPU in Ubuntu 16.04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Source: | |
https://askubuntu.com/questions/892532/nvidia-card-for-cuda-and-amd-card-for-display-on-ubuntu-16-04 | |
Credit to Marcus on StackOverflow. This Gist is for archive and reference purpose. | |
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 | | |
+-----------------------------------------------------------------------------+ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment