[Neural_SDFs tutorial]

Overview

日本語



 This is a technical demonstration of GLSL graphical based on DNN technology.

It is created based on her explanatory video.

 The distance function was calculated using deep learning technology and converted into data.
Since Windiws10 20H2, CUDA has been able to run in ubuntu environment, which makes machine learning very easy.

In this section, we will explain the path from environment setup to SDF data creation.
By applying this technology, you will be able to convert any "waveform", "image", or "3D data" into a distance function.





■preparation■

1.Turn on Virtualization Technology in BIOS.


2.Under "Enable or disable Windows features", check "Hyper-V".
3.Check "Windows Subsystem for Linux" and "Virtual Machine Platform" as well.


4.Update to Windows 10 version 21H2 or later.


5.Make sure your Nvidia drivers are up to date. (GameReady available).
https://www.nvidia.co.jp/Download/index.aspx

-Restart the computer-





■Installation of WSL2■

Install the Linux Kernel Update Package
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

Run Windows Terminal or PowerShell as administrator and execute the following command

Activate Windows Subsubsystem for Linux
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Activate the optional components of the virtual machine platform.
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Set the default version of WSL to 2
wsl --set-default-version 2




■Installing Ubntu■

Open the Microsoft Store and install "Ubuntu 20.04 LTS".


Start a command prompt and check the wsl version.
wsl --set-version Ubuntu-20.04 2
wsl -l -v

-Start ubuntu and decide on a user name and password.-

※If you can't boot ubntu, the virtualization settings have failed, so review them from the BIOS management.



■Setting up CUDA for WSL■

Will Install the necessary programs in ubuntu

Update the kernel.
sudo apt -y update
sudo apt -yV upgrade

Install WSL2 (ubuntu)
wsl --install -d Ubuntu-20.04

Install Docker-CE
curl https://get.docker.com | sh
※On the way, you will get an English message asking if you want to use Docker Desktop because you found WSL, but leave it alone.

Install CUDA Toolkit (casting spells line by line.)
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
curl -s -L https://nvidia.github.io/libnvidia-container/experimental/$distribution/libnvidia-container-experimental.list | sudo tee /etc/apt/sources.list.d/libnvidia-container-experimental.list
sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo service docker start
Check it CUDA for WSL works.
sudo docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark

※If there are no errors, you have succeeded.




■Setup tools■

Continue to install the necessary programs within ubuntu.

Install python
sudo apt -y install build-essential python3-dev python3-pip
Upgrade pip
pip install -U pip
Install pytorch
pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
Install the necessary libraries (run one line at a time)
pip install numpy
pip install pandas
pip install matplotlib
pip install scikit-image
pip3 install mesh-to-sdf
Install GLUT
sudo apt-get install libglu1-mesa-dev mesa-common-dev
Install jupyter-notebook
sudo pip3 install jupyterlab
Install google-chrome(run one line at a time)
sudo wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt install --fix-broken -y




■Installing MobaXterm■

DL and install MobaXterm in order to run ubuntu GUI on windows.
Press Download now for the Free version to install it.
https://mobaxterm.mobatek.net/download.html

When the screen opens, the setup is complete.

※Possible with VcXsrv

Open the ubuntu console by double-clicking on it.
Download the neural_experiments project from Blackle Mori's googleDrive, unzip it, and copy it to your ubuntu folder.
https://drive.google.com/drive/folders/13-ks7iyLyI0vcS38xq1eeFdaMdfNlUC8







■Start the project■

Open two ubumtu consoles and start the program

GUI on the WSL-Ubuntu-20.04 side
sudo service docker start 
google-chrome
On the WSL-Ubuntu side, jupyter-notebook
jupyter-notebook

Paste the URL listed in the jupyter-notebook into the google-chrome URL launched from ubuntu.


The ubuntu folder will appear, click on sdf.ipynb to open it.


You can do this by clicking on the Is[n] part and pressing RUN as explained in the video.


※Note: The line serialize_to_shadertoy(sdf_siren, "f") here must be removed or an error will occur.


If all goes well, you will get the results from here, and you can check them by pasting them into shadertoy.




In the project folder, you will also find sad_cat, a cat image, and a sample distance function that includes colors. This method has a wide range of applications, so you can use it to create distance functions for waveforms, convert 2D images, or process them with post-processing shaders.





Reference:
Microsoft:https://docs.microsoft.com/en-us/windows/wsl/install-win10
Install CUDA on WSL on WSL2:https://ascii.jp/elem/000/004/020/4020410/
CUDA on WSL User Guide https://docs.nvidia.com/cuda/wsl-user-guide/index.html