My Bash setup and aliases
Last active
July 18, 2024 21:45
-
-
Save ASKabalan/e5430e91b412d045efd2d5173fa1327f to your computer and use it in GitHub Desktop.
Setting up bash files
This file contains 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
alias conda='micromamba' | |
alias nvgui='__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia' | |
alias clear-pip='pip freeze | cut -d "@" -f1 | xargs pip uninstall -y' | |
alias yump_prox='ssh -D localhost:9080 -N wassim@apcssh01.in2p3.fr -i ~/.ssh/id_rsa_jz' | |
alias 2prox02='ssh -D localhost:9080 -N wassim@apcssh02.in2p3.fr -i ~/.ssh/id_rsa_jz' | |
alias 3prox03='ssh -D localhost:9080 -N wassim@apcssh03.in2p3.fr -i ~/.ssh/id_rsa_jz' | |
alias jz='firefox -P JZ & yump_prox' | |
alias configure='cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=1' | |
alias mkmk='cmake --build build -j' | |
alias check_bat='upower -i /org/freedesktop/UPower/devices/battery_BAT0' | |
alias cp-jz='rsync -avz --exclude venv --exclude .git --exclude build -e ssh ' | |
alias get-apt='comm -23 <(apt-mark showmanual | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n "s/^Package: //p" | sort -u)' | |
function ssh_tmux() { ssh -t "$1" "tmux a || tmux"; } | |
function ssh-fs() { | |
local folder_name="$1" | |
local remote_path="JZ:/gpfswork/rech/tkc/commun/$folder_name" | |
local local_path="Projects/jean-zay/$folder_name" | |
# Create the local directory if it doesn't exist | |
mkdir -p "$local_path" | |
# Mount the remote directory to the local directory | |
sshfs "$remote_path" "$local_path" -oauto_cache,reconnect | |
if [ $? -eq 0 ]; then | |
echo "Successfully mounted $remote_path to $local_path" | |
else | |
echo "Failed to mount $remote_path to $local_path" | |
fi | |
} | |
function unssh-fs() { | |
local folder_name="$1" | |
local local_path="Projects/jean-zay/$folder_name" | |
# Unmount the local directory | |
fusermount -u "$local_path" | |
if [ $? -eq 0 ]; then | |
# Remove the local directory | |
rm -rf "$local_path" | |
echo "Successfully unmounted and deleted $local_path" | |
else | |
echo "Failed to unmount $local_path" | |
fi | |
} |
This file contains 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
alias py='module load python && conda deactivate' | |
alias pip-get='pip install --user --no-cache-dir' | |
alias clear-pip='pip freeze | cut -d "@" -f1 | xargs pip uninstall -y' | |
alias clear-cache='rm -rf ~/.cache/*' | |
alias size='du -h --max-depth=1 ' | |
alias configure='cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=1' | |
alias mkmk='cmake --build build -j' | |
alias eta-queue='squeue -u $USER --start' | |
alias queue='squeue -u $USER ' | |
alias curr-queue="squeue -p gpu_p13 | rg \"(Priority)|(Resources)\" -c" | |
alias gpus='srun python -c "import jax;jax.distributed.initialize();print(jax.devices())"' | |
alias nv='module load nvidia-compilers/23.9 cuda/12.2.0 cudnn/8.9.7.29-cuda nccl/2.19.3-1-cuda openmpi/4.1.5-cuda cmake' | |
alias a100='export CXXFLAGS="-tp=zen2 -noswitcherror" && export CFLAGS="-tp=zen2 -noswitcherror" && module load cpuarch/amd && nv && source $ALL_CCFRWORK/venv/a100/bin/activate ' | |
alias v100='export CXXFLAGS=-noswitcherror && export CFLAGS=-noswitcherror && nv && source $ALL_CCFRWORK/venv/v100/bin/activate ' | |
alias alloc_v100='salloc --account=glc@v100 -C v100-32g --gres=gpu:4 --ntasks-per-node=4 --time=02:00:00 --cpus-per-task=10 --hint=nomultithread --qos=qos_gpu-dev --nodes=1' | |
alias alloc_a100='salloc --account=glc@a100 -C a100 --gres=gpu:8 --ntasks-per-node=8 --time=02:00:00 --cpus-per-task=8 --hint=nomultithread --qos=qos_gpu-dev --nodes=1' |
This file contains 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
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
# General for all UNIX systels | |
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;33m\]\w\[\033[36m\]$(parse_git_branch)\[\033[01;00m\]\$ ' | |
# Debian and ubuntu | |
if [ "$color_prompt" = yes ]; then | |
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;33m\]\w\[\033[36m\]$(parse_git_branch)\[\033[01;00m\]\$ ' | |
else | |
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' | |
fi | |
unset color_prompt force_color_prompt |
This file contains 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
# <<< texlive initialize <<< | |
export TEXLIVE=$HOME/Software/tex/texlive/2023 | |
export MANPATH=$MANPATH:$TEXLIVE_HOME/texmf-dist/doc/man | |
export INFOPATH=$INFOPATH:$TEXLIVE_HOME/texmf-dist/doc/info | |
export PATH=$PATH:$TEXLIVE_HOME/bin/x86_64-linux | |
# <<< texlive initialize <<< |
This file contains 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
# <<< NVIDIAHPC initialize <<< | |
export CUDA_VERSION=12.2 | |
NVARCH=$(uname -s)_$(uname -m) | |
NVCOMPILERS=/opt/nvidia/hpc_sdk | |
NVHPC_VERSION=24.3 | |
export NVHPC_ROOT=$NVCOMPILERS/$NVARCH/$NVHPC_VERSION | |
export CUDA_HOME=$NVHPC_ROOT/cuda/$CUDA_VERSION | |
export CUDA_PATH=$CUDA_HOME | |
export MATHLIBS=$NVHPC_ROOT/math_libs/$CUDA_VERSION | |
export COMM_LIBS=$NVHPC_ROOT/comm_libs/$CUDA_VERSION | |
# for CUTLASS | |
export CUDA_INSTALL_PATH=$CUDA_HOME | |
export CUDACXX=${CUDA_INSTALL_PATH}/bin/nvcc | |
# To compile JAX and XLA | |
export CUDA_TOOLKIT_PATH=$CUDA_HOME,$MATHLIBS,$COMM_LIBS | |
export TF_CUDA_PATHS=$CUDA_TOOLKIT_PATH | |
# Set LD_LIBRARY_PATH | |
export LD_LIBRARY_PATH=$MATHLIBS/lib64/:$LD_LIBRARY_PATH | |
export LD_LIBRARY_PATH=$NVHPC_ROOT/comm_libs/$CUDA_VERSION/nccl/lib/:$LD_LIBRARY_PATH | |
export LD_LIBRARY_PATH=$NVHPC_ROOT/comm_libs/$CUDA_VERSION/nvshmem/lib/:$LD_LIBRARY_PATH | |
export LD_LIBRARY_PATH=$NVHPC_ROOT/comm_libs/$CUDA_VERSION/openmpi4/latest/lib/:$LD_LIBRARY_PATH | |
export LD_LIBRARY_PATH=$NVHPC_ROOT/comm_libs/$CUDA_VERSION/hpcx/latest/ompi/lib/:$LD_LIBRARY_PATH | |
export LD_LIBRARY_PATH=$CUDA_HOME/extras/CUPTI/lib64::$LD_LIBRARY_PATH | |
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH | |
# Set PATH | |
export PATH=$NVHPC_ROOT/comm_libs/mpi/bin:$PATH | |
export PATH=$NVHPC_ROOT/comm_libs/$CUDA_VERSION/openmpi4/latest/include:$PATH | |
export PATH=$MATHLIBS/include:$PATH | |
export PATH=$NVHPC_ROOT/compilers/bin:$PATH | |
export MANPATH=$MANPATH:$NVHPC_ROOT/compilers/man | |
# Set environment variables for NVIDIA HPC SDK | |
export PATH=$CUDA_HOME/include:$PATH | |
export PATH=$CUDA_HOME/bin:$PATH | |
# Make function that selects the right compiler between nvc gcc and clang | |
function set_compiler() { | |
if [ "$1" == "nvc" ]; then | |
export CC=nvc | |
export CXX=nvc++ | |
export CFLAGS=-noswitcherror | |
elif [ "$1" == "gcc" ]; then | |
export CC=gcc | |
export CXX=g++ | |
export CFLAGS=-fPIC | |
elif [ "$1" == "clang" ]; then | |
export CC=clang | |
export CXX=clang++ | |
export CFLAGS=-fPIC | |
else | |
echo "Invalid compiler" | |
fi | |
} | |
# <<< NVIDIAHPC initialize <<< |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment