My Bash setup and aliases
Last active
November 24, 2024 18:28
-
-
Save ASKabalan/e5430e91b412d045efd2d5173fa1327f to your computer and use it in GitHub Desktop.
Setting up bash files
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
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 --progress --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)' | |
alias nv_reset='sudo rmmod nvidia_uvm && sudo modprobe nvidia_uvm' | |
function ssh-fs() { | |
local folder_name="$1" | |
local remote_path="JZ:/gpfswork/rech/tkc/commun/$folder_name" | |
local local_path="$HOME/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,max_conns=20 | |
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="$HOME/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 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
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 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
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 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
sudo apt install -y apt-transport-https build-essential clang-15 clangd clangd-15 clang-format-15 clang-tidy-15 cmake cuda-drivers-fabricmanager-535 curl ffmpeg fontforge gimp graphviz htop imagemagick libcairo2-dev libc++-dev libpango1.0-dev libreadline-dev libreoffice-java-common libsdl2-dev libspa-0.2-bluetooth libstdc++-12-dev linux-modules-nvidia-535-server-generic-hwe-22.04 make meld net-tools nvidia-driver-535-server nvtop pdfsam-basic pdftk pipewire-audio-client-libraries powertop python3.10-venv python3-dev qtdeclarative5-dev software-properties-gtk solaar thunderbird-locale-en tree xclip zlib1g-dev |
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
# <<< 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 <<< | |
# <<< Init blender >>> | |
export PATH=$HOME/Software/blender/:$PATH | |
# <<< Init CMake >>> | |
export PATH=$HOME/Software/cmake/bin:$PATH | |
# <<< Init Quarto >>> | |
export PATH=$HOME/Software/quarto/bin:$PATH | |
export QUARTO_PYTHON=$HOME/micromamba/envs/ocr/bin/python | |
# <<< Init Zotero >>> | |
export PATH=$HOME/Software/zotero:$PATH | |
# <<< Init kitty >>> | |
export PATH=$HOME/.local/kitty.app/bin:$PATH |
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
# <<< 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 <<< |
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
# Snaps | |
sudo snap install discord firefox slack zoom-client | |
sudo snap install code --classic | |
# Neovim | |
bash <(curl -s https://raw.githubusercontent.com/ASKabalan/nvim-config-2.5/main/setup.sh) | |
# Micromamba | |
"${SHELL}" <(curl -L micro.mamba.pm/install.sh) | |
# apt installs | |
sudo apt install -y tree xclip htop nvtop powertop solaar thunderbird imagemagick meld | |
# compilers | |
sudo apt install -y build-essential clangd-15 clang-format-15 clang-tidy-15 | |
# Imagerie | |
sudo apt install -y libcairo2-dev imagemagick graphviz gimp fontforge | |
# nvidia | |
sudo ubuntu-drivers autoinstall | |
# install cuda | |
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-ubuntu2404.pin | |
sudo mv cuda-ubuntu2404.pin /etc/apt/preferences.d/cuda-repository-pin-600 | |
wget https://developer.download.nvidia.com/compute/cuda/12.6.1/local_installers/cuda-repo-ubuntu2404-12-6-local_12.6.1-560.35.03-1_amd64.deb | |
sudo dpkg -i cuda-repo-ubuntu2404-12-6-local_12.6.1-560.35.03-1_amd64.deb | |
sudo cp /var/cuda-repo-ubuntu2404-12-6-local/cuda-*-keyring.gpg /usr/share/keyrings/ | |
sudo apt-get update | |
sudo apt-get -y install cuda-toolkit-12-6 | |
# Wire plumber | |
sudo apt install -y wireplumber | |
systemctl enable --user pipewire | |
systemctl enable --user wireplumber | |
systemctl start --user pipewire | |
systemctl start --user wireplumber |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment