Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6046

Dockerfile or image for running ROS noetic with nvidia gpu

$
0
0

I have been trying to build a docker container in Ubuntu-22.04 using the following Dockerfile (modified from https://github.com/sunsided/ros-gazebo-gpu-docker.git)

FROM nvidia/cudagl:11.4.2-base-ubuntu20.04ENV TZ=Asia/Kolkata \    DEBIAN_FRONTEND=noninteractive# Run a full upgrade and install utilities for development.RUN apt-get update && apt-get upgrade -y && apt-get install -y \    mesa-utils \    vim \    nano \    build-essential gdb \    cmake cmake-curses-gui \    git \    ssh \    curl \&& rm -rf /var/lib/apt/lists/*# Register the ROS package sources.ENV UBUNTU_RELEASE=focalRUN sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $UBUNTU_RELEASE main" > /etc/apt/sources.list.d/ros-latest.list'RUN wget --output-document - \  https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add -# Install ROS.RUN apt-get update && apt-get install -y \    ros-noetic-desktop-full \&& rm -rf /var/lib/apt/lists/*RUN apt-get update && apt-get install -y \    python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential\&& rm -rf /var/lib/apt/lists/*# Initialize rosdepRUN rosdep init# Only for nvidia-docker 1.0LABEL com.nvidia.volumes.needed="nvidia_driver"# ENV PATH /usr/local/nvidia/bin:${PATH}# ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64:${LD_LIBRARY_PATH}# nvidia-container-runtime (nvidia-docker2)ENV NVIDIA_VISIBLE_DEVICES \   ${NVIDIA_VISIBLE_DEVICES:-all}ENV NVIDIA_DRIVER_CAPABILITIES \   ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics# Some QT-Apps/Gazebo don't show controls without thisENV QT_X11_NO_MITSHM 1# Create users and groups.ARG ROS_USER_ID=1000ARG ROS_GROUP_ID=1000RUN addgroup --gid $ROS_GROUP_ID ros \&& useradd --gid $ROS_GROUP_ID --uid $ROS_USER_ID -ms /bin/bash -p "$(openssl passwd -1 ros)" -G root,sudo ros \&& echo '%sudo ALL=(ALL) NOPASSWD:ALL'>> /etc/sudoers # Source the ROS configuration.RUN echo "source /opt/ros/noetic/setup.bash" >> /home/ros/.bashrcUSER rosRUN rosdep updateWORKDIR /home/${USER}

The Dockerfile is inside a docker folder in the home directory and is run using

docker build ~/Docker -t  ros_noetic

Then the following noetic_image.bash file is used to run the docker container from the home directory

#!/usr/bin/env bash# See http://wiki.ros.org/docker/Tutorials/Hardware%20Accelerationset -euo pipefail# See README.md for building this image.CONTAINER_NAME=rosDOCKER_IMAGE=ros_noetic# Which GPUs to use; see https://github.com/NVIDIA/nvidia-dockerGPUS="all"XSOCK=/tmp/.X11-unixXAUTH=`pwd`/.tmp/docker.xauthXAUTH_DOCKER=/tmp/.docker.xauthif [ ! -f $XAUTH ]then    xauth_list=$(xauth nlist :0 | sed -e 's/^..../ffff/')    if [ ! -z "$xauth_list" ]    then        echo "$xauth_list" | xauth -f $XAUTH nmerge -    else        touch $XAUTH    fi    chmod a+r $XAUTHfidocker run --rm -it \    --name "$CONTAINER_NAME" \    --gpus "$GPUS" \    --env="DISPLAY" \    --env="QT_X11_NO_MITSHM=1" \    --env="XAUTHORITY=$XAUTH_DOCKER" \    --volume="$XSOCK:$XSOCK:rw" \    --volume="$XAUTH:$XAUTH_DOCKER:rw" \    $DOCKER_IMAGE \    bash

On running the bash file the following error pops up

$ ./noetic_image.bash xauth:  error in locking authority file /home/<user>/.tmp/docker.xauth

Where are we supposed to find the .tmp folder? Although this can be run without including the xauth, on running gazebo libgl error pops up.

Could anyone help me with modifying the Dockerfile or bash file or suggest any other better method. I would like to use docker to run ros noetic with gpu and opengl support for gazebo projects. Note that I have already installed the official NVIDIA Container Toolkit from https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html

$ docker run -it --rm --gpus all ubuntu nvidia-smiUnable to find image 'ubuntu:latest' locallylatest: Pulling from library/ubuntubccd10f490ab: Pull complete Digest: sha256:77906da86b60585ce12215807090eb327e7386c8fafb5402369e421f44eff17eStatus: Downloaded newer image for ubuntu:latestTue Mar 12 14:44:29 2024       +-----------------------------------------------------------------------------------------+| NVIDIA-SMI 550.54.14              Driver Version: 550.54.14      CUDA Version: 12.4     ||-----------------------------------------+------------------------+----------------------+| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC || Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. ||                                         |                        |               MIG M. ||=========================================+========================+======================||   0  NVIDIA GeForce GTX 1650        Off |   00000000:01:00.0 Off |                  N/A || N/A   51C    P0             15W /   50W |       5MiB /   4096MiB |      0%      Default ||                                         |                        |                  N/A |+-----------------------------------------+------------------------+----------------------++-----------------------------------------------------------------------------------------+| Processes:                                                                              ||  GPU   GI   CI        PID   Type   Process name                              GPU Memory ||        ID   ID                                                               Usage      ||=========================================================================================|+-----------------------------------------------------------------------------------------+

Thank you for any help (well in advanced)!


Viewing all articles
Browse latest Browse all 6046

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>