One spring evening of 2020, I read an article about the face-depixelizer neural network. After studying, it turned out that this is a kind of frontend for the engine PULSE . Which is based on the StyleGAN neural network (generates faces with random features).

In this tutorial, I’ll walk you through the steps and show how I installed Ubuntu on Windows 10 (WSL), set up the environment for experimenting with PULSE , threw another source photo and got a good result.
Result of restoring the original image to PULSE
Morphing Animation and Video Tutorial - Next.

What is given to us

Face-Depixelizer - front-end for working with PULSE.

PULSE - an engine on the StyleGAN neural network. Its meaning is that it restores images of a person’s face from fuzzy photographs. And by the way, this is scientific work for CFV .

StyleGAN - generative adversarial neural network from NVidia, generates a random face of a non-existent person (in fact it will be funny if such a person already exists).

ITKarma picture
PULSE , finally, about to tell us what the very person who blinked in this photo looks like!

Grab the PULSE

I wondered what was under the hood of PULSE and, in general, how it could be made locally.
For fun, looking through a scientific article diagonally, I began to think about how to start and how to set it all up (despite the fact that I had never set myself a “neural network”).

I started by saying that as soon as possible, until the github fell (if you know what I mean), I switched to the project PULSE . Where the author indicated this installation option: anaconda and python. Those. in any case, platform-specific packages (libraries) are required. I'm mostly a Windows user than Linux. But, anyway, I would like to run without edits and tedious selection of libraries. And without Linux this cannot be done in any way.

Some time ago, a part of IT specialists were holing about Linux in Windows. And I will tell you that, for me - in vain. The thing is comfortable, although still not completed.
WSL - the Windows subsystem for Linux allows developers to run the GNU/Linux environment, including most command-line programs, utilities and applications, directly on Windows without any changes, eliminating from having to use a separate virtual machine.

Those. This is access to the linux command line from Windows. A Linux terminal starts up as easy as cmd. Convenient.

Let's get started

I’ll use the Windows Terminal (from the Windows Store) to work with the terminal here and in the video.

In short

Checking requirements

  • NVidia graphics card with CUDA support (StyleGAN neural network uses CUDA). List of supported video cards here
  • Experimental NVidia drivers with CUDA support in WSL2 (until lagging, playing).
  • Windows 10 version 2004 build 20150 and higher (while it is available in the Windows Insider Program at an early access), with component updates. Where to start and how to install here
  • How to install WSL2 (4.19.121 and later; again, only in early access Windows) to install the linux system.
  • Ubuntu 18.04 for WSL2 from the Windows Store.

Preparing Ubuntu

Checking the performance of CUDA

  1. Download CUDA examples
  2. Compile and run.

Set the environment

download and install anaconda.

Install PULSE

  1. Download from the PULSE github
  2. Editing pulse.yml:

    • Add the channels anaconda, conda-forge
    • Removing specific assembly links
  3. Install the PULSE environment using the edited file
  4. Checking the performance of Pytorch and the CUDA Toolkit in Python.


  1. Using pip, update jupyter notebook to the latest version
  2. Customize the image (in issue they write that PULSE works with a square image of 1024 * 1024 and three RGB channels, i.e. without transparency)
  3. Increase \ decrease the number of steps and error
  4. .
  5. PROFIT!

ITKarma picture

Above is a morphing animation created from intermediate images.

As the saying goes: "it is better to see once than hear a hundred times." The video shows all the steps, starting with updating WSL2 and installing Ubuntu.

And now...

Learn more


Once again I will repeat the requirements (... and after the hundredth editing, for the hundredth time I will recall Fowler):

  • Windows 10 version 2004 build 20150 and higher
  • WSL2 (version 4.19.121 and higher)
  • Ubuntu 18.04 for WSL2 is the distribution itself from the Windows Store. It is installed after all Windows 10 updates Insider including WSL2
  • NVidia Driver WSL is an experimental version of drivers supporting the new version of WSL2. Consent required to participate in the NVidia pilot program. But not every map will do .

OS Preparation

Windows 10

Target : Windows 10 version 2004 build 20150 and higher

Pre-training :

  1. Launch updates
  2. Then, using the CDMY0CDMY application, we check the current version of Windows
  3. If your Windows version is lower than Windows 10 version 2004 build 20150, then you will need to follow the steps below
  4. And if everything is ok, congratulations, you don’t have to join the Windows Insider Program! Feel free to proceed to the next stage!

