11-785 Spring 2023 Recitation 0F: AWS Fundamentals (Part 4/4)
Welcome to the last part of the AWS reservation. In this video, we are going to talk about remote process. If we are running code that takes a long time to complete, for example, here I have a code snippet that outputs the timestamp to the output file every two seconds. If we just run it from the terminal like this, now the code is running. It always happens that the execution stops because of the SSH connection is closed or simply we close the terminal by accident. We can see the code stops running. This training usually takes several hours. It is very inconvenient that we need to keep our laptop and connection open all the time. The first solution we are going to introduce is screen command. It allows us to create new terminals to execute our code in the background. To start a new session, tapping the command screen-s with a session name. Now we are in a new session. We can start running the code normally within this session. Not the code is executing. We can exit the current session using control A and D. We can see that the code is still running and updating the output file. To go back to the session, we can type in screen-r with session name. We can see that even if we close the terminal by accident, the code will still keep running. Now let’s stop the code. The second solution we are going to talk about is DrifterLab. If you are a notebook person and you don’t like to run, stoppy code. Here is a solution for you to set up a DrifterLab server on your ECU instance. In this way, you can run your notebooks without interaction. First, we need to install DrifterLab in your environment. Here, I already have it installed. Next, we need to create a Python script and paste the code to generate hashed password. The code is available on the slide. And replace this screen with your password. Then run the script. Copy and paste the output for your hashed password for later use. The next step is to create a configuration file for DrifterLab server. Make this directory if it does not exist before. Then go to this directory and create a file named DrifterServerConfig.py. Then copy and paste the configurations available on the slide. And then replace this string. With the hashed password, you address copied. And then save the configuration file. The last step is to open a screen session and run our DrifterLab server. Create a session named Drifter and activate our environment. Then run DrifterLab to start the session. You can see that our lab is running on 8888. It’s the pot number we set in our configuration file. Then we go to our AWS console. Find our instance. Copy the public IP address. Press and go to 8888. Put in the password. Then we have a notebook environment to use. Even if we accidentally close everything, as long as your ECQ instance is running, the notebook will be working correctly. One thing to notice is that if you cannot access this page successfully, go back to the ECQ instance page, go to the security tab and find the security group for your instance. Here I’m selecting group deep learning. Then let’s go to the network and security, select security groups and find the corresponding security group. Check if there is an inbound rule with type custom TCP and the port for our DrifterLab. If there isn’t such a rule, we can add an inbound rule, click add rule, and configure the pot number here. After this step, you should be able to access DrifterLab successfully.