Note:

Install DeepFace on Ubuntu GPU HPC Instance in Oracle Cloud Infrastructure

Introduction

DeepFace is a software that uses Artificial intelligence (AI) for facial attribute recognition and analysis. This task requires a large processing capacity, in which Graphical Processor Unit (GPUs) are used. DeepFace can be used in several areas, such as: media, arts, education and so on without any threat to security and privacy.

Note: Oracle has no relationship with the DeepFace software. The purpose of this tutorial is to assist in the installation of the software based on successful tests carried out for an Oracle customer in the media sector.

Objective

Install DeepFace

  1. Install Operating System (OS) dependencies.

    $ sudo apt-get install libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6 ffmpeg git libgtk2.0-dev '^ libxcb .\* -dev ' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev xorg gnome
    
  2. Install Miniconda.

    $ rm - rf /home/ ubuntu /miniforge3
    $ mkdir -P ~/miniconda3
    $ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
    $ bash ~/miniconda3/miniconda.sh -B -u -P ~/miniconda3
    $ rm - rf ~/miniconda3/miniconda.sh
    $ ~/miniconda3/bin/conda init bash
    $ ~/miniconda3/bin/conda init zsh
    
  3. Install DeepFace.

    $ conda create -n deepfacelab -c main python=3.9 cudnn cudatoolkit
    $ conda activate deepfacelab
    $ git clone --depth 1 https://github.com/nagadit/DeepFaceLab_Linux.git
    $ cd DeepFaceLab_Linux
    $ git clone --depth 1 https://github.com/iperov/DeepFaceLab.git
    
  4. Navigate to /home/ubuntu/DeepFaceLab_Linux/DeepFaceLab/requirements-cuda.txt and update the requirements-cuda.txt file with the following content.

    tqdm
    numpy
    numexpr
    h5py
    ffmpeg-python
    scikit-image
    scipy
    colorama
    pyqt5
    tf2onnx
    opencv-python-headless==4.5.1.48
    opencv-python==4.5.1.48
    flatbuffers
    pytest
    
  5. Install the necessary packages for DeepFace to work.

    $ pip install --upgrade pip
    $ python -m pip install -r requirements-cuda.txt
    $ pip install tensorflow[and-cuda]
    
  6. Enable GPU support with TensorFlow.

    $ pip install tensorflow-2.15.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
    

    Note: Download Tensorflow from here: Install TensorFlow with pip.

  7. Test the GPU access.

    $ python3 - c "import tensorflow as tf ; print( tf. config.list _physical_devices ('GPU'))"
    
  8. Adjust the NumPy version for the DeepFace code to work correctly.

    $ pip install numpy==1.23
    
  9. Navigate to /home/ubuntu/DeepFaceLab_Linux/scripts/env.sh and edit the env.sh file. Change Python version to 3.9 and delete the line referring to conda activation.

    export DFL_PYTHON="python3.9"
    

    DeepFace is ready to run.

Acknowledgments

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.