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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# neural-style-pt Installation
|
2 |
+
|
3 |
+
This guide will walk you through multiple ways to setup `neural-style-pt` on Ubuntu and Windows. If you wish to install PyTorch and neural-style-pt on a different operating system like MacOS, installation guides can be found [here](https://pytorch.org).
|
4 |
+
|
5 |
+
Note that in order to reduce their size, the pre-packaged binary releases (pip, Conda, etc...) have removed support for some older GPUs, and thus you will have to install from source in order to use these GPUs.
|
6 |
+
|
7 |
+
|
8 |
+
# Ubuntu:
|
9 |
+
|
10 |
+
## With A Package Manager:
|
11 |
+
|
12 |
+
The pip and Conda packages ship with CUDA and cuDNN already built in, so after you have installed PyTorch with pip or Conda, you can skip to [installing neural-style-pt](https://github.com/ProGamerGov/neural-style-pt/blob/master/INSTALL.md#install-neural-style-pt).
|
13 |
+
|
14 |
+
### pip:
|
15 |
+
|
16 |
+
The neural-style-pt PyPI page can be found here: https://pypi.org/project/neural-style/
|
17 |
+
|
18 |
+
If you wish to install neural-style-pt as a pip package, then use the following command:
|
19 |
+
|
20 |
+
```
|
21 |
+
# in a terminal, run the command
|
22 |
+
pip install neural-style
|
23 |
+
```
|
24 |
+
|
25 |
+
Or:
|
26 |
+
|
27 |
+
|
28 |
+
```
|
29 |
+
# in a terminal, run the command
|
30 |
+
pip3 install neural-style
|
31 |
+
```
|
32 |
+
|
33 |
+
Next download the models with:
|
34 |
+
|
35 |
+
|
36 |
+
```
|
37 |
+
neural-style -download_models
|
38 |
+
```
|
39 |
+
|
40 |
+
By default the models are downloaded to your home directory, but you can specify a download location with:
|
41 |
+
|
42 |
+
```
|
43 |
+
neural-style -download_models <download_path>
|
44 |
+
```
|
45 |
+
|
46 |
+
#### Github and pip:
|
47 |
+
|
48 |
+
Following the pip installation instructions
|
49 |
+
[here](http://pytorch.org), you can install PyTorch with the following commands:
|
50 |
+
|
51 |
+
```
|
52 |
+
# in a terminal, run the commands
|
53 |
+
cd ~/
|
54 |
+
pip install torch torchvision
|
55 |
+
```
|
56 |
+
|
57 |
+
Or:
|
58 |
+
|
59 |
+
```
|
60 |
+
cd ~/
|
61 |
+
pip3 install torch torchvision
|
62 |
+
```
|
63 |
+
|
64 |
+
Now continue on to [installing neural-style-pt](https://github.com/ProGamerGov/neural-style-pt/blob/master/INSTALL.md#install-neural-style-pt) to install neural-style-pt.
|
65 |
+
|
66 |
+
### Conda:
|
67 |
+
|
68 |
+
Following the Conda installation instructions
|
69 |
+
[here](http://pytorch.org), you can install PyTorch with the following command:
|
70 |
+
|
71 |
+
```
|
72 |
+
conda install pytorch torchvision -c pytorch
|
73 |
+
```
|
74 |
+
|
75 |
+
Now continue on to [installing neural-style-pt](https://github.com/ProGamerGov/neural-style-pt/blob/master/INSTALL.md#install-neural-style-pt) to install neural-style-pt.
|
76 |
+
|
77 |
+
## From Source:
|
78 |
+
|
79 |
+
### (Optional) Step 1: Install CUDA
|
80 |
+
|
81 |
+
If you have a [CUDA-capable GPU from NVIDIA](https://developer.nvidia.com/cuda-gpus) then you can
|
82 |
+
speed up `neural-style-pt` with CUDA.
|
83 |
+
|
84 |
+
First download and unpack the local CUDA installer from NVIDIA; note that there are different
|
85 |
+
installers for each recent version of Ubuntu:
|
86 |
+
|
87 |
+
```
|
88 |
+
# For Ubuntu 18.04
|
89 |
+
sudo dpkg -i cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb
|
90 |
+
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
|
91 |
+
```
|
92 |
+
|
93 |
+
```
|
94 |
+
# For Ubuntu 16.04
|
95 |
+
sudo dpkg -i cuda-repo-ubuntu1604-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb
|
96 |
+
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
|
97 |
+
```
|
98 |
+
|
99 |
+
Instructions for downloading and installing the latest CUDA version on all supported operating systems, can be found [here](https://developer.nvidia.com/cuda-downloads).
|
100 |
+
|
101 |
+
Now update the repository cache and install CUDA. Note that this will also install a graphics driver from NVIDIA.
|
102 |
+
|
103 |
+
```
|
104 |
+
sudo apt-get update
|
105 |
+
sudo apt-get install cuda
|
106 |
+
```
|
107 |
+
|
108 |
+
At this point you may need to reboot your machine to load the new graphics driver.
|
109 |
+
After rebooting, you should be able to see the status of your graphics card(s) by running
|
110 |
+
the command `nvidia-smi`; it should give output that looks something like this:
|
111 |
+
|
112 |
+
```
|
113 |
+
Wed Apr 11 21:54:49 2018
|
114 |
+
+-----------------------------------------------------------------------------+
|
115 |
+
| NVIDIA-SMI 384.90 Driver Version: 384.90 |
|
116 |
+
|-------------------------------+----------------------+----------------------+
|
117 |
+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
|
118 |
+
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|
119 |
+
|===============================+======================+======================|
|
120 |
+
| 0 Tesla K80 Off | 00000000:00:1E.0 Off | 0 |
|
121 |
+
| N/A 62C P0 68W / 149W | 0MiB / 11439MiB | 94% Default |
|
122 |
+
+-------------------------------+----------------------+----------------------+
|
123 |
+
|
124 |
+
+-----------------------------------------------------------------------------+
|
125 |
+
| Processes: GPU Memory |
|
126 |
+
| GPU PID Type Process name Usage |
|
127 |
+
|=============================================================================|
|
128 |
+
| No running processes found |
|
129 |
+
+-----------------------------------------------------------------------------+
|
130 |
+
```
|
131 |
+
|
132 |
+
### (Optional) Step 2: Install cuDNN
|
133 |
+
|
134 |
+
cuDNN is a library from NVIDIA that efficiently implements many of the operations (like convolutions and pooling)
|
135 |
+
that are commonly used in deep learning.
|
136 |
+
|
137 |
+
After registering as a developer with NVIDIA, you can [download cuDNN here](https://developer.nvidia.com/cudnn). Make sure that you use the approprite version of cuDNN for your version of CUDA.
|
138 |
+
|
139 |
+
After dowloading, you can unpack and install cuDNN like this:
|
140 |
+
|
141 |
+
```
|
142 |
+
tar -zxvf cudnn-10.1-linux-x64-v7.5.0.56.tgz
|
143 |
+
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
|
144 |
+
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
|
145 |
+
```
|
146 |
+
|
147 |
+
Note that the cuDNN backend can only be used for GPU mode.
|
148 |
+
|
149 |
+
### (Optional) Steps 1-3: Install PyTorch with support for AMD GPUs using Radeon Open Compute Stack (ROCm)
|
150 |
+
|
151 |
+
|
152 |
+
It is recommended that if you wish to use PyTorch with an AMD GPU, you install it via the official ROCm dockerfile:
|
153 |
+
https://rocm.github.io/pytorch.html
|
154 |
+
|
155 |
+
- Supported AMD GPUs for the dockerfile are: Vega10 / gfx900 generation discrete graphics cards (Vega56, Vega64, or MI25).
|
156 |
+
|
157 |
+
PyTorch does not officially provide support for compilation on the host with AMD GPUs, but [a user guide posted here](https://github.com/ROCmSoftwarePlatform/pytorch/issues/337#issuecomment-467220107) apparently works well.
|
158 |
+
|
159 |
+
ROCm utilizes a CUDA porting tool called HIP, which automatically converts CUDA code into HIP code. HIP code can run on both AMD and Nvidia GPUs.
|
160 |
+
|
161 |
+
|
162 |
+
### Step 3: Install PyTorch
|
163 |
+
|
164 |
+
To install PyTorch [from source](https://github.com/pytorch/pytorch#from-source) on Ubuntu (Instructions may be different if you are using a different OS):
|
165 |
+
|
166 |
+
```
|
167 |
+
cd ~/
|
168 |
+
git clone --recursive https://github.com/pytorch/pytorch
|
169 |
+
cd pytorch
|
170 |
+
python setup.py install
|
171 |
+
|
172 |
+
cd ~/
|
173 |
+
git clone --recursive https://github.com/pytorch/vision
|
174 |
+
cd vision
|
175 |
+
python setup.py install
|
176 |
+
```
|
177 |
+
|
178 |
+
To check that your torch installation is working, run the command `python` or `python3` to enter the Python interpreter. Then type `import torch` and hit enter.
|
179 |
+
|
180 |
+
You can then type `print(torch.version.cuda)` and `print(torch.backends.cudnn.version())` to confirm that you are using the desired versions of CUDA and cuDNN.
|
181 |
+
|
182 |
+
To quit just type `exit()` or use Ctrl-D.
|
183 |
+
|
184 |
+
Now continue on to [installing neural-style-pt](https://github.com/ProGamerGov/neural-style-pt/blob/master/INSTALL.md#install-neural-style-pt) to install neural-style-pt.
|
185 |
+
|
186 |
+
|
187 |
+
# Windows Installation
|
188 |
+
|
189 |
+
If you wish to install PyTorch on Windows From Source or via Conda, you can find instructions on the PyTorch website: https://pytorch.org/
|
190 |
+
|
191 |
+
|
192 |
+
### Github and pip
|
193 |
+
|
194 |
+
First, you will need to download Python 3 and install it: https://www.python.org/downloads/windows/. I recommend using the executable installer for the latest version of Python 3.
|
195 |
+
|
196 |
+
Then using https://pytorch.org/, get the correct pip command, paste it into the Command Prompt (CMD) and hit enter:
|
197 |
+
|
198 |
+
|
199 |
+
```
|
200 |
+
pip3 install torch===1.3.0 torchvision===0.4.1 -f https://download.pytorch.org/whl/torch_stable.html
|
201 |
+
```
|
202 |
+
|
203 |
+
|
204 |
+
After installing PyTorch, download the neural-style-pt Github respository and extract/unzip it to the desired location.
|
205 |
+
|
206 |
+
Then copy the file path to your neural-style-pt folder, and paste it into the Command Prompt, with `cd` in front of it and then hit enter.
|
207 |
+
|
208 |
+
In the example below, the neural-style-pt folder was placed on the desktop:
|
209 |
+
|
210 |
+
```
|
211 |
+
cd C:\Users\<User_Name>\Desktop\neural-style-pt-master
|
212 |
+
```
|
213 |
+
|
214 |
+
You can now continue on to [installing neural-style-pt](https://github.com/ProGamerGov/neural-style-pt/blob/master/INSTALL.md#install-neural-style-pt), skipping the `git clone` step.
|
215 |
+
|
216 |
+
# Install neural-style-pt
|
217 |
+
|
218 |
+
First we clone `neural-style-pt` from GitHub:
|
219 |
+
|
220 |
+
```
|
221 |
+
cd ~/
|
222 |
+
git clone https://github.com/ProGamerGov/neural-style-pt.git
|
223 |
+
cd neural-style-pt
|
224 |
+
```
|
225 |
+
|
226 |
+
Next we need to download the pretrained neural network models:
|
227 |
+
|
228 |
+
```
|
229 |
+
python models/download_models.py
|
230 |
+
```
|
231 |
+
|
232 |
+
You should now be able to run `neural-style-pt` in CPU mode like this:
|
233 |
+
|
234 |
+
```
|
235 |
+
python neural_style.py -gpu c -print_iter 1
|
236 |
+
```
|
237 |
+
|
238 |
+
If you installed PyTorch with support for CUDA, then should now be able to run `neural-style-pt` in GPU mode like this:
|
239 |
+
|
240 |
+
```
|
241 |
+
python neural_style.py -gpu 0 -print_iter 1
|
242 |
+
```
|
243 |
+
|
244 |
+
If you installed PyTorch with support for cuDNN, then you should now be able to run `neural-style-pt` with the `cudnn` backend like this:
|
245 |
+
|
246 |
+
```
|
247 |
+
python neural_style.py -gpu 0 -backend cudnn -print_iter 1
|
248 |
+
```
|
249 |
+
|
250 |
+
If everything is working properly you should see output like this:
|
251 |
+
|
252 |
+
```
|
253 |
+
Iteration 1 / 1000
|
254 |
+
Content 1 loss: 1616196.125
|
255 |
+
Style 1 loss: 29890.9980469
|
256 |
+
Style 2 loss: 658038.625
|
257 |
+
Style 3 loss: 145283.671875
|
258 |
+
Style 4 loss: 11347409.0
|
259 |
+
Style 5 loss: 563.368896484
|
260 |
+
Total loss: 13797382.0
|
261 |
+
Iteration 2 / 1000
|
262 |
+
Content 1 loss: 1616195.625
|
263 |
+
Style 1 loss: 29890.9980469
|
264 |
+
Style 2 loss: 658038.625
|
265 |
+
Style 3 loss: 145283.671875
|
266 |
+
Style 4 loss: 11347409.0
|
267 |
+
Style 5 loss: 563.368896484
|
268 |
+
Total loss: 13797382.0
|
269 |
+
Iteration 3 / 1000
|
270 |
+
Content 1 loss: 1579918.25
|
271 |
+
Style 1 loss: 29881.3164062
|
272 |
+
Style 2 loss: 654351.75
|
273 |
+
Style 3 loss: 144214.640625
|
274 |
+
Style 4 loss: 11301945.0
|
275 |
+
Style 5 loss: 562.733032227
|
276 |
+
Total loss: 13711628.0
|
277 |
+
Iteration 4 / 1000
|
278 |
+
Content 1 loss: 1460443.0
|
279 |
+
Style 1 loss: 29849.7226562
|
280 |
+
Style 2 loss: 643799.1875
|
281 |
+
Style 3 loss: 140405.015625
|
282 |
+
Style 4 loss: 10940431.0
|
283 |
+
Style 5 loss: 553.507446289
|
284 |
+
Total loss: 13217080.0
|
285 |
+
Iteration 5 / 1000
|
286 |
+
Content 1 loss: 1298983.625
|
287 |
+
Style 1 loss: 29734.8964844
|
288 |
+
Style 2 loss: 604133.8125
|
289 |
+
Style 3 loss: 125455.945312
|
290 |
+
Style 4 loss: 8850759.0
|
291 |
+
Style 5 loss: 526.118591309
|
292 |
+
Total loss: 10912633.0
|
293 |
+
```
|