What are we doing :

  1. Join the Windows Insider Program
  2. Further, in the system settings "Update and Security":
    • Tab “Preliminary Assessment Program” (if the screen is blank, see the “Problem Solving” section below):

      1. Evaluation Options: Early Access
      2. Click "Start."
    • Windows Update Tab:

      1. In the "Advanced", we definitely allow "When updating to receive updates for other Microsoft products" (this is for installing WSL2 4.19.121 and higher)
      2. Updating.

Verification : we start CDMY1CDMY. In the dialog that opens, look at the version.

NVidia Driver CUDA WSL

Purpose : Installing the Latest Version of NVidia Driver CUDA WSL

What are we doing :

  1. We go to the page
  2. If you haven’t registered yet, we reign; agree to participate in the pilot program
  3. Download and install.

Verification : will be at the “CUDA operability check” stage


Target : WSL2 version 4.19.121 and higher

Pre-training :

  1. We update Windows to Windows 10 version 2004 build 20150 and higher, if not updated by the steps above
  2. If, after execution in the terminal:

    wsl --update 
    the contents of the help will be displayed (a la CDMY2CDMY), then you have an old version. Then proceed to the steps below
  3. If a version from 4.19.121 and higher is displayed, then skip this step.

What are we doing :

  1. Run PowerShell with the rights of admin and execute it in sequence:
    • We include the additional component "Windows Subsystem for Linux":

    • Next, turn on the Virtual Machine Platform component:

    • Reboot.
  2. Updating WSL:

    wsl --update 
  3. Next, install the second version of WSL - as default for all future distributions:
    To do this, run PowerShell with the rights admin and execute:

    wsl --set-default-version 2 

Verification : command:

wsl --update 
[after installing the update] will display version 4.19.121 and higher.

Ubuntu 18.04 on WSL2

Target : Ubuntu 18.04 on WSL2

Pre-training : if Ubuntu 18.04 was previously installed on the WSL (I did not check the following branch, but it would be nice if you indicate in the comments who came across if it helped):

  • Checking it in the list:

    wsl --list --all -v 
  • For this distribution, switch the WSL version to ver.2:

    wsl --set-version Distro 2 

    For example:

    wsl --set-version Ubuntu-18.04 2 
  • Reboot.

What are we doing :

  1. Go to the Windows Store
  2. We are looking for Ubuntu 18.04 and installing

Verification : open the terminal, execute:

wsl --list --all -v 


Preparing Ubuntu


  1. Updating Package Indices:

    sudo apt update 
  2. Install cmake (to install dlib):

    sudo apt install cmake 
  3. To unpack zip archives, install, for example, the unzip utility:

    sudo apt install unzip 

Install the CUDA Toolkit

  1. Add CUDA to the package index:

    sudo apt-key adv --fetch-keys sudo sh -c 'echo "deb" >/etc/apt/sources.list.d/cuda.list' sudo apt update 
  2. Installing the CUDA Toolkit:

    sudo apt install -y cuda-toolkit-11-0 

Checking the performance of the CUDA Toolkit

To do this, run the examples (deviceQuery is informative):

  1. Download:

  2. Unzip:

  3. We pass and build (all):

  4. Run:


    The application will list compatible devices.

Install Anaconda

  1. Download the distribution by the link
  2. Run:


    During installation:

    1. We agree to the license
    2. Leaving PREFIX
    3. Agree to initialize
  3. We restart the terminal, or we execute:

    source ~/.bashrc 

Setting up the environment in the anaconda

Configuring PULSE

  1. Download:

  2. Unzip:

  3. Creating a backup pulse.yml:

    cp pulse.yml pulse.yml.bak 
  4. Fixim pulse.yml:

    1. Adding channels (these are package sources):
      • conda-forge
      • anaconda
    2. We remove all references to a specific version of the package.
      Example : from the line "CDMY4CDMY" we remove the last part, starting with the equal sign: "CDMY5CDMY". As a result, we get "CDMY6CDMY".

      We do this either by hand or through the sed utility:

      sed '/==/b; s/=\([^=]*\)$//' pulse.yml > pulse1.yml 

      Note : the first part means, they say, if we see "==", then we jump to the end of the regexp script
  5. Create an environment using the CDMY7CDMY file:

    conda env create -f pulse1.yml 
  6. It may be that the version of some file was not found CDMY8CDMY. For example, take CDMY9CDMY:

    1. Google conda libfortran
    2. In Anaconda Cloud in Files we see this very version ( 3.0.1 ), but, unfortunately, it is for osx -64
    3. We continue to search the Anaconda Cloud, we see in the cloud-forge channel only the previous version 3.0.0-1 for linux-64 . Fits!
    4. Replace in the file pulse1.yml CDMY10CDMY with CDMY11CDMY
    5. Once again we execute:

      conda env create -f pulse1.yml 
    6. If installation went well!
    7. If other packages are required, be sure to pay attention to the channels, add as necessary.
  7. We are waiting for it to be installed
  8. Then activate:

    conda activate pulse 

