From ccf61e1972940fe6b51abc7289f51a915027a654 Mon Sep 17 00:00:00 2001 From: "Bofu Chen (bafu)" Date: Wed, 20 Jan 2016 16:52:56 +0800 Subject: [PATCH 1/7] Add installation steps in INSTALL.md. --- INSTALL.md | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 INSTALL.md diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..bb276f2 --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,126 @@ +# Overview + +Neural Artistic Style relies on these dependencies: + + * [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads) + * [cuDNN](https://developer.nvidia.com/cudnn) v3 + * [DeepPy](http://github.com/andersbll/deeppy), Deep learning in Python. + * [CUDArray](http://github.com/andersbll/cudarray), CUDA-accelerated NumPy. + * [Pretrained VGG 19 model](http://www.vlfeat.org/matconvnet/pretrained), choose *imagenet-vgg-verydeep-19*. + +The detailed installation steps are explained in the sections below. + +Note: This installation in mainly for GNU/Linux distributions. + +# Neural Artistic Style + +1. Download Neural Artistic Style: + + $ git clone + +# CUDA + +Please refer to the [Installation Guides](http://docs.nvidia.com/cuda/index.html#installation-guides) provided by nVidia. + +The CUDA toolkit should be installed at `/usr/local/cuda/`. + +# cuDNN + +1. Download [cuDNN](https://developer.nvidia.com/cudnn) v3. +1. Extract the tarball file to the CUDA directory: + + $ sudo tar xzf cudnn-7.0-linux-x64-v3.0-prod.tgz -C /usr/loca/cuda + +The tarball file consists of libcudnn static and shared object libraries, and +the library header. + +# CUDArray + +1. Download CUDArray: + + $ git clone https://github.com/andersbll/cudarray.git + +1. Build CUDArray: + +Before building CUDArray, please make sure Cython>=0.21 has been installed. If +not, you can install Cython via Pip: + + $ pip install --user --upgrade cython + +Start to build: + + # Install shared object library + $ make + $ sudo make install # install into /usr/local/lib by default + $ echo "export LD_LIBRARY_PATH=\"/usr/local/lib:$LD_LIBRARY_PATH\"" >> $HOME/.bashrc + $ source $HOME/.bashrc + + # Install Python modules + $ sudo python setup.py install + +If you get the error messages when executing `make`, that means you might be +using cuDNN v4 instead of v3 (Issue #36): + + src/nnet/cudnn.cpp:206:5: error: cannot convert ‘const float*’ to ‘cudnnConvolutionBwdFilterAlgo_t’ for argument ‘8’ to ‘cudnnStatus_t cudnnConvolutionBackwardFilter(cudnnHandle_t, const void*, cudnnTensorDescriptor_t, const void*, cudnnTensorDescriptor_t, const void*, cudnnConvolutionDescriptor_t, cudnnConvolutionBwdFilterAlgo_t, void*, size_t, const void*, cudnnFilterDescriptor_t, void*)’ + )); + ^ + ./include/cudarray/nnet/cudnn.hpp:85:44: note: in definition of macro ‘CUDNN_CHECK’ + #define CUDNN_CHECK(status) { cudnn_check((status), __FILE__, __LINE__); } + + compilation terminated due to -Wfatal-errors. + make: *** [src/nnet/cudnn.o] Error 1 + +https://github.com/andersbll/cudarray/issues/36 + +# DeepPy + +1. Download DeepPy: + + $ git clone https://github.com/andersbll/deeppy.git + +1. Copy the `deeppy` module direcotry into the Neural Artistic Style directory: + + $ cp -a deeppy/deeppy neural_artistic_style + +# Pretrained VGG 19 Model + +1. Download the pretrained VGG 19 model: + + $ cd neural_artistic_style + $ wget http://www.vlfeat.org/matconvnet/models/imagenet-vgg-verydeep-19.mat + +The model size is around 510 MB. + +# Troubleshooting + +## Out of Memory Issue + +If you get the out of memory error messages when executing +neural_artistic_style.py (Issue #26): + + Traceback (most recent call last): + File "neural_artistic_style.py", line 138, in + run() + File "neural_artistic_style.py", line 130, in run + cost = np.mean(net.update()) + File "neural_artistic_style/style_network.py", line 130, in update + next_x = layer.fprop(next_x) + File "neural_artistic_style/deeppy/feedforward/convnet_layers.py", line 71, in fprop + poolout = self.pool_op.fprop(x) + File "/usr/local/lib/python2.7/dist-packages/cudarray-0.1.dev-py2.7-linux-x86_64.egg/cudarray/nnet/pool.py", line 34, in fprop + poolout = ca.empty(poolout_shape, dtype=imgs.dtype) + File "/usr/local/lib/python2.7/dist-packages/cudarray-0.1.dev-py2.7-linux-x86_64.egg/cudarray/cudarray.py", line 246, in empty + return ndarray(shape, dtype=dtype) + File "/usr/local/lib/python2.7/dist-packages/cudarray-0.1.dev-py2.7-linux-x86_64.egg/cudarray/cudarray.py", line 36, in __init__ + self._data = ArrayData(self.size, dtype, np_data) + File "cudarray/wrap/array_data.pyx", line 16, in cudarray.wrap.array_data.ArrayData.__init__ (./cudarray/wrap/array_data.cpp:1401) + File "cudarray/wrap/cudart.pyx", line 12, in cudarray.wrap.cudart.cudaCheck (./cudarray/wrap/cudart.cpp:763) + ValueError: out of memory + +Here are some solutions: + + 1. Use GPU with larger memory. + 1. Use smaller input and style images. + 1. Use CPU instead of GPU. Set CUDARRAY_BACKEND to 'numpy' as workaround. + +https://github.com/andersbll/neural_artistic_style/issues/26 From 2239a22d46b95f06e123163bea32f2f1f27d4e87 Mon Sep 17 00:00:00 2001 From: "Bofu Chen (bafu)" Date: Wed, 20 Jan 2016 17:07:14 +0800 Subject: [PATCH 2/7] Update code format in INSTALL.md to fenced code blocks. --- INSTALL.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index bb276f2..3b78a8e 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -16,7 +16,9 @@ Note: This installation in mainly for GNU/Linux distributions. 1. Download Neural Artistic Style: - $ git clone + ``` + $ git clone https://github.com/andersbll/neural_artistic_style.git + ``` # CUDA @@ -29,7 +31,9 @@ The CUDA toolkit should be installed at `/usr/local/cuda/`. 1. Download [cuDNN](https://developer.nvidia.com/cudnn) v3. 1. Extract the tarball file to the CUDA directory: + ``` $ sudo tar xzf cudnn-7.0-linux-x64-v3.0-prod.tgz -C /usr/loca/cuda + ``` The tarball file consists of libcudnn static and shared object libraries, and the library header. @@ -38,17 +42,22 @@ the library header. 1. Download CUDArray: + ``` $ git clone https://github.com/andersbll/cudarray.git + ``` 1. Build CUDArray: Before building CUDArray, please make sure Cython>=0.21 has been installed. If not, you can install Cython via Pip: + ``` $ pip install --user --upgrade cython + ``` Start to build: + ``` # Install shared object library $ make $ sudo make install # install into /usr/local/lib by default @@ -57,10 +66,12 @@ Start to build: # Install Python modules $ sudo python setup.py install + ``` If you get the error messages when executing `make`, that means you might be using cuDNN v4 instead of v3 (Issue #36): + ``` src/nnet/cudnn.cpp:206:5: error: cannot convert ‘const float*’ to ‘cudnnConvolutionBwdFilterAlgo_t’ for argument ‘8’ to ‘cudnnStatus_t cudnnConvolutionBackwardFilter(cudnnHandle_t, const void*, cudnnTensorDescriptor_t, const void*, cudnnTensorDescriptor_t, const void*, cudnnConvolutionDescriptor_t, cudnnConvolutionBwdFilterAlgo_t, void*, size_t, const void*, cudnnFilterDescriptor_t, void*)’ )); ^ @@ -69,6 +80,7 @@ using cuDNN v4 instead of v3 (Issue #36): compilation terminated due to -Wfatal-errors. make: *** [src/nnet/cudnn.o] Error 1 + ``` https://github.com/andersbll/cudarray/issues/36 @@ -76,18 +88,24 @@ https://github.com/andersbll/cudarray/issues/36 1. Download DeepPy: + ``` $ git clone https://github.com/andersbll/deeppy.git + ``` 1. Copy the `deeppy` module direcotry into the Neural Artistic Style directory: + ``` $ cp -a deeppy/deeppy neural_artistic_style + ``` # Pretrained VGG 19 Model 1. Download the pretrained VGG 19 model: + ``` $ cd neural_artistic_style $ wget http://www.vlfeat.org/matconvnet/models/imagenet-vgg-verydeep-19.mat + ``` The model size is around 510 MB. @@ -98,6 +116,7 @@ The model size is around 510 MB. If you get the out of memory error messages when executing neural_artistic_style.py (Issue #26): + ``` Traceback (most recent call last): File "neural_artistic_style.py", line 138, in run() @@ -116,6 +135,7 @@ neural_artistic_style.py (Issue #26): File "cudarray/wrap/array_data.pyx", line 16, in cudarray.wrap.array_data.ArrayData.__init__ (./cudarray/wrap/array_data.cpp:1401) File "cudarray/wrap/cudart.pyx", line 12, in cudarray.wrap.cudart.cudaCheck (./cudarray/wrap/cudart.cpp:763) ValueError: out of memory + ``` Here are some solutions: From e50b58917bd0efe54c667653beda5596ee1aee24 Mon Sep 17 00:00:00 2001 From: "Bofu Chen (bafu)" Date: Wed, 20 Jan 2016 17:15:48 +0800 Subject: [PATCH 3/7] * INSTALL.md - Add proper indents in contexts of lists. --- INSTALL.md | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 3b78a8e..17369de 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -35,8 +35,8 @@ The CUDA toolkit should be installed at `/usr/local/cuda/`. $ sudo tar xzf cudnn-7.0-linux-x64-v3.0-prod.tgz -C /usr/loca/cuda ``` -The tarball file consists of libcudnn static and shared object libraries, and -the library header. + The tarball file consists of libcudnn static and shared object libraries, and + the library header. # CUDArray @@ -48,14 +48,14 @@ the library header. 1. Build CUDArray: -Before building CUDArray, please make sure Cython>=0.21 has been installed. If -not, you can install Cython via Pip: + Before building CUDArray, please make sure Cython>=0.21 has been installed. If + not, you can install Cython via Pip: ``` $ pip install --user --upgrade cython ``` -Start to build: + Start to build: ``` # Install shared object library @@ -68,8 +68,8 @@ Start to build: $ sudo python setup.py install ``` -If you get the error messages when executing `make`, that means you might be -using cuDNN v4 instead of v3 (Issue #36): + If you get the error messages when executing `make`, that means you might be + using cuDNN v4 instead of v3 (Issue #36): ``` src/nnet/cudnn.cpp:206:5: error: cannot convert ‘const float*’ to ‘cudnnConvolutionBwdFilterAlgo_t’ for argument ‘8’ to ‘cudnnStatus_t cudnnConvolutionBackwardFilter(cudnnHandle_t, const void*, cudnnTensorDescriptor_t, const void*, cudnnTensorDescriptor_t, const void*, cudnnConvolutionDescriptor_t, cudnnConvolutionBwdFilterAlgo_t, void*, size_t, const void*, cudnnFilterDescriptor_t, void*)’ @@ -81,8 +81,6 @@ using cuDNN v4 instead of v3 (Issue #36): compilation terminated due to -Wfatal-errors. make: *** [src/nnet/cudnn.o] Error 1 ``` - -https://github.com/andersbll/cudarray/issues/36 # DeepPy @@ -142,5 +140,3 @@ Here are some solutions: 1. Use GPU with larger memory. 1. Use smaller input and style images. 1. Use CPU instead of GPU. Set CUDARRAY_BACKEND to 'numpy' as workaround. - -https://github.com/andersbll/neural_artistic_style/issues/26 From 949e9981b982980d01c5e2108eb6a6635a67dc40 Mon Sep 17 00:00:00 2001 From: "Bofu Chen (bafu)" Date: Wed, 20 Jan 2016 17:17:51 +0800 Subject: [PATCH 4/7] * INSTALL.md - Tiny format improvement. --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 17369de..ab1fcb7 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -139,4 +139,4 @@ Here are some solutions: 1. Use GPU with larger memory. 1. Use smaller input and style images. - 1. Use CPU instead of GPU. Set CUDARRAY_BACKEND to 'numpy' as workaround. + 1. Use CPU instead of GPU. Set `CUDARRAY_BACKEND` to 'numpy' as workaround. From 5fbb0013ff073b9e987323ec19422053d35c74f8 Mon Sep 17 00:00:00 2001 From: "Bofu Chen (bafu)" Date: Wed, 20 Jan 2016 17:20:42 +0800 Subject: [PATCH 5/7] * INSTALL.md - Correct LD_LIBRARY_PATH info in .bashrc for CUDArray. --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index ab1fcb7..ab143f9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -61,7 +61,7 @@ The CUDA toolkit should be installed at `/usr/local/cuda/`. # Install shared object library $ make $ sudo make install # install into /usr/local/lib by default - $ echo "export LD_LIBRARY_PATH=\"/usr/local/lib:$LD_LIBRARY_PATH\"" >> $HOME/.bashrc + $ echo "export LD_LIBRARY_PATH=\"/usr/local/lib:\$LD_LIBRARY_PATH\"" >> $HOME/.bashrc $ source $HOME/.bashrc # Install Python modules From a83362084b80e2a529e9b9cb2221ddc9b5de75b6 Mon Sep 17 00:00:00 2001 From: "Bofu Chen (bafu)" Date: Wed, 20 Jan 2016 17:28:52 +0800 Subject: [PATCH 6/7] * INSTALL.md - Add hyperlinks for external/internal issues. --- INSTALL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index ab143f9..58b6296 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -69,7 +69,7 @@ The CUDA toolkit should be installed at `/usr/local/cuda/`. ``` If you get the error messages when executing `make`, that means you might be - using cuDNN v4 instead of v3 (Issue #36): + using cuDNN v4 instead of v3 (Issue [#36](https://github.com/andersbll/cudarray/issues/36)): ``` src/nnet/cudnn.cpp:206:5: error: cannot convert ‘const float*’ to ‘cudnnConvolutionBwdFilterAlgo_t’ for argument ‘8’ to ‘cudnnStatus_t cudnnConvolutionBackwardFilter(cudnnHandle_t, const void*, cudnnTensorDescriptor_t, const void*, cudnnTensorDescriptor_t, const void*, cudnnConvolutionDescriptor_t, cudnnConvolutionBwdFilterAlgo_t, void*, size_t, const void*, cudnnFilterDescriptor_t, void*)’ @@ -112,7 +112,7 @@ The model size is around 510 MB. ## Out of Memory Issue If you get the out of memory error messages when executing -neural_artistic_style.py (Issue #26): +neural_artistic_style.py (Issue [#26](https://github.com/andersbll/neural_artistic_style/issues/26)): ``` Traceback (most recent call last): From 7a206b927f9b276d43d55aaa6892dc24e360846e Mon Sep 17 00:00:00 2001 From: Bofu Chen Date: Fri, 29 Jan 2016 17:46:27 +0800 Subject: [PATCH 7/7] Correct the installation path of cuDNN. --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 58b6296..9fc30cb 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -32,7 +32,7 @@ The CUDA toolkit should be installed at `/usr/local/cuda/`. 1. Extract the tarball file to the CUDA directory: ``` - $ sudo tar xzf cudnn-7.0-linux-x64-v3.0-prod.tgz -C /usr/loca/cuda + $ sudo tar xzf cudnn-7.0-linux-x64-v3.0-prod.tgz -C /usr/local ``` The tarball file consists of libcudnn static and shared object libraries, and