Note
This repo is about a set of commands which might be useful for AI coding.
tmux is useful when you have to utilize multiple terminals concurrently without termination.(i.e., efficient terminal usage!)
Multiple sessions can be created via tmux, and it results in more efficient terminal mangement than single one.
- Prerequisite
sudo apt-get install tmux
- Create a session
tmux new -s <sessions_name>
- Print out information on session
Information includes in session name, the number of windows, and current attached session
tmux ls
- Enter a session
tmux attach -t <session_name>
- Detach from a session
If using this command, you need to the former and the latter separately not concurrently(i.e., 1) ctrl+b, 2) d
ctrl+b -> d
- Create a new window
ctrl+b -> c
- Check current storage capacity
df -h
- print current working directory
pwd
- Check your CUDA version
nvcc -V
- Output current directory's capacity
du -sh .
- Check all running processes' id and command
nvidia-smi | grep python | awk '{print $5}' | xargs -I{} ps -p {} -o pid,cmd
- Print list of currently running prcoesses on background
jobs
- Monitor resource usage and running processs
top
- Similar to top, but better in terms of visualization
nvtop # recommended
htop
1. Install pytorch library with cuda
You might as well check whether cuda version is aligned with pytorch one.
conda install pytorch=='your version' torchvision=='version' torchaudio=='version' pytorch-cuda='cuda-version' -c pytorch -c nvidia
2. Check whether to be ready for running GPU or installed cuda on your OS
cuda_is_available() module in pytorch
3. List of conda virtual environments
conda env list
4. Create conda virtual environment python version is specified
conda create -n (env name) python='version'
5. Remove your conda virtual environment
conda env remove --name (env name) --all
6. Activate/Deactivate conda virtual environment
conda activate/deactivate
1. Cwd path setting
ctrl+shift+p
2. KeyInterrupt during code execution
ctrl+c
or you can insert process termination call(i.e., exit()) into your code snippet
exit()
Unzip your file in specified directory
# -q: quiet mode, -qq: without any output
unzip file_name.zip -d /path/to/directory
unzip -qq (your zip file name)
Download files stored in google drive
pip install gdown
gdown --fuzzy (google drive link)
Alternative to the above
wget <your_url>
file_name.zip -d /path/to/directory
1. Print all branches
git branch
2. move other branch
git checkout <branch_name>
3. Create a branch and move to it
git checkout -b <branch_name>
4. Setting user name and email
git config user.name "Your Name"
git config user.email "[email protected]"
5. Check git's global setting
git config --global --list
6. Print commit logs
git log
7. Clone not all but certain directories for big size repository(you can test it via transformers)
git clone --no-checkout <repo_url>
cd repo_dir
git sparse-checkout init --cone
git sparse-checkout set dir1 dir2 ...
git checkout main
If you change the file which extension is csv, then you might as well save xlsx extension to ensure that changes are applied in terms of visualization. (csv 파일의 세팅을 변경했다면, 시각화 측면에서 변경사항이 반영되도록 xlsx 확장자로 저장하는 게 낫다.)
1. Open file
vi file-name
2. Access via insert mode
i
When you press ESC, then linux will be changed to command mode.
3-1. Save changes and exit
:wq
3-2. Save changes without exit
:w
3-3. Exit without saving
:qa!
4-1. Delete one character
x
4-2. Delete a word
dw
4-3. Delete a line after cursor
d$
4-4. Create an empty file which called in file-name
touch
5. Output result or log
filename > result.txt
6. Check owner, group, and others permission on [r]ead, [w]rite, and e[x]ecution
ls -l (file_name)
7. Modify the file called in file-name. Before executing this command, you might as well check your permission on read, write, and execution.
vi (file-name)
Although you chanage your file's mode via chmod command, it cannot be changed because of parent directory's permission. Therefore, you could check the upper directory's permission.
8. printk is used in kernel mode instead of printf
printk
9. Copy target file
cp <target-file> <target-directory>
10. Clear kernel log
dmesg -C
11. Transfer file or directory of virtualbox(guestOS) to local computer(HostOS)
$scp -r source-path HostOS's username@host_ip:destination-path
e.g., scp -r /hw [email protected]:/Users/JS/Desktop/
12. Log last access time, modified time and last change mode time
stat file-name