Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the 10 Linux commands learned based on AWS?

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Based on what are the 10 Linux commands learned by AWS, I believe many inexperienced people don't know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Performing large-scale deep learning processing on AWS is a cheap and effective way of learning and development. It is recommended that dozens of GB of memory, dozens of CPU, and multiple GPU can be used for a small amount of money.

If you are new to using EC2 or Linux commands, these commands are very effective when executing deep learning scripts in the cloud.

The main contents of this paper include:

1) copy data between native machine and EC2 instance

2) make the script run safely on a daily, weekly and monthly basis

3) Monitoring the performance of processes, systems and GPU

Note: all commands are executed in a linux-like environment (Linux,OS x or cygwin)

0. Environmental agreement

Assuming that AWS EC2 is running normally, for convenience, make the following settings for the environment:

1) the IP address of the EC2 server is 54.218.86.47

2) user name is ec2-user

3) the SSH key is located in ~ / .ssh/, and the file name is aws-keypair.pem

4) work with python script

For information on how to build a GPU-based EC2 instance to perform deep learning, see:

Https://machinelearningmastery.com/develop-evaluate-large-deep-learning-models-keras-amazon-web-services/

1. Log in to the server

Before doing anything, log in to the target server. Simply, use the SSH command. Store the SSH key in ~ / .ssh/, using a meaningful file name, such as aws-keypair.pem. Log in to the EC2 host using the following command, and note the address and user name:

Ssh-I / .ssh/aws-keypair.pem ec2-user@54.218.86.47

2. Copy files to the server

Use the SCP command to copy local files to the server, for example, the command to copy the script.py file to the EC2 server is as follows:

Scp-I / .ssh/aws-keypair.pem script.py ec2-user@54.218.86.47:~/

3. Make the script run in the background of the server

By executing the script in the background of the service, you can ignore other semaphores, ignore standard input and output, and redirect all output and error messages to a log file. This is necessary for deep learning models that need to run for a long time.

> nohup python / home/ec2-user/script.py > / home/ec2-user/script.py.log & 1 &

Both script.py and script.py.log are located in the / home/ec2-user/ directory in this command. Other details on nohup and redirection reference (for example, introduction in wikipedia).

4. Execute the script on the specified GPU of the server

If EC2 supports it, it is recommended to run multiple scripts at the same time. For example, if EC2 has four GPU, you can run a separate script on each GPU. The sample code is as follows:

CUDA_VISIBLE_DEVICES=0 nohup python / home/ec2-user/script.py > / home/ec2-user/script.py.log & 1 &

If you have four GPU, you can specify CUDA_VISIBLE_DEVICES from 0 to 3. This is feasible on Keras in the background of TF, and has not been tested in Theano.

For more information about CUDA_VISIBLE_DEVICES, see https://devblogs.nvidia.com/parallelforall/cuda-pro-tip-control-gpu-visibility-cuda_visible_devices/.

5. Monitor the output of the script

If there is a project score or the running result of an algorithm in the output, it makes sense to monitor the output of the script in real time. Examples are as follows:

Tail-f script.py.log

Unfortunately, AWS shuts down the terminal when there is no output on the screen for a while, so it's best to use:

Watch "tail script.py.log"

Sometimes I can't see the standard output of python, and I don't know if it's the problem of python or EC2.

6. Monitor the performance of systems and processes

It makes sense to monitor the performance of the EC2 system, especially how much memory is used or left. For example:

Top-M

Or specify the process ID PID:

Top-p PID-M7, monitoring GPU performance

If you execute multiple scripts simultaneously on GPU and execute them in parallel, it's a good idea to check the performance and usage of each GPU. For example:

Watch "nvidia-smi" 8. Check to see if the script is still running on the server

Normally, the terminal is kept open all the time.

Watch "ps-ef | grep python" 9. Edit the file on the server

It is generally not recommended to modify it directly on the server, except that you are familiar with vi:

Vi ~ / script.py

The usage of vi will not be repeated here.

10. Download files from the server

As opposed to uploading a file, this is an example of the next png file:

Scp-I ~ /. Ssh/aws-keypair.pem ec2-user@54.218.86.47:~/*.png. A few points to pay attention to

If you want to run multiple scripts at the same time, it is best to choose EC2 with multiple GPU

It is best to write scripts locally

Output the execution result to a file and download it to the local for analysis

Use the watch command to keep the terminal running

Execute remote commands locally

In fact, most of them are the basic skills of background development engineers, just a little reference value for interest enthusiasts.

After reading the above, have you mastered what the 10 Linux commands are based on AWS? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report