Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative docker solution with no vnc required (with NVIDIA driver) #1

Open
ooUglyGuyoo opened this issue Mar 28, 2023 · 3 comments

Comments

@ooUglyGuyoo
Copy link

ooUglyGuyoo commented Mar 28, 2023

I wrote this issue in case someone needs it and is willing to f**k things up like me. In general, I am not using the docker image and method TA provided which is definitely not recommended by the teaching team. I personally still have doubts about the method below but it is the most rapid way for me to start my assignment, so I just go with it. I DO NOT TAKE ANY RESPONSIBILITY if the below method has problems and issues and affect others from submitting their assignment. So please think carefully before adopting the following method. You may reply to this issue if something went wrong, I will try my best to reply if I have time.

My machine setting:

Distributor ID: Ubuntu
Description: Ubuntu 22.04.2 LTS
Release: 22.04
Codename: jammy

description: VGA-compatible controller
product: GA102 [GeForce RTX 3080 Lite Hash Rate]
vendor: NVIDIA Corporation

Linux 5.19.0-38-generic #39~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 17 21:16:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

I am using ubuntu 22.04 but should also work for windows and other ubuntu distribution.

Install Docker

Follow the guide bellow to install docker
https://docs.docker.com/engine/install/

Install Nvidia Container

Check whether your NVIDIA driver is setup properly.

nvidia-smi

You can follow the link below if it is not:
https://www.cyberciti.biz/faq/ubuntu-linux-install-nvidia-driver-latest-proprietary-driver/
Follow the guide bellow to install Nvidia-container
https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html

Docker run

Replace <CONTAINER NAME> (eg: elec5660-test)
Replace <WORKSPACE ON YOUR COMPUTER> (eg: /home/name/elec5660/proj2phase1)

docker run --name <CONTAINER NAME> --volume="<WORKSPACE ON YOUR COMPUTER>:/home/workspace" --gpus all --network host -env=DISPLAY -env=NVIDIA_DRIVER_CAPABILITIES=all -env=NVIDIA-VISIBLE_DEVICES=all -env=QT_X11_NO_MITSHM=1 -v /tmp/.X11-unix:/tmp/.X11-unix:rw --runtime=nvidia --privileged -it docker.io/koenlek/ros-nvidia:kinetic-desktop-full

Add ros setup.bash to .bashrc or source it for every terminal

source /opt/ros/kinetic/setup.bash

Start rviz

should be able to start rviz normally now.

If you cannot connect to display, on your own computer terminal (not in docker), execute

xhost +

Install cmake

sudo apt install cmake

Project code management

In docker

cd /home/workspace
mkdir src
mv aruco-1.2.4/ src/
mv tag_detector/ src/
cd src/aruco-1.2.4/
mkdir build
cd build
cmake ..
make
make install
cd /home/workspace/

(remember to source ros setup.bash)

catkin_make

should build successfully.

HAPPY CODING!

@ooUglyGuyoo ooUglyGuyoo changed the title Alternitive docker solution with no vnc required Alternative docker solution with no vnc required (with NVIDIA driver) Mar 28, 2023
@Peize-Liu
Copy link
Contributor

Good Job. I notice that you use the unofficial docker image to start your docker. I am considering building a new docker image from the Nvidia image(in 2023, we don't have much time to build images based on official ones for different hardware platforms) to enhance students' experience on coding in docker and fully use your hardware.

@ooUglyGuyoo
Copy link
Author

I tried it on windows. Though I can find the driver using nvidia-smi, there are still bugs when running rviz Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface. Segmentation fault. Seems that it can not work properly. Most of the solutions I found said it is necessary to run docker in a docker in WSL. So I just give up. Windows are full of shit. Ubuntu is good. :) You can close this issue if needed. Thanks.

@ooUglyGuyoo
Copy link
Author

Follow up!
Since I upgraded to Win 11 with a brand new system, I retried running ros graphic apps (RViz, Gazebo) in Docker for Windows and somehow I made it work.

This time I only followed some of the tutorials and it worked quite smoothly (Don't know why).

  1. Install WSL2 in terminal with wsl --install
  2. Restart the computer and open ubuntu in the start manual. Set up user info.
  3. Update and upgrade packages sudo apt update && sudo apt upgrade
  4. Setup Linux GUI apps: sudo apt update sudo apt install gnome-text-editor -y sudo apt install gimp -y sudo apt install nautilus -y sudo apt install vlc -y sudo apt install x11-apps -y
  5. You can try xcalc, xclock, xeyes
  6. Install Docker Desktop.
  7. Install Xserver.
  8. Restart your computer.
  9. Run Xserver by XLaunch.
  10. Once again, Docker in Visual Studio Code is suggested.
  11. Install ros docker (I only tried noetic since I am gonna use that instead of kinetic): docker pull osrf/ros:noetic-desktop-full
  12. Run docker: docker run -it --name ros-test -e DISPLAY=host.docker.internal:0.0 -e LIBGL_ALWAYS_INDIRECT=0 docker.io/osrf/ros:noetic-desktop-full
  13. echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
  14. Now you can do roscore and rviz or gazebo to test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants