当前位置:网站首页>Teaching you to learn Van Gogh's painting from the beginning to the end: GTX 1070 CUDA 8.0 tensorflow GPU version

Teaching you to learn Van Gogh's painting from the beginning to the end: GTX 1070 CUDA 8.0 tensorflow GPU version

2020-12-07 13:01:35 osc_ bgpugm2v

Teach you to use... From the beginning to the end DL Painting with Van Gogh



author : July online development / Three people in the marketing team , Xiao Zhe 、 Li Wei 、July. This tutorial is mainly written by Xiaozhe , Li Wei is in charge of Linux Command part .
Time : September 25, 2016
To configure :GTX 1070 cuda 8.0 Ubuntu 14.04 cudnn 5.1 tensorflow gpu
communication :TensorFlow Actual communication Q Group 472899334, If you have any questions, you can join this group to communicate with each other . Explore the principle behind the experiment , See our deep learning online course : Deep learning online class .





One 、 Preface

    12 This blog was launched SVM Three levels of state ,14 year July The team started working on the machine learning line , So I wrote a series of ML Blog .15 year ,July The team started a business , Get started July online ——  Domestic leading artificial intelligence education platform , Initially covered algorithms 、 machine learning 、 Three focuses of deep learning .16 year , July online from the first half of 5 Courses are extended to the second half of the year 30 A course , The lecturer team also started from the first half of the year 5 People expand to the existing 19 people ( And to arrive 18 In the first half of , The lecturer team has surpassed 60 people ).

    meanwhile , Machine learning is becoming more and more popular , And with the improvement of computer computing ability, deep learning becomes more and more popular . When companies do deep learning courses , Development / Marketing colleagues will also learn along with them , But the experiment has not been done from the beginning to the end of the course .

    Until recently , After our team was fully staffed , I found that I could do some experiments . Why? ? Learn something , After understanding its theory , The most important thing is to put it into practice , Do some experiments , Otherwise, it will always be on paper . We three don't give lectures ( One market one PHP A lot of miscellaneous things ), But it can help the lecturer team to lead more students to do experiments together 、 Let's do it together .

    Passion is surging , be prompted by a sudden impulse .

  • 21 Afternoon of 5 spot , Colleague li 、 Xu began to engage in DL: use DL Painting with Van Gogh . Okay , Is to DL It's not about ML.
  • near 6 A.m. , Start convolution , The process of waiting is like giving birth to a child .
  • evening 8 spot ,CPU It took an hour and a half to make it , And then you start loading cuda, To use GPU A couple of Van Gogh paintings .
  • 0 spot , My colleagues are still pretending , because GTX 1070 Bottling cuda8.0 It's hard work (1070+8.0 The reason why it's hard to pretend , One is that there are few online tutorials , One is 1070 8.0 They're just coming out , especially 1070 At present, you can only use cuda 8.0. Probably 960/970/980 take cuda 7.5 It's going to be so much easier ).
  • Next , The two colleagues went on a night in the dark , Through countless pits .
  • 22 Morning in the morning 6 Half past six ,cuda、TensorFlow Finally, it's compiled , I ..
  • 22 Morning in the morning 8 spot , use DL Painting with Van Gogh ,GTX 1070 cuda 8.0 Ubuntu 14.04 cudnn 5.1 tensorflow gpu, All night , Through countless pits , Two colleagues one PHP A market has finally been settled .( Okay , Some people say ,PHP Is the best language in the world ).

    After we set it up , Happy to post on microblog ( Because the two colleagues have never done DL, You can imagine the excitement of our mood ), Find us 5 month DL A student in the class has set up this configuration before , say :“ loading cuda And the drive took a few days , Black screen often appears ”. There's also feedback from friends :“ It's a real hassle to configure .”、 as well as “ It's really troublesome , I tried to build it myself, and I never succeeded ”. therefore , Many friends ask for a tutorial .

    in fact ,GPU When it's done , Finally run down demo Just a few minutes , Mainly the whole construction process It's a toss . Don't believe it ? You can skip this tutorial , And then build one from the beginning to the end 1070+8.0, No, I haven't 1070+8.0 Don't jump to conclusions before . True words .

    Sum up , This course is hereby launched , It's rare on the Internet 1070+8.0 The most detailed one in the tutorial ( Some of the pictures are taken by Xiao zhe with his mobile phone to the computer ), I hope more people will take less detours . Besides , We are more likely to be in Deep learning course Lead more people to do it with us DL experiment , hang out together .



Two 、 To configure

Our configuration is

  • hardware configuration : core i7-6700+GTX1070+500G Solid state disk +8G Memory + a main board
  • software configuration :Ubuntu14.04 +GTX1070 Driver. +CUDA8.0+cudnn5.1+Tensorflow



3、 ... and 、 download

Considering some students Linux The operation is not very skilled , The following steps are as detailed as possible , So that everyone can play . another , The operating system is newly installed Ubuntu14.04 English desktop version , If a different version is installed or not completely new , The steps can be adjusted accordingly .

3.1、 Ubuntu14.04

http://www.ubuntu.com/download/alternative-downloads( Download address , choice 64 Bit download )

explain :

  1. When we download it ourselves, we download it from the official English page , in writing There seems to be no Ubuntu14.04 Download page .
  2. Ubuntu14.04 It is recommended to use the original English version for version selection ,Kylin( kirin : Specially customized for Chinese users ) Version is not recommended . reason : ha-ha , Foreign monks chant sutras
  3. Ubuntu16.04 After testing, we found that the screen will flash when entering the desktop , Analysis of the reason seems to be with our graphics card is 1070 The version is about ( In fact, as long as GTX1070 Video card driver installed on the line ), and Ubuntu14.04 None of the above . So consider reducing trouble for the masses , When your graphics card is similar to ours (GTX1070\GTX1080), Please refer to this recommendation .

UltraISO A diskette tong :

http://cn.ultraiso.net/xiazai.html( Download address )

explain :

  1. This software is to make you U The disc is made into Ubuntu14.04 The tool to install the disk .
  2. How to use it, please check the relevant instructions of Baidu Library :http://wenku.baidu.com/link?url=XIitpKr9kKSXLLBzhrO7DzCOgGtrqpvxyfnI8tt3ugnt59dEWzMwUAUzMy-mIyY1gDeqaOPkKMB5EwlWYCwWZjaq2CaLiZzWpENTpgk04SG
  3. If the download address link fails , To baidu :UltraISO A diskette tong .
  4. The installation is in Windows Installed below .

3.2、 GTX1070 Driver.

http://www.geforce.cn/drivers( Download address )

explain :

1) Option diagram

2) You can choose according to your computer configuration .

3.3、 CUDA

https://developer.nvidia.com/cuda-toolkit( Download address )

explain :

1) stay NVIDIA Of CUDA Download page , Select which to use CUDA Version to download .

2) Here we use CUDA8.0( The page has a hint GTX1070GTX1080 Support 8.0 edition ), If students do not use the above two versions of GPU, Can download CUDA7.5.DOWNLOAD( download ).

3) Download requires registration .

4) Graphic selection

 

 

3.4、 Cudnn

https://developer.nvidia.com/cudnn( Download address )

explain :

1) To download, you need to fill out a questionnaire , Just three options , It is suggested to fill in carefully , After all, I'm free to use .

2) When you're done, click  I Agree To   The little box at the front , Appear as follows :

    Click on After downloading, there are many choices , Check 3 An option :Images、Image Classification、Tensorflow.


3.5、 Tensorflow

tensorflow github above-mentioned 4 Installation methods , This tutorial USES A fourth Source code installation

  1. Virtualenv installation
  2. Anaconda installation
  3. Docker installation
  4. Installing from sources

https://github.com/tensorflow/tensorflow( Download address )

explain :

1) Open download page , Flip down , Until this position in the picture below :

(2)  Click on Python 2 Start the download .

Last , Save all downloaded files to your own mobile hard disk /U tray , Wait for installation time to use .



Four 、 install

4.1、  install Ubuntu14.04

install Ubuntu14.04

http://jingyan.baidu.com/article/eb9f7b6d8536a8869364e813.html

explain :

1) We directly installed the original English system , English is also the language of choice .

2) The above links are in -- The third step : The installation type is selected as -- Customize . What we chose is -- Clear the entire disk and install , If you have Windows System , You will also be prompted to install Ubuntu14.04 And Windows Coexistence mode . It's your choice , Bear in mind ! This place is carefully chosen .

3) Thanks to Baidu experience uploader !

4.2、  install GTX1070 Video card driver and CUDA8.0

notes : To install the driver, you need to install it in the character interface

step :

1) Get into Ubuntu Interface

2) Insert U disc , Copy the content to Desktop Under the document . be familiar with Ubuntu Classmate , This step can be placed under other folders according to your own habits .

3) Search for Terminal


4)  Drag the command box icon to the left bar or desktop , For use .

5)  Open the command box , Input sudo  –i

Enter the power on password

Input   sudo apt-get install vim

           sudo  vi   /etc/default/grub


6)  At this point, the system will enter a text page . In the 20 There will be GRUB_CMDLINE_LINUX_DEFAULT="quiet". Move the cursor to the front of the command , And then the keyboard hits Esc key , Click again y Key twice , click p key . This command will be copied to the next line . And then click i key , You can edit it , Add... Before the line command # Number , And then move to the copied one , modify quiet by text, Press Esc key .Shift+ Input wq.

 

The command box interface will be called back , Input sudo update-grub2

       Input shutdown  r  now restart

7)  Restart and enter the character interface , Follow the prompts to enter your user name and password


Input sudo  -i

Input password

