Lei Mao bio photo

Lei Mao

Machine Learning, Artificial Intelligence. On the Move.

Twitter Facebook LinkedIn GitHub   G. Scholar E-Mail RSS

Introduction

Playing games on Ubuntu is not news. Some games on Steam were supported by Linux natively and Wine provides compatibility to Windows games. However, previously it has some restrictions for your OS environment. People often failed due to driver mismatch or missing of libraries, as you can see from the issues on the GitHub steam repository.


My gaming experience on Ubuntu 18.04 was not very successful neither. I was not able to turn on Steam, not even mentioning Windows games in Wine, with the drivers I installed for Deep Learning. Although I have tried many tricks, I was only able to play some Linux native games, such as MineTest, but not other games. To play my favorite games, such as World of Warcraft, CS:GO, and Dota 2, I would have to reboot my computer and switch to Windows 10.


Recently I found that I could start to play the games on Steam and the Windows games in Wine on Ubuntu with the latest official NVIDIA drivers. I also tried the way I configured my Ubuntu for both deep learning and gaming on several different PCs with different hardware configurations, and all of them worked pretty well. So I am very excited to write this blog post on how to configure Ubuntu for both deep learning and gaming. Now that I could do both development and gaming on Ubuntu, I feel I could hardly go back to Windows.

Protocols

In this protocol, I assume the OS is Ubuntu 18.04. The other Linux distributions might also work but I just did not test them.

NVIDIA CUDA and Driver Installation

Deep learning developers need to install both NVIDIA driver and CUDA. Usually we install the CUDA package directly from the official NVIDIA driver website, and that package would include the driver package as well. While installing CUDA and driver via this way makes future upgrade easy, it did not support gaming on Ubuntu in my case previously, at least for the driver series 418. Recently, I found upgrading to the latest driver series 430 totally supports my Ubuntu gaming demand without sacrificing the environment configuration for deep learning.


Here is how you will install the latest NVIDIA CUDA and driver. You go to https://developer.nvidia.com/cuda-downloads, select your PC architecture, Linux distribution, and Version, and finally make sure to select deb (network) for Installer Type. Then you will get the installation guide to install both the latest CUDA and driver.

NVIDIA CUDA and Driver Installation on Ubuntu 18.04

Concretely, for Ubuntu 18.04, we run the following commands to install.

$ wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.168-1_amd64.deb
$ sudo dpkg -i cuda-repo-ubuntu1804_10.1.168-1_amd64.deb
$ sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
$ sudo apt-get update
$ sudo apt-get install cuda

To verify the installation is successful. We run nvidia-smi in the terminal.

$ nvidia-smi
Wed Aug  7 21:48:46 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 430.26       Driver Version: 430.26       CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| 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 RTX 208...  Off  | 00000000:01:00.0  On |                  N/A |
| 41%   42C    P0    56W / 260W |   3357MiB / 11016MiB |     28%      Default |
+-------------------------------+----------------------+----------------------+

In this case, we could see that the driver version is 430.26 and the CUDA version is 10.2.

NVIDIA CUDA and Driver Upgrade

Once the NVIDIA CUDA and driver were installed via the way I described above, to upgrade in the future, we could simply run the following command.

$ sudo apt-get update
$ sudo apt-get upgrade cuda

Steam Installation

Because Steam games uses OpenGL as the graphics interface on Ubuntu and it seems that it only supports 32-bit OpenGL. Players with 64-bit systems have to install some weird i386 libraries, such as libgl1-mesa-dri:i386 and libgl1-mesa-glx:i386 etc. There is no such information officially from the Steam installation guide, and it is often very hard to troubleshoot what is missing for Steam for beginners.


Now we could install steam with apt, and all the dependencies will also be installed automatically.

$ sudo apt-get install steam

To run Steam, simply run the following command in the terminal.

$ steam
Steam on Ubuntu 18.04

Lutris Installation

Lutris supports a variety of Windows applications and games, including Blizzard games, using Wine. To install Lutris, please follow the instructions on the official website.


Concretely, for Ubuntu 18.04, we run the following commands to install.

$ sudo add-apt-repository ppa:lutris-team/lutris
$ sudo apt-get update
$ sudo apt-get install lutris

To run Lutris, simply run the following command in the terminal.

$ lutris
Lutris on Ubuntu 18.04

Others

There are of course other platforms, such as GOG. But I am not going to cover all of them.

Games

I played several games with the highest graphics settings on my PC which has a ROG SWIFT PG27UQ 120Hz refresh rate 4K resolution monitor and a NVIDIA RTX 2080 TI GPU.

Dota 2 from Steam

Dota 2 on Ubuntu 18.04

World of Warcraft from Lutris

World of Warcraft on Ubuntu 18.04

Final Remarks

Do remember to balance your work and game.