This repo records some steps to initialize my faviorate work environment (including oh-my-zsh, conda, pytorch) on a new Ubuntu machine.
df -h # see the memory usage of each disk
du -d 1 -h # see the memory usage of a folder
# 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
quick-links: oh-my-zsh, zsh-autosuggestions, zsh-syntax-highlighting
- Install
# install oh-my-zsh. Need Clash!
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
# install zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
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
- 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
)
- Change theme
Recommend powerlevel10k.
- Use
source ~/.zshrc
to make the changes effective.
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}
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/
Recommend this blog.
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:
- Use Clash and move to pytorch_all_versions and choose the suitable link to run.
Another possible way:
-
Choose suitable version and download .whl file from here
-
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
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}