Checking the health of Pytorch and CUDA in python

  1. This script:

    from __future__ import print_function import torch x=torch.rand(5, 3) print(x) 

    Should output something like this:

    tensor([[0.3380, 0.3845, 0.3217], [0.8337, 0.9050, 0.2650], [0.2979, 0.7141, 0.9069], [0.1449, 0.1132, 0.1375], [0.4675, 0.3947, 0.1426]]) 
  2. And this one:

    import torch torch.cuda.is_available() 



At this stage, in theory, you can stop. But I went further and installed jupyter notebook for experiments.
Jupyter Notebook is an incredibly powerful tool for interactively developing and presenting data science projects.

Working with PULSE

Let's get started

  1. Activate the pulse environment:

    conda activate pulse 
  2. Installing Jupiter:

    pip install jupyter 
  3. Run:

    jupyter notebook 
    And then:
    1. Create a new notebook New- > Python3 (notebook)
    2. Paste the code from the file
    3. We throw the source file in the project root, renaming it source.png:

      cp/mnt/c/Users/ПОЛЬЗОВАТЕЛЬ/Desktop/face1.png source.png 
    4. We start. Waiting for


  1. It is very likely that you will need to change the number of steps to 500-800, as well as change eps
  2. Image must be:
    1. Square, they say, is better than 1024 * 1024
    2. PNG
    3. With three channels (RGB) and not with four RGBA
  3. If an error occurs: "CDMY12CDMY", consider the following:

    It is necessary to change steps and \ or eps so that upon reaching the number of steps, eps is at least L2. Below is an explanation.

    The result is accompanied by a conclusion of the achieved parameters:

    BEST (400) | L2: 0.0013 GEOGROSS: | TOTAL: | time:... 

    Where 400 is the (set) achieved number of steps (steps), L2 is the value of interest, it should be less than the given eps (as I understand it, this is the accuracy of optimization ; Comrade AI-developers, tell me what it is?).

    So, for example, it is necessary to increase something one or all together: steps (put more than 400) and \ or eps (put eps=0,0013 and more, i.e. it should be so that eps >=L2).
  4. If you want to see intermediate photos for each step, add the CDMY13CDMY parameter
    Images are saved in the CDMY14CDMY folder: in the CDMY15CDMY folder - high resolution, in the CDMY16CDMY folder - low resolution)

Possible problems are below.

Problem Solving

If you not only encountered errors, but also solved them, write, I will add it here.

White screen in the Windows Insider Program

Option : you are under a different user, not enough privileges.
Solution : see the link .But I decided without registry changes.

CUDA samples do not start

Options :

  1. Your video card is not supported
  2. You have not rolled the latest version of WSL2
  3. You have not installed the latest (experimental) version of NVidia Driver CUDA WSL drivers

When starting CDMY17CDMY throws an error

Error : CDMY18CDMY
Solution : copy the connection string to the browser (did not understand other solutions).

When PULSE starts, an error constantly falls out

Error : CDMY19CDMY
Solution : copy the source file and throw it at me to the root - to the cache folder (create if it is not).


  1. Download the file using the first google link from
  2. Rename it according to the template md5hash, where md5hash is the md5 hash of the downloaded file (in the current version it is CDMY20CDMY)
  3. We throw in the cache folder (we create if it is not in the root of the directory where PULSE is)

When starting PULSE or checking Pytorch, it throws an error

Error : CDMY21CDMY
Solution : if you checked pytorch and it works, it means that you did not activate the pulse environment. To do this, run the following command:

conda activate pulse 


The next step would be to study StyleGAN and other “neural networks” based on it.
I would be glad to read your feedback on the article, recommendations (including on the statement, as this is my first public article), amendments.

Thank you all for reading!

References and links to utilities, drivers

  1. Installation instructions for NVidia Driver for CUDA on WSL
  2. NVidia drivers for CUDA under WSL
  3. List of supported CUDA video cards
  4. CUDA examples
  5. Installation instructions for WSL2 on Windows 10
  6. Windows Help and Introduction Insider Program - Early Access to Windows Versions
  7. Instructions for installing Anaconda on a Linux system
  8. List of Anaconda distributions
  9. Jupyter Notbook - Analytics and Experiments
  10. PULSE repository
  11. Face-Depixelizer Repository
  12. StyleGAN repository