Table of contents
- Install Ubuntu 20.04
- Configure Input Method
- Install Chrome
- Install PyCharm
- Install Git
- Install Anaconda
- Install CUDA (optional)
- Install GPU-driver
- Install Pytorch/TensorFlow
- Configure PyCharm
- Install TeamViewer (optional)
This post documents how I configure a brand new computer into a work station that could be used for deep learning. It was first posted on the ZhiHu in Chinese, which is no longer updated. This page is maintained by me to be up-to-date.
Lastest Update: 27 April 2022.
Requirement: A 4GB or larger USB stick/flash drive
- Don’t use dual boot, i.e., install two operating systems (e.g., Ubuntu and Windows) in your computer.
- Install system on SSD drive if possible.
- “Erase disk and install Ubuntu” is good unless you are famialr with disk partition. Make sure that important data in the disk have been backed up.
computer's nameshort to have a nice prefix in the terminal:
- If you accidently configured some wrong/unwanted settings, reinstallation could be one of the simplest solution.
- Do not waste time on trying to install Windows apps on Ubuntu.
- Install the version of English.
Got BIOS problems?**F12 not working?** 1. *"F12 is the most common key for bringing up your system’s boot menu, but Escape, F2 and F10 are common alternatives."* 2. *"If you’re unsure, look for a brief message when your system starts – this will often inform you of which key to press to bring up the boot menu."* 3. If there is not brief message guiding you to press which key to get into the system’s boot menu (BIOS), Google the BIOS key of your motherboard. 4. If pressing the right BIOS key (repeatedly/and holding) is still not working, it's probably because the Fast Boot is enable on your computer, which will skip the BIOS access. Google how to disable the Fast Boot for your motherboard. **Cannot boot from USB in BIOS?** Different motherboards have BIOS of different styles. Find and get into the setting of `Boot Menu`, and there should be the name of your USB flash in the list. Select your USB and continue the booting.
Take the configuration of input source of Chinese as an example.
Settings --> Region&Language --> Manage Installed Language --> Install/Remove Language --> check "Chinese" --> Apply
- Open a terminal and run
Settings --> Region&Language --> "+" Input Sources --> Chinese (Intelligent Pinyin) --> Add:
- Configuration completed. Now you can use the shortcut
Super + Spaceto switch between the input sources. The status is shown in the right-up corner：
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb sudo dpkg -i google-chrome-stable_current_amd64.deb
Search Pycharm in
Software and install the one you like:
I installed pro because I have free license of student.
External reading: Ubuntu Software vs Software
sudo apt install git
Here we install the miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh sh Miniconda3-latest-Linux-x86_64.sh sudo rm Miniconda3-latest-Linux-x86_64.sh conda update -n base -c defaults conda # restart the terminal before run this line
Nowadays, you don NOT have to install cuda-toolkit or cuDNN because they will come with the installation of pytorch/tensorflow using conda. Therefore, you only need to install a NVIDIA driver. Skip this section if you don’t need cuda.
If you do have to install CUDA, since the software is being updated frequently, here I provide some websites for reference: Compatibility check:
After the confirmation of the CUDA version to install, go to the CUDA archive website and follow the instruction to install the CUDA. Below is an example:
- I suggest using the network installation because it always follows the latest guidance from the NVIDIA.
- Instead of running
sudo apt-get -y install cuda, it’s suggested to first running
sudo apt-cache search cudato get list of available version of CUDA, and then run
sudo apt-get install cuda-12.1(for example) to install the specific version.
- It happens that the command
sudo apt-cache search cudadoes NOT show the wantted version if you are looking for a older version of CUDA, e.g., CUDA-10.2. In this case, you are suggested to install CUDA in via
runfile (local)in the above figure, to download a CUDA-10.2 installer on you computer and then excute it.
Verify the installation of CUDA:
export PATH=$PATH:/usr/local/cuda/bin nvcc -V
Nowadays, you don NOT have to install cuda-toolkit or cuDNN because they will come with the installation of pytorch/tensorflow using conda. Therefore, you only need to install a NVIDIA driver. Check the compatibility of GPU-Driver (optional).
The below commands are dangerous
### remove all cuda/nvidia related softwares, be very careful. # sudo rm /etc/apt/sources.list.d/cuda* # sudo apt-get --purge remove "*cublas*" "cuda*" "nsight*" # sudo apt-get --purge remove "*nvidia*" # sudo apt-get autoremove # sudo apt-get autoclean # sudo rm -rf /usr/local/cuda*
sudo add-apt-repository ppa:graphics-drivers sudo apt update ubuntu-drivers devices # list all effetive drivers # sudo apt list nvidia-driver* # (alternative) list all effective drivers
Output (1080ti, 27 April 2022):
Choose one appropriate version, install it:
sudo apt install nvidia-driver-510
Reboot and check the installation:
Note that the
CUDA Version: 11.6 in the above picture does NOT mean that a CUDA is installed.
Follow the official installation tutorials of Pytorch and Tensorflow. Alternatively, you may run the following given commands to install pytorch/tensorflow in a new conda env (cuda and cuDNN are all installed automatically).
conda create -n pyt # replace 'pyt' with name you like conda activate pyt conda install pytorch torchvision torchaudio -c pytorch conda list
conda create -n tf-gpu conda activate tf-gpu conda install tensorflow-gpu conda list
Noted that you can specify version that you want, e.g.,
tensorflow-gpu=2.4.1 cudatoolkit=10.1 and
- Conda virtual enviroment is flexible and simple to use. It can install cuda-toolkit and cuDNN easily. We can configure multiple envs with different versions of cuda/pytorch/tensorflow and switch among them quickly.
- If you have installed a global cuda in the system, and a different version of the cuda-toolkit in the virtual env, you then might encounter the error of version conflict. You can install pytorch/tensorflow solely by using
pip install(instead of
conda install). In this case, your virtual env will use the cuda installed in the system.
To use the created conda virtual in Pycharm, you need to configure it as the
Python Interpreter of your project. Open the
File --> Settings --> Project --> Python Interpreter：
Click the gear icon at the right-up corner, chose ‘Add’:
Conda Enviroment --> Exsiting enviroment, then configure the executable python path of your conda env:
The executable python path will be automatically detected by the Pycharm. In case not, it normally locates at
Control your computer remotely:
wget https://download.teamviewer.com/download/linux/teamviewer_amd64.deb sudo apt install -y ./teamviewer_amd64.deb sudo rm teamviewer_amd64.deb
TeamViewer didn’t restart with the system even after I checked the box
Extras --> Options --> Start TeamViewer with system. The solution I found:
sudo systemctl start teamviewerd.service sudo systemctl enable teamviewerd.service