The GPU instance created in Classification of CIFAR-10 by GPU instance of AWS is usually expensive, so stop it and start jupyter notebook from time to time. I want to touch it from the browser. The assumption is an AWS super light user with only one instance in one region. (Because the settings are not general-purpose at all ...)
You can do the same thing by flipping through the console, but the CLI is good because it takes time. If you have more than one instance in your region, it should fail if you don't change the options you pass to jq.
Bring the instance ID with describe-instances and pass it to the start-instances. There must be a better article about the know-how in this area.
aws ec2 start-instances --instance-ids `aws ec2 describe-instances | jq -r '.Reservations[].Instances[].InstanceId'`
When "ec2" is connected to Public DNS included in the domain, the user name and key file are fixed and set to Local Forward. Now, if you connect to the local 8888 while you are connected to SSH, you will be connected to the 8889 that is waiting on the EC2 side.
Host *ec2*
User ec2-user
LocalForward 8888 127.0.0.1:8889
IdentityFile ~/.ssh/gpu.pem
SSH executes the following command so that it connects to the PublicDnsName at that time.
ssh `aws ec2 describe-instances | jq -r '.Reservations[].Instances[].PublicDnsName'`
Launch jupyter notebook so that Keras (Theano) uses GPU. The startup port is 8889.
THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 jupyter notebook --no-browser --port 8889
Send the necessary ipynb file with scp etc. The access destination will be http: // localhost: 8888 /.