anishathalye / neural-style

Neural style in TensorFlow! 🎨
https://anishathalye.com/an-ai-that-can-mimic-any-artist/
GNU General Public License v3.0
5.54k stars 1.52k forks source link

Doesn't run on Windows 10 #161

Closed sourcedexter closed 4 years ago

sourcedexter commented 4 years ago

I have all the environment dependencies setup. When I run the script, it does not throw any error, but it doesn't train either.

Command used:
python neural_style.py --content .\xwing.jpg --styles .\space.jpg --output theout.jpg --style-weight 0.3 --style-layer-weight-exp 0.2 --pooling avg --checkpoint-output .\out\check_{}.jpg --checkpoint-iterations 50

here's the output: 2020-01-14 22:08:06.783431: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 2020-01-14 22:08:07.313816: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1411] Found device 0 with properties: name: GeForce 940MX major: 5 minor: 0 memoryClockRate(GHz): 1.2415 pciBusID: 0000:01:00.0 totalMemory: 4.00GiB freeMemory: 3.36GiB 2020-01-14 22:08:07.329445: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1490] Adding visible gpu devices: 0 2020-01-14 22:08:08.533005: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] Device interconnect StreamExecutor with strength 1 edge matrix: 2020-01-14 22:08:08.540925: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] 0 2020-01-14 22:08:08.545901: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0: N 2020-01-14 22:08:08.551660: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1103] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 3073 MB memory) -> physical GPU (device: 0, name: GeForce 940MX, pci bus id: 0000:01:00.0, compute capability: 5.0) 2020-01-14 22:08:13.506375: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1490] Adding visible gpu devices: 0 2020-01-14 22:08:13.515591: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] Device interconnect StreamExecutor with strength 1 edge matrix: 2020-01-14 22:08:13.523388: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] 0 2020-01-14 22:08:13.529139: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0: N 2020-01-14 22:08:13.534527: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1103] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 3073 MB memory) -> physical GPU (device: 0, name: GeForce 940MX, pci bus id: 0000:01:00.0, compute capability: 5.0) 2020-01-14 22:08:16.440041: W tensorflow/core/framework/allocator.cc:113] Allocation of 2236612608 exceeds 10% of system memory. 2020-01-14 22:08:19.230418: W tensorflow/core/framework/allocator.cc:113] Allocation of 2236612608 exceeds 10% of system memory.

is there some way to see if an error is occurring but not being printed?

anishathalye commented 4 years ago

The line Allocation of 2236612608 exceeds 10% of system memory. makes me think your system is getting out of memory. The GeForce 940MX appears to have 4GB of memory, so this won't support a large input image (I've tested the sample images on a Titan X with 12GB of memory).

Could you try a smaller image (e.g. try a 100x100 content and style image)? If that works, then we will know that this is the problem.

sourcedexter commented 4 years ago

I wi try what you have suggested and see if it works.

However, shouldn't it have thrown an error? I checked about the allocation of memory exceeds 10% . It's not an error but a warning from tf. I suspect it's something else but I'll try what you said and let you know.

azurrot commented 4 years ago

Hello all, I am using Windows 10 and could succesfully recreate the examples windows. But still I get the "exceeds 10% of system memory" when I try to transfer larger images. I googled a bit and the solution might be to adjust the batch size but I could not find something like this in the code. Is the batch size already part of the model (imagenet-vgg-verydeep-19.mat) or is it somewhere in the code?

Best regards

anishathalye commented 4 years ago

There isn't really a notion of "batch size" with this neural style algorithm. Batch size is always 1. If you want to process large images, you either need more GPU memory, need to tweak the implementation to do something like moving data from GPU <-> CPU memory to save on GPU memory, or use a different algorithm like fast style transfer instead.

anishathalye commented 4 years ago

Closing due to inactivity, feel free to re-open if you have any follow-up questions.