Last active
July 21, 2023 14:14
-
-
Save changx03/1944820f27ee0d37ed5499cf426812cc to your computer and use it in GitHub Desktop.
Instruction for executing Python code with a specific GPU and save console outputs and error to a log file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use `nvtop` or `nvidia-smi` to check avalible GPUs. Only allows the Python code to access a specific GPU: | |
# CUDA_VISIBLE_DEVICES=<GPU_INDEX> | |
# Redirect standard output to `main.log` and then redirect standard error to standard output: | |
# > main.log 2>&1 | |
# Allows code to run in the bakcgounrd: | |
# & | |
CUDA_VISIBLE_DEVICES=0 python main.py > main.log 2>&1 & | |
# Check CPU usage: | |
top | |
# Check GPU usage: | |
nvtop | |
# Kill program: | |
kill <UID> | |
# To read the end of log file | |
tail -f main.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment