Skip to content

JunseokLee42/cmds

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 

Repository files navigation

Note

This repo is about a set of commands which might be useful for AI coding.

tmux

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.

  1. Prerequisite
sudo apt-get install tmux
  1. Create a session
tmux new -s <sessions_name>
  1. Print out information on session

Information includes in session name, the number of windows, and current attached session

tmux ls
  1. Enter a session
tmux attach -t <session_name>
  1. 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
  1. Create a new window
ctrl+b -> c

Multi-gpu

  1. Check current storage capacity
df -h
  1. print current working directory
pwd
  1. Check your CUDA version
nvcc -V
  1. Output current directory's capacity
du -sh .
  1. Check all running processes' id and command
nvidia-smi | grep python | awk '{print $5}' | xargs -I{} ps -p {} -o pid,cmd
  1. Print list of currently running prcoesses on background
jobs
  1. Monitor resource usage and running processs
top
  1. Similar to top, but better in terms of visualization
nvtop # recommended
htop

Conda

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

VS Code

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()

zip extension

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

Git

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

pip

1. Itemize installed libraries

pip freeze > requirements.txt

csv, xlsx extension

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 확장자로 저장하는 게 낫다.)

Linux

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.Save

3-1. Save changes and exit

:wq

3-2. Save changes without exit

:w

3-3. Exit without saving

:qa!

4. Delete

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

About

commands which might be useful for coding

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published