Problem:
I am running into an issue with my AWS EC2 instance where I am trying to ssh to the instance from both the mac terminal and Visual studio code. The ssh gets connected initially without any problem from the terminal & VS Code but when I try to edit one of the files and start running some script the ssh communication crashes completely. And this is repeating. This never happened for a certain amount of time until I started using VS Code to ssh into the instance 🙁
This first happened when I tried to install some vscode extension onto the instance. but then could solve it by deleting vscode server extensions and folders on the EC2 instance referring from here.
Instance configuration:
- Type: t2.micro
- AMI: Deep Learning AMI GPU PyTorch 1.12.1 (Ubuntu 20.04) 20221005.
- Region: us-west-2
What I have tried:
- After going through the comments here, I checked if I was opening any large file or folder which could cause this issue but I am not doing that. I am trying to edit and run a python script that I have written which internally executes another script using this command
python3 /detect.py --weights weights/S-512.pt --source {path} --img-size 512 --conf-thres 0.6
in which the script is trying to access a folder called ‘weights/’ and it is the only folder that is considered a bit heavy with the size of 1.45 GB on disk.
- I tried stopping and starting the instance and could resolve the issue for a while, which is pretty obvious:sweat_smile:
My opinion is that the script I am running is crashing my instance and the ssh connection is getting lost.
Do you think updating the instance type to a better one with more RAM can solve the issue? or do you think I shouldn’t have VSCode at all?
2
Answers
I was able to solve the issue. In such cases, the following can be possible considerations:
The EC2 Instance type you are using and the amount of RAM that is being consumed. See here to understand the instance types and find a suitable one for you.
If you ssh through VSCode, I recommend not installing any extensions related to VSCode on the EC2 instance, which can mess up, if done.
See here for help.
Using a mac terminal/ Windows CMD prompt to execute the scripts and VSCode ssh to edit files can be a temporary solution but doesn't take you anywhere and eventually, you will land in the same problem.
I solved my problem by upscaling the instance type from a t2.micro to t2.large which gives me 4GB RAM whereas t2.micro has only 1GB RAM.
Thank you!
My first approach in this case would be to upscale the instance type to an instance with more RAM. In AWS console, did you check the monitoring tabs to see if anything weird happens when you lose the SSH connection?