Skip to content

Instantly share code, notes, and snippets.

@SilvesterHsu
Last active February 1, 2021 14:52
Show Gist options
  • Save SilvesterHsu/d27159a392b8f4eb54c7846e09dca6e8 to your computer and use it in GitHub Desktop.
Save SilvesterHsu/d27159a392b8f4eb54c7846e09dca6e8 to your computer and use it in GitHub Desktop.
Quick Start

Quick Start

Suppose, the ip for Remote Server is xxxx.xxxx.xxxx.xxxx. If you use a computer as both Local Machine and Remote Server, replace the ip xxxx.xxxx.xxxx.xxxx with 127.0.0.1 in the below tutorial.

Step 1: run a container [on Remote Server]

docker run -it --name ros --restart=always --gpus all --shm-size=32G -p 6006:6606 -p 8888:8888 -p 6080:80 -p 8022:22 -v ~/new_project:/notebooks silvesterhsu/ros_gpu:noetic-desktop-ubuntu20.04

Ignore all the information when run the code above, and goes to the Step 2

Step 2: open browser to connect the VNC [on Local Machine]

Browse http://xxxx.xxxx.xxxx.xxxx:6080/ to connect to the desktop inside this ROS container.

image-20210117122922428

Once we can access the vnc through browser, we can close the terminal of step 1.

Step 3: enable Pycharm debugging

Stage 1: Install pycharm_remote [on ROS Desktop]

Get to the ROS Desktop first (browse http://xxxx.xxxx.xxxx.xxxx:6080/). And run the commond below in the terminator to install pycharm_remote automatically.

wget -O - http://jupi.ink:83/ros/install_pycharm_remote.sh | bash

Stage 2. Run pycharm_reomte [on ROS Desktop]

Double click the pycharm_reomte icon on the remote ROS desktop.

Once it started, everything on the Remote Server is ready. And press any key to exit.

Stage 3. Configure Pycharm for your project [on Local Machine]

  1. Open Pycharm to set ssh connection

    • Pycharm > Preferences > Tools > SSH Configuration > Add

    • Change the host into your service IP address xxxx.xxxx.xxxx.xxxx.

    • Change the port to 8022

    • The default username is root, and the password is ShARC

    • After configuration, you can test connection and save the configure

  2. Connect to remote Python interpreter

    • Pycharm > Preferences > Project > Python Interpreter
    • Click to show all Python Interpreters, and select "add" to add new python interpreter
    • Select the existing server configuration
    • Click next to map the project path to ROS container's path /notebooks, and finish interpreter configuration
    • File synchronization will start automatically. To view remote files, Tools > Deployment > Browse Remote Host
  3. Add ROS lib to Python interpreter

    • Show the paths for the remote interpreter

    • Add ROS path /opt/ros/noetic/lib/python3/dist-packages into python interpreter

  4. Select remote Python interpreter for your project

    • Edit Run/Debug Configurations

    • Select "Remote Python" in the Python interpreter

    • And run the code below for test

      import torch #test torch with cuda
      import tf #test ros tf
      import rospy #test ros rospy
      
      print([torch.cuda.get_device_name(i) for i in range(torch.cuda.device_count())]) #check GPUs
      
      def print_hi(name):
          print(f'Hi, {name}')
      
      if __name__ == '__main__':
          print_hi('PyCharm')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment