Skip to content
yxKryptonitePublic

About

some steps to setup zsh and conda environment on a new machine

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 

Repository files navigation

Intro

This repo records some steps to initialize my faviorate work environment (including oh-my-zsh, conda, pytorch) on a new Ubuntu machine.

Commonly used commands

df -h          # see the memory usage of each disk
du -d 1 -h     # see the memory usage of a folder

Clash

quick links: Tutorial, clash

# download
unzip Clash.zip    # online link is not supported anymore. Use our zip file.
wget -O config.yaml [代理商提供的订阅链接]    # your vpn config

# run
cd Clash
./clash -d .

# Open another terminal and set proxy for the system. Add into ~/.bashrc or ~/.zshrc to make it permanent.
export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7891

# cancel proxy
unset https_proxy
unset http_proxy
unset all_proxy

Zsh

quick-links: oh-my-zsh, zsh-autosuggestions, zsh-syntax-highlighting

  1. Install
# install oh-my-zsh. Need Clash!
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

To use zsh as the default one, add the following two lines to ~/.bash_profile (or ~/.bashrc) and reconnect the server.

export SHELL=`which zsh`
[ -z "$ZSH_VERSION" ] && exec "$SHELL" -l
  1. Install useful plugins:
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

And set the following lines in ~/.zshrc:

plugins=(
    git
    zsh-autosuggestions
    zsh-syntax-highlighting
)
  1. Change theme to powerlevel10k
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

Then open ~/.zshrc, find the line that sets ZSH_THEME, and change its value to "powerlevel10k/powerlevel10k".

  1. Use source ~/.zshrc to make the changes effective.

Conda

quick-links: miniconda, Anaconda

# Download Miniconda (Linux, python 3.8)
wget https://repo.anaconda.com/miniconda/Miniconda3-py38_4.12.0-Linux-x86_64.sh
# Install 
sh Miniconda3-py38_4.12.0-Linux-x86_64.sh
# Refresh .zshrc
source ~/.zshrc

To create and remove environments,

# create new envs
conda create -n ${ENV_NAME}

# remove envs
conda remove -n ${ENV_NAME} --all

Tsinghua Mirror

Quick-links: pip

# pip 
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

# conda 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --set show_channel_urls yes

# remove conda channels
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

CUDA Toolkit 11.8

Recommend this blog.

pytorch

quick-links: pytorch

Personal preference: 2.0.1+cu118

NOTE: If you are using Tsinghua Mirror through pip to install pytorch, the default version of torch is CUDA10.2. It may have problem to run on machine with CUDA 11.0+ !

NOTE: If you are using Tsinghua Mirror through conda to install pytorch, remove '-c pytorch'. (But it may fail to find the suitable version)

Recommended way:

  1. Use Clash and move to pytorch_all_versions and choose the suitable link to run.

Another possible way:

  1. Choose suitable version and download .whl file from here

  2. Directly install from .whl file

# stable version 1.9.1+cu111 (Linux, python 3.8)
wget https://download.pytorch.org/whl/cu111/torch-1.9.1%2Bcu111-cp38-cp38-linux_x86_64.whl

# install from .whl file
pip install torch-1.9.1+cu111-cp38-cp38-linux_x86_64.whl

Git

To connect to github, first run

ssh-keygen

to generate keys. Then put the public key (.ssh/id_rsa.pub) to -> Settings -> SSH and GPG keys

Then, write the following lines to ~/.ssh/config

Host github.com
    Hostname ssh.github.com
    Port 443
    User git

Now you can pull codes. To push codes, you also need

git config --global user.email {$YOUR_EMAIL}
git config --global user.name {$YOUR_NAME}

About

some steps to setup zsh and conda environment on a new machine

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors