{"id":18171375,"url":"https://github.com/ndhana94/ros_nvidia_container","last_synced_at":"2026-07-02T10:32:06.845Z","repository":{"id":260378734,"uuid":"881129527","full_name":"NDHANA94/ros_nvidia_container","owner":"NDHANA94","description":"ROS Noetic (can be setup for other distros) container with NVIDIA GPU-accelerated OpenGL for Gazebo and RViz. ","archived":false,"fork":false,"pushed_at":"2024-11-21T15:46:33.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T12:19:28.310Z","etag":null,"topics":["devcontainer","docker-container","nvidia-cuda","nvidia-docker","nvidia-gpu","ros","ros2"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NDHANA94.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-31T00:43:08.000Z","updated_at":"2024-11-21T15:46:37.000Z","dependencies_parsed_at":"2024-10-31T01:29:37.154Z","dependency_job_id":"518da119-aef4-4570-a7d8-89ad0b76e1f4","html_url":"https://github.com/NDHANA94/ros_nvidia_container","commit_stats":null,"previous_names":["ndhana94/ros_nvidia_container"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NDHANA94%2Fros_nvidia_container","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NDHANA94%2Fros_nvidia_container/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NDHANA94%2Fros_nvidia_container/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NDHANA94%2Fros_nvidia_container/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NDHANA94","download_url":"https://codeload.github.com/NDHANA94/ros_nvidia_container/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247622281,"owners_count":20968561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["devcontainer","docker-container","nvidia-cuda","nvidia-docker","nvidia-gpu","ros","ros2"],"created_at":"2024-11-02T15:08:49.102Z","updated_at":"2026-07-02T10:32:06.815Z","avatar_url":"https://github.com/NDHANA94.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"## ROS Docker Container with NVIDIA GPU-Accelerated OpenGL for Gazebo and RViz\n\nThis repo explains how to create a docker container on an Ubuntu host machine with NVIDIA GPU accelerated OpenGL for Gazebo and RViz Graphic rendering for a smooth simulation experience with ROS. \n\n### OUTLINE\n1. [Host Machine Setup for NVIDIA GPU](#1-host-machine-setup-for-nvidia-gpu)\n2. [Building the Docker Image](#2-building-the-docker-image)\n3. [Run the container](#3-run-the-container)\n4. [Open in VS-Code DevContainer](#4-open-in-vs-code-dev-container)\n\n\u003c/br\u003e\n\u003c/br\u003e\n\n## 1. Host Machine Setup for NVIDIA GPU:\n\nFollow these steps to setup your Ubuntu host machine to enable docker to use the NVIDIA GPU:\n\n1. Make sure you have installed NVIDIA Driver. \n    - Run this command to verify.\n        ```bash\n        nvidia-smi\n        ```\n\n        If the driver is installed correctly, this command will display information about your NVIDIA GPU, including driver version, and CUDA version. \n        \n        \u003c/br\u003e\n\n    - If it's **NOT** installed;\n        - Update the Package List:\n            ```bash\n            ubuntu-drivers devices\n            ```  \n        - Detect Available NVIDIA Drivers: Use the ubuntu-drivers tool to find compatible drivers for your system:\n            ```bash\n            ubuntu-drivers devices\n            ```\n\n            This command will list all available NVIDIA drivers for your GPU. The recommended driver version will be indicated.\n\n        - Install the Recommended Driver: To install the recommended driver version:\n            ```bash\n            sudo ubuntu-drivers install\n            ```\n\n            Alternatively, you can specify a specific driver version (e.g., nvidia-driver-560):\n\n            ```bash\n            sudo apt install nvidia-driver-560\n            ```\n        \n        - Reboot the System: After installation, reboot your system for the driver to take effect.\n            ```bash\n            sudo reboot\n            ```\n\n        - Verify Installation: After rebooting, run nvidia-smi to check if the driver was installed successfully.\n            ```bash\n            nvidia-smi\n            ```\n            \u003c/br\u003e\n\n\n2. Install [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) and `nvidia-docker2:\n\n    -  Configure the production repository for `nvidia-container-toolkit`:\n        ```bash\n        curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \\\n        \u0026\u0026 curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \\\n            sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \\\n            sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list\n\n        ```\n\n    - Update the packages list from the repository and Install the NVIDIA Container Toolkit packages:\n        ```bash\n        sudo apt-get update\n        sudo apt-get install -y nvidia-container-toolkit\n        ```\n\n    - Configure the container runtime by using the nvidia-ctk command:\n        ```bash\n        sudo nvidia-ctk runtime configure --runtime=docker\n        ```\n    - ⚠️ Make sure `/etc/docker/daemon.json` file exists and configured correctly. It should have the following context.\n        ```json\n        {\n            \"default-runtime\": \"nvidia\",\n            \"runtimes\": {\n                \"nvidia\": {\n                    \"args\": [],\n                    \"path\": \"nvidia-container-runtime\"\n                }\n            }\n        }\n        ```\n\n        - If you don't have this file create one:\n            ```bash\n            sudo nano /etc/docker/daemon.json\n            ```\n\n            - copy/paste the above mentioned configuration.\n            - save (ctrl+s) and exit (ctrl+x)\n         \n    - Install `nvidia-docker2`:\n        ```bash\n        sudo apt-get update\n        sudo apt-get install -y nvidia-docker2\n        ```\n\n    - Restart the Docker daemon:\n        ```bash\n        sudo systemctl restart docker\n        ```\n\u003c/br\u003e\n\n3. Make sure your host has selected NVIDIA GPU for rendering:\n\n    - Install `prime`:\n        ```bash\n        sudo apt-get install nvidia-prime\n        ```\n    \n    - select NVIDIA GPU for rendering:\n        ```bash\n        sudo prime-select nvidia\n        ```\n    \n    - Verify selection:\n        ```bash\n        prime-select query\n        ```\n\n\n\u003c/br\u003e\n\u003c/br\u003e\n\n## 2. Building the Docker Image:\n\n- Clone this repo:\n    ```bash\n    cd ~/\n    git clone .....\n    cd ros_nvidia_container\n    ```\n    \u003c/br\u003e\n\n- ⚠️ The provided Dockerfile  (`ros_nvidia_container/.devcontainer/Dockerfile`) is configured for installing ROS Noetic in the container. If you wish to use a different ROS distribution, please modify the Dockerfile accordingly.\n\u003c/br\u003e\n\n- ⚠️ Edit the `cuda-toolkit` version (**line: 43**) for your host cuda version. ( running `nvidia-smi` command you can see the cuda version.)\n- Build the docker image:\n    ```bash\n    cd ~/ros_nvidia_container\n    docker build -t \u003cImage Name\u003e .devcontainer/\n    ```\n\n- ⚠️ Check if your host has `.Xauthority` file in `HOME` directory:\n    ```bash \n    ls ~/.Xauthority\n    ```\n\n    - If the file does not exist, create one:\n\n        ```bash\n        touch ~/.Xauthority\n        ```\n\n-  Permissions to `.Xauthority` file:\n    ```bash\n    chmod 664 ~/.Xauthority\n    ```\n\n\u003c/br\u003e\n\u003c/br\u003e\n\n## 3. Run the container:\n\nUse the `run_ros_nvidia_container.sh` file to run the docker container. \n\n- ⚠️ Edit the image name in `run_ros_nvidia_container.sh` file (**line: 36)** to the image name you chose to build.\n\n- ⚠️ configuring X11 permissions for Docker:\n    ```bash\n    xhost +local:docker\n    ```\n    Running this command is very important before running the container to run GUI applications inside a Docker container and display them on your host's screen.\n\n- Grant executable permission:\n    ```bash\n    chmod +x ~/ros_nvidia_container/run_ros_nvidia_container.sh\n    ```\n\n- Run the container:\n    ```bash\n    ~/ros_nvidia_container/run_ros_nvidia_container.sh\n    ```\n\n\u003c/br\u003e\u003c/br\u003e\n\n## 4. Open in VS-Code Dev Container:\n\nYou can use vscode remote extention to open this container.\n\n1. Open VS-Code and Install `Install the Dev Containers` extension.\n\n2. Open Your Project: Open the folder that contains your .devcontainer directory.\n\n3. Reopen in Container:\n    - Once you have the folder open in VS Code, you can reopen it in a container by clicking on the green icon in the bottom left corner of the VS Code window.\n    - From the menu, select Remote-Containers: Reopen in Container. This option will build the Docker image defined in your Dockerfile and start a new container based on it.\n\n4. Build and Start the Container: \n    - VS Code will automatically read the configuration from the .devcontainer/Dockerfile and .devcontainer.json files, build the container, and open a new window connected to it. You can monitor the output in the terminal that appears in the bottom panel.\n\n5. Access the Terminal: \n    - Once the container is running, you can open a terminal inside the container by going to Terminal \u003e New Terminal. This terminal will give you access to the environment set up in your Docker container.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndhana94%2Fros_nvidia_container","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fndhana94%2Fros_nvidia_container","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndhana94%2Fros_nvidia_container/lists"}