Input cd  /home/***( This press Tab Key auto matching )/Desktop

Input  ./NVIDIA-LIN( This press Tab Key auto matching )  or  /bin/bash file name

Don't understand the picture below


Press the Enter key and appear

…………………………………………………………………………………………………………………………………………………………………………………………………………………………….

Instructions to start the installation

And then choose Accept Wait for the word "agree"

During this period, when you meet the agreement, you always press Space bar Just go

After the agreement is completed, the prompt is as shown in the figure


Input accept

And agree along the way

8)  install NVIDIA After the end , Operate the same way to install CUDA8.0, One of the places to be noted here is to fill in N Talent , Can't write Y. Pictured


The rest operations are shown in the figure


Then go back and wait

9)  It's like the first time (5) Step execution

Input sudo  vi   /etc/default/grub At this point, the system will enter a text page . In the 20 There will be GRUB_CMDLINE_LINUX_DEFAULT="quiet". Move the cursor to the front of the command , And then the keyboard hits Esc key , Click again y Key twice , click p key . This command will be copied to the next line . And then click i key , You can edit it , Delete before line command # Number , And then move to the copied one , Before the command add to # Number , Press Esc key .Shift+ Input wq.

The command box interface will be called back , Input sudo update-grub

       Input shutdown  r  now restart

4.3、 Cudnn install

cd  /home/***( Own user name )/Desktop/###( This command means to find out what we just used U Files from disk )

tar xvzf cudnn-8.0-linux-x64-v5.1-ga.tgz###( Unzip this file )

sudo cp cuda/include/cudnn.h /usr/local/cuda/include###( Copy )

sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64###( Copy )

sudo chmoda+r/usr/local/cuda/include/cudnn.h/usr/local/cuda/lib64/libcudnn*

 

4.4、  Other dependent installations :

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md

We are in github Of Tensorflow On the official website , Install as prompted , Address above .

Step by step, the screenshot is as follows

sudo apt-get install python-pip python-dev ( This is incomplete , The full version is as follows )

sudo apt-get install python-pip python-dev Python-scipy Pythoy-numpy git

 

 




4.5、 Bazel install

Because this tutorial uses tensorflow Source code compilation / install , So we need to use bazel build.

link :https://www.bazel.io/versions/master/docs/install.html


Automatic jump



And then back to the previous Tensorflow Install the tutorial page :https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md


4.6、 numpy install

http://www.scipy.org/scipylib/download.html


git clone git://github.com/numpy/numpy.git numpy


4.7、 Tensorflow install

Or just the website

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md


./configure

If configure  Failure   Try two commands
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda


bazel build -c opt //tensorflow/tools/pip_package:build_pip_package

bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

sudo pip install /home/***( Your own user name )/Desktop/tensorflow-0.10.0-cp2-none-any.whl


bazel build -c opt //tensorflow/tools/pip_package:build_pip_package

 

# To build with GPU support:

bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

 

mkdir _python_build

cd _python_build

ln -s ../bazel-bin/tensorflow/tools/pip_package/build_pip_package.runfiles/org_tensorflow/* .

ln -s ../tensorflow/tools/pip_package/* .

python setup.py develop

 



5、 ... and 、  test Tensorflow

 



6、 ... and 、 experiment : Imitating Van Gogh's paintings

neural-style download
In this github The website downloads the corresponding code :https://github.com/anishathalye/neural-style


Next , download vgg19
http://www.vlfeat.org/matconvnet/models/beta16/imagenet-vgg-verydeep-19.mat

then , hold vgg Put it in neural-style At the root of the folder

Now? , In the command window cd  /home/***( Your own user name )/Desktop/

   git clone  https://github.com/anishathalye/neural-style.git 

next You can open this folder on your desktop


Put the photo you want to modify into example In the folder , Then, in the window command just now, input :

python   neural_style.py   --content  ./example/***.jpg( Do not copy in this bracket :*** Represents the image name you want to use )   --styles  ./example/ 1-style.jpg( Do not copy in this bracket :1-style.jpg It's the name of Van Gogh's star pictures in the folder , You can also change other styles , Just change the name ) --output  ./example/$$$.jpg( Do not copy in this bracket :$$$ Represents the name of the image you want to generate )

For example, my input is as follows python neural_style.py –content  ./example/1-content.jpg  --styles ./example/1-style.jpg --output ./example/1-output.jpg


Next , It's a time to witness miracles .

After learning the style of Van Gogh's starry sky , Let the computer do the van Gogh processing of the specified picture , As shown in the figure below


I used to use CPU It's going to take an hour and a half to get the results , Now use GPU It's a matter of minutes . It's no waste of effort GPU.



Postscript

    The two colleagues have never done anything before DL experiment , Just a passion 、 Interest in 、 Love doing this experiment , It was a lot of trouble when I just finished , Because a lot of pits haven't mentioned it on the Internet 、 Crossing the river by touching stones in the dark , And all night . But I believe that with this tutorial ,1070+8.0 Then there's no more trouble , Maybe in an hour or two ( because Then we did it three times in an afternoon , Over and over again ). It's easy to move your mouth 、 It's not that easy , But it is the doers who really push the society forward , Not critics .

    This experiment is just the beginning , We develop / The marketing team will also assist the lecturer team to lead more students and friends to do a series of more experiments , such as char-rnn、WaveNet( Using convolutional neural network to simulate human voice ) wait , Even if the experiment is simple, we will do it , because : Learn computer /ML/DL, The first thing is to do it 、 It's an experiment , Otherwise, no matter how much is on paper .

    Create value 、 Helping people . Post two pictures , It's for reading . Finally, explore the principle behind the experiment , Please refer to this course : Deep learning class .


    July online development / The marketing team is smart 、 Li Wei 、July, September 25, 2016 .

版权声明
本文为[osc_ bgpugm2v]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/20201207125003111v.html