# Ubuntu 20.04 for Deep Learning In the name of God This gist contains steps to setup `Ubuntu 20.04` for deep learning. ---------------------------------------------------------------------------------------------------- **Install Ubuntu 20.04**: - Computer name: Name-PC - Name: Name - User name: name - Password: ******** ---------------------------------------------------------------------------------------------------- **Update Ubuntu**: ```sh $ sudo apt update $ sudo apt full-upgrade --yes $ sudo apt autoremove --yes $ sudo apt autoclean --yes $ reboot ``` ---------------------------------------------------------------------------------------------------- **Create Update Script**: - Create a file (`~/full-update.sh`) with the following lines: ```sh #!/bin/bash if [ "$EUID" -ne 0 ] then echo "Error: Please run as root." exit fi clear echo "################################################################################" echo "Updating list of available packages..." echo "--------------------------------------------------------------------------------" apt update echo "################################################################################" echo echo "################################################################################" echo "Upgrading the system by removing/installing/upgrading packages..." echo "--------------------------------------------------------------------------------" apt full-upgrade --yes echo "################################################################################" echo echo "################################################################################" echo "Removing automatically all unused packages..." echo "--------------------------------------------------------------------------------" apt autoremove --yes echo "################################################################################" echo echo "################################################################################" echo "Clearing out the local repository of retrieved package files..." echo "--------------------------------------------------------------------------------" apt autoclean --yes echo "################################################################################" echo ``` ---------------------------------------------------------------------------------------------------- **Change Settings**: - Review Ubuntu Settings ---------------------------------------------------------------------------------------------------- **Change Software & Updates**: - Review Ubuntu Software & Updates ---------------------------------------------------------------------------------------------------- **Update Ubuntu**: - `$ sudo ~/full-update.sh` ---------------------------------------------------------------------------------------------------- **Install Chrome** (https://www.google.com/chrome): - `$ sudo dpkg -i google-chrome-stable_current_amd64.deb` ---------------------------------------------------------------------------------------------------- **Install Development Tools**: - `$ sudo apt install build-essential pkg-config cmake cmake-qt-gui ninja-build valgrind` ---------------------------------------------------------------------------------------------------- **Install MinGW Tools**: ```sh $ sudo apt install mingw-w64 mingw-w64-tools $ sudo apt install binutils-mingw-w64 $ sudo update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-posix $ sudo update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix $ sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix $ sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix ``` ---------------------------------------------------------------------------------------------------- **Install ARM Tools**: ```sh $ sudo apt install crossbuild-essential-armel crossbuild-essential-armhf crossbuild-essential-arm64 $ sudo apt install binutils-multiarch binutils-arm-none-eabi binutils-arm-linux-gnueabi binutils-arm-linux-gnueabihf binutils-aarch64-linux-gnu ``` ---------------------------------------------------------------------------------------------------- **Install Git**: ```sh $ sudo apt install git $ git config --global user.name "Name" $ git config --global user.email "name@domain.com" $ git config --global core.editor "gedit -s" ``` - Copy your own SSH keys to `~/.ssh` ---------------------------------------------------------------------------------------------------- **Install Python 3**: - `$ sudo apt install python3 python3-wheel python3-pip python3-venv python3-dev python3-setuptools` ---------------------------------------------------------------------------------------------------- **Install NVIDIA Drivers for Deep Learning**: - https://www.tensorflow.org/install/gpu - Check Hardware: - `$ sudo lshw -C display` - Install NVIDIA GPU Driver: - Software & Updates > Additional Drivers > NVIDIA - Install CUDA Toolkit (CUDA 11.0): - https://developer.nvidia.com/cuda-toolkit-archive 1. Install prerequisites: - `$ sudo apt install linux-headers-$(uname -r)` 2. Install `cuda_11.0.3_450.51.06_linux.run` (without Driver, use --override if gcc version not supported) 3. Set up the development environment by modifying the PATH and LD_LIBRARY_PATH variables (`~/.bashrc`): - `export PATH=$PATH:/usr/local/cuda-11.0/bin` - `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.0/lib64:/usr/local/cuda-11.0/extras/CUPTI/lib64` 4. Check that GPUs are visible using the command: - `$ nvidia-smi` - Install cuDNN v8.0.5, for CUDA 11.0: - https://developer.nvidia.com/cudnn - https://developer.nvidia.com/rdp/cudnn-archive - `$ sudo dpkg -i libcudnn8_8.0.5.39-1+cuda11.0_amd64.deb` - `$ sudo dpkg -i libcudnn8-dev_8.0.5.39-1+cuda11.0_amd64.deb` - `$ sudo dpkg -i libcudnn8-samples_8.0.5.39-1+cuda11.0_amd64.deb # Optional` - Reboot ---------------------------------------------------------------------------------------------------- **Machine Learning Environment**: ```sh $ python3 -m venv ~/venv/ml $ source ~/venv/ml/bin/activate $ (ml) pip install --upgrade wheel pip $ (ml) pip install --upgrade numpy scipy matplotlib ipython jupyter pandas sympy nose $ (ml) pip install --upgrade scikit-learn scikit-image $ (ml) deactivate ``` ---------------------------------------------------------------------------------------------------- **Deep Learning Environment (CPU)**: - https://www.tensorflow.org/install ```sh $ python3 -m venv ~/venv/dlcpu $ source ~/venv/dlcpu/bin/activate $ (dlcpu) pip install --upgrade wheel pip $ (dlcpu) pip install --upgrade opencv-python opencv-contrib-python $ (dlcpu) pip install --upgrade tensorflow tensorboard keras $ (dlcpu) deactivate ``` ---------------------------------------------------------------------------------------------------- **Deep Learning Environment (GPU)**: - https://www.tensorflow.org/install/gpu ```sh $ python3 -m venv ~/venv/dlgpu $ source ~/venv/dlgpu/bin/activate $ (dlgpu) pip install --upgrade wheel pip $ (dlgpu) pip install --upgrade opencv-python opencv-contrib-python $ (dlgpu) pip install --upgrade tensorflow-gpu tensorboard keras $ (dlgpu) deactivate ``` ---------------------------------------------------------------------------------------------------- **Check GPU Support by Tensorflow**: ```sh $ source ~/venv/dlgpu/bin/activate $ python >>> from tensorflow.python.client import device_lib >>> device_lib.list_local_devices() >>> exit() ``` ---------------------------------------------------------------------------------------------------- **Install Qt**: - https://www.qt.io/ - `$ sudo apt install build-essential libgl1-mesa-dev` - For Android Java 8 required. - `$ sudo apt install openjdk-8-jre openjdk-8-jdk` - Install Android SDK & Android Studio - https://doc.qt.io/qt-6/linux.html ---------------------------------------------------------------------------------------------------- **Install PyCharm**: - https://www.jetbrains.com/pycharm/ ---------------------------------------------------------------------------------------------------- **Enable GPU support for PyCharm Projects**: - Edit Configurations... - Environment variables: - `PATH=$PATH:/usr/local/cuda-11.0/bin` - `LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.0/lib64:/usr/local/cuda-11.0/extras/CUPTI/lib64` ---------------------------------------------------------------------------------------------------- **Install Docker Engine**: - https://docs.docker.com/engine/install/ubuntu/ ---------------------------------------------------------------------------------------------------- **Install Additional Tools**: ```sh $ sudo apt install ubuntu-restricted-extras $ sudo apt install virtualbox virtualbox-dkms virtualbox-ext-pack virtualbox-guest-additions-iso $ sudo apt install curl wget uget unzip tar rar unrar $ sudo apt install gimp $ sudo apt install kdiff3 ``` - Ubuntu Software > System Load Indicator ---------------------------------------------------------------------------------------------------- **Install Additional Fonts**: - `$ mkdir ~/.fonts` - Copy fonts to `~/.fonts`