Art and science (IX) – Neural networks

This is a continuation of a series of blog posts, written mostly in French, about arts and science

In the past few years, we’ve seen the emergence of Deep Neural Networks (DNN), and the latest developments are Generative Adverserial Networks (GAN), where the goal is to pit two neural networks against each other so that they find the best way to generate an object from a label or a simple drawing, or mimick the style of an artist.

The first ripple in the vast ocean of possibility was Deep Dream, though it wasn’t technically a GAN:

Now, things have evolved even more, and you can not only generate trippy videos, but also use neural network to emulate the style of an artist and generate from scratch content that is indeed appealing!

For instance, there is the Magenta Project at Google where the goal is to use DNN to augment recorded music, and improve the look and feel of computer-generated music (try out Perfomance RNN!) or create and blend melodies that do sound interesting (musicVAE):

Recently, GAN used on video have attracted lots of attention beacause of DeepFake, where the the face of celebrities where merged with bodies of actor on pornographic footage (it seems that nowadays the abuse of good ideas goes at light speed; that’s the drawback of open source.)

Quite interesting are the GAN such as CycleGAN that apply — and/or remove! — the style from an artist, or even allows make a horse look like a zebra in a video.

My attempts at using CycleGAN on some views from Berkeley hills, with ukiyo-e styling, Monet styling, Cezanne styling and Van Gogh styling (with a dash of shame)

(you can try on your own using the instructions listed further in the post)

The latest thing is to not only recreate the style, but also the technique of an artist, but teaching a robot to make brush strokes, such as in the DeepMind SPIRAL work.

I was really excited to learn that there will be many events in the Bay Area on Arts and Science, as part of the After tomorrow project — I hope to see many interesting things there:)

*    *
*

Installing Torch with CUDA and cuDNN on a MacBook Pro

Here are some tricks to install CUDA 9.1 and CuDNN 7.05 to run the graphics card acceleration for Torch 7 on a MacBook Pro (Early 2014, version 11,3) with a nvidia GeForce GT 750M graphics card and Mac OS X 10.13.3 High Sierra (to tell which version you have, you need to go to /Apple menu on the top left of your screen, then enter the “About this Mac menu” and click on system report.) Since this is a fairly old version, I assume that this might be of help to many people with more recent computers, the idea is to show how to jump through all the hoops to use it on High Sierra.

First, you need to update your drivers to at least nVidia GeForce 387.10.10.25.161 (you can go to System Preferences/NVIDIA Driver Manager pane and check for updates, or you can try to get them here)

Then you need to download and install CUDA 9.1 for MacOS X 10.3 64bits.

Next, you will need to download CuDNN 7.0.5 for CUDA 9.1 on MacOS X. To do so, you will probably have to register to NVIDIA developer website. It’s important that you make sure you get the proper version; the one that supports CUDA 9.1; also not the Linux version, and not the latest which right now doesn’t support MacOS X; here’s a direct link to the download if you’re already logged in: CuDNN 7.0.5 for CUDA 9.1 on MacOS X 64bits)

Then, you can follow the instruction listed here, or try something along this line in the terminal, to bring the download files to a place where they belong, and adding a new PATH to your environment:

tar -zxf cudnn-9.1-osx-x64-v7-ga.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib/libcudnn*
export CUDNN_PATH=/usr/local/cuda/lib/libcudnn.7.dylib

Then installation you should be able to install Torch (there’s a guide here to help you.)

Make sure you have the latest XCode Command Line tools (type xcode-select --installin the terminal) , and brew (type /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)").

Basically now what you need to do type this in your terminal (assuming you have git)

git clone https://github.com/torch/distro.git ~/torch --recursive

BEFORE YOUR START THE INSTALL, you will need to modify THCTensorRandom.cuh because it has a small tweak thing prevents it from compiling. You will need to search the file on your computer (mine is located at /Users/awojdyla/torch/extra/cutorch/lib/THC/THCTensorRandom.cuh), and remove the __align__ string at two locations, otherwise your compilator will scream.

There’s also a fix that you might need to apply to make the compilation work:

git clone https://github.com/soumith/cudnn.torch.git -b R7 && cd cudnn.torch && luarocks make cudnn-scm-1.rockspec

Then you can run the following lines and go get a cup of tea with your friends

cd ~/torch; bash install-deps;
./clean
export TORCH_NVCC_FLAGS="-D__CUDA_NO_HALF_OPERATORS__"
./install.sh

finally type
./Users/ [you user name] /torch/install/bin/torch-activate

and you should be able to run Torch (type th in your terminal to see if this works.)

Now you’re ready to use Torch anf cool stuff such as CycleGAN

(it seems there is another helper available here)