Skip to content
Jack Liu edited this page Feb 5, 2018 · 6 revisions

Welcome to the ros-docker-images wiki!

NVIDIA video card installation inside docker container

For NVIDIA video card users, you must install the NVIDIA video driver in container, and the driver version should be same with your host.

The following instructions will help you.

Confirm your device from host

In your host, open a terminal and run the following command,

$  lspci |grep -i nvidia

01:00.0 VGA compatible controller: NVIDIA Corporation GM206 [GeForce GTX 960] (rev a1)
01:00.1 Audio device: NVIDIA Corporation Device 0fba (rev a1)

It will confirm what video card you are using with.

Confirm your video driver from host

$ dpkg --list |grep nvidia

ii  nvidia-367                                                  375.39-0ubuntu0.16.04.1                               amd64        Transitional package for nvidia-375
ii  nvidia-375                                                  375.39-0ubuntu0.16.04.1                               amd64        NVIDIA binary driver - version 375.39
ii  nvidia-modprobe                                             361.28-1                                              amd64        utility to load NVIDIA kernel modules and create device nodes
rc  nvidia-opencl-icd-367                                       367.57-0ubuntu0.16.04.1                               amd64        NVIDIA OpenCL ICD
ii  nvidia-opencl-icd-375                                       375.39-0ubuntu0.16.04.1                               amd64        NVIDIA OpenCL ICD
ii  nvidia-prime                                                0.8.2                                                 amd64        Tools to enable NVIDIA's Prime
ii  nvidia-settings                                             361.42-0ubuntu1  

Here we need nvidia-375 as the video card driver, then you may get nvidia-xxx.

If you want offline install NVIDIA driver, you should get more exact version of the driver package. For more exact version of your nvidia driver, you can get from details of above package, like

$ apt-cache show nvidia-375 | grep Version

Version: 375.66-0ubuntu0.16.04.1

Please replace nvidia-375 with your own nvidia-xxx.

For offline install NVIDIA driver, you can get the driver package from NVIDIA official website or NVIDIA X86_64 Display Archive with this version.

Run ros docker image with --privileged option

$ docker run --privileged  \
 --security-opt="label:disable"  \
 --security-opt seccomp:unconfined  \
 --env="DISPLAY" --env QT_X11_NO_MITSHM=1  \
 --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw"  \
 --volume="/path/to/your_workspace:/data:rw"  \
 --volume="/path/to/gazebo_models:/home/ros/.gazebo/models:rw"  \
 --name="ros_kinetic"  \
 jacknlliu/ros:kinetic-ide terminator

NOTE: /path/to/your_workspace and /path/to/gazebo_models should be customized by yourself.

Then we will get a terminator window from the docker container named ros_kinetic.

Install nvidia video driver inside container

Run the following command within the terminator window from container.

$ sudo aptitude update -y
$ sudo aptitude install -y -R nvidia-375

NOTE: nvidia-375 should be replaced by your version from the above steps.

If you want offline install the driver, you should download the driver package with exact version from NVIDIA official website or NVIDIA X86_64 Display Archive. And put your driver package in your shared directory with docker container, here we use /path/to/your_workspace on host. And then execute the following command in your container,

# cd to your shared directory with host
cd /data

# run driver installation program with root priviledge
sudo ./NVIDIA-Linux-x86_64-375.66.run -a -N --ui=none --no-kernel-module

Exit docker container and restart

After these steps, you can exit the container just with Ctrl-D or exit in the terminator window. And then restart the docker container with the following command

$ docker start ros_kinetic

Test

After enter the container, run the following command within the terminator window,

$ glxgears

If you get the following output, then everything seems working!

Running synchronized to the vertical refresh.  The framerate should be
approximately the same as the monitor refresh rate.
373 frames in 5.0 seconds = 74.462 FPS
300 frames in 5.0 seconds = 59.998 FPS