andersbll / neural_artistic_style

Neural Artistic Style in Python
MIT License
2.18k stars 482 forks source link

Will it work without CUDA? #13

Open softshape opened 9 years ago

softshape commented 9 years ago

Hi,

is CUDA requirement or optimization? Will it work on PC without CUDA ?

andersbll commented 9 years ago

CUDArray has a NumPy-based backend allowing it to run on CPU. However, the convolution operations on CPU are way too slow to be useful for Neural artistic networks of any decent size.

mawimawi commented 9 years ago

I have it working without CUDA. On startup of the program, I get a warning "CUDArray: CUDA back-end not available, using NumPy.."

One iteration of two images having about 700x500px takes about 30 minutes on my MacBook (2.7Ghz, 4 Cores)

I hope to get it working with CUDA soon. I guess, I'll have to wait until NVIDIA accepts my registration, so I can get the header files for the libraries...

andersbll commented 9 years ago

@mawimawi: You can run without cuDNN if you choose max pooling using the command line option. This might be more entertaining than running on CPU while you are waiting for your cuDNN download. :)

mawimawi commented 9 years ago

@andersbll : I did not notice any speed improvements after trying the "--pool-method max" command line option. Maybe I'm doing something wrong? Also: Is it possible to explain the command line parameters a bit for people like me who are just interested to create these nice effects and have no idea how the algorithm works? And: How long does the algorithm work on an iteration on your gpu? Just being curious here.

mawimawi commented 9 years ago

Oops, just found out that I have to set a couple of environment variables too. In my case it was:

LD_LIBRARY_PATH=/usr/local/cuda/lib CUDARRAY_BACKEND=cuda python neural_artistic_style.py --subject my_image.jpg --style my_style.jpg --pool-method max

about 20 times faster than running on cpu, BUT as I only have a 1GB graphics card, the source images must be really tiny (about 250x200px)

andersbll commented 9 years ago

@mawimawi: You are right, better documentation would be nice! :) I'm a bit short on time at the moment, though.

benwu7 commented 9 years ago

I don't have a computer with Nvidia graphic card. So Testing on my macbook (early 2015). It is also super slow.

andersbll commented 9 years ago

@benwu7: Yes, the NumPy backend could benefit from a more effective convolution implementation. Though, even with fast CPU convolutions, the optimization will probably take around 30 minutes rather than 1-2 miuntes.

benwu7 commented 9 years ago

I ran the following command:

python neural_artistic_style.py --subject images/tuebingen.jpg --style images/starry_night.jpg
CUDArray: CUDA back-end not available, using NumPy.

This has been run for a week now. I have my macbook open for 8 hours per day. It is now at

Iteration: 219, cost: 6.3366

Is the program in an infinite loop?

andersbll commented 9 years ago

Hey, sorry for the late reply. The convolution operations on CPU are too slow for any practical usage. Sorry about that.

benwu7 commented 9 years ago

Thanks! Will try it on GPU if I have a chance :+1:

Irolan commented 8 years ago

Hi, I have CUDA downloaded, but still get the message that the CUDA backend is not available. The very sparce installation instructions say to "add to the PATH environment variable". I unzipped it to E:\cuda so that's what I added. Apparently that's wrong. Can anyone tell me what I need to add under Windows?

verybigelephants commented 8 years ago

if i understand correctly, you need cudarray library for python, just having cuda downloaded won't do anything. unfortunately, here it says that it's currently not possible on windows https://github.com/andersbll/cudarray

Irolan commented 8 years ago

Cudarray is a dependency. Don't remember for what, but I had to install it. So basically, this other module is contempt with having cudarray there, despite it apparently not working on Windows? I'll never understand this stuff...

filmo commented 8 years ago

cudarray is the underlying interface between Python and the compiled CUDA libraries. deeppy has cudarray as a dependency. Neural_artisic_style has deeppy as a dependency. You need to have deeppy and cudarray installed to get this software to work effectively. To install cudarray, it must compile the .cu files.

I could be wrong, but right now it only works on linux and mac os x.

jaold commented 8 years ago

I am running on windows, and got cudarray installed without the CUDA backend. Deeppy installed without problem. However when I go to run neural_artistic_style.py, I get the message:

CUDArray: CUDA back-end not available, using NumPy

Then Python crashes.

Question, do you think this is because I'm running on windows, or due to the lack of the CUDA backend, or something else?

verybigelephants commented 8 years ago

https://github.com/andersbll/cudarray

TODO

Proper transpose support, Add functionality for copying from NumPy array to existing CUDArray array. FFT module based on cuFFT. Unit tests! Add documentation to wiki. Windows/OS X support.

alexhulbert commented 8 years ago

@jaold Are you actually running this on windows? How did you get it compiled?

Irolan commented 8 years ago

@Taconut running it on Windows is no problem, if you get all dependencies (I did so via the Conda package manager). There's just no CUDA support. Which is a real pity, I don't plan on setting up a Linux just for this program.

sirisian commented 8 years ago

Does this implement any multithreading without CUDA? I just spun up a VM and gave it 14 of my 16 cores (5960X) and setup everything. It only seems to be using 11% CPU max. I ran just the basic example:

python neural_artistic_style.py --subject images/tuebingen.jpg --style images/starry_night.jpg

I'd like to run this without creating a Linux partition ideally, but that doesn't seem likely if it's only going to use 1/8 CPU core. Also how many iterations does the basic example take?

filmo commented 8 years ago

In theory you can run it on just a CPU. In practice it does not work unless you have an infinite amount of time. @andersbll, perhaps update the readme at the beginning to indicate that a Nvidia GPU on Linux or Mac is pretty much required. ?? Or just remove the CPU option entirely since it seems to only confuse people into thinking this can operate on a CPU-only machine.

andersbll commented 8 years ago

@filmo: Under requirements, I already specify cuDNN. :) But it's probably best to write out more explicitely that the conv. operations on CPU are too slow.

sirisian commented 8 years ago

Yeah I let it run and it got to 70 iterations of 500 after like 36 hours with the small sample images. I created a quick Ubuntu partition and with my 2x GTX 980 it finished in around 3 minutes for 1024x768. Definitely underestimated that. Might help others though that were trying to use the CPU.

filmo commented 8 years ago

For others who see this in the future, @sirisian results imply that it takes ~30 minutes per iteration. Typically there are 500 iterations to generate a result. This means 250 hours to generate one image on a CPU (~10.4 days vs 3 minutes on a GPU). So for those of you asking if it works on a CPU, keep this in mind.

The reality is you will need a GPU.

zhongning7924 commented 7 years ago

@mawimawi how to reslove the question? CUDArray: CUDA back-end not available, using NumPy。

zhongning7924 commented 7 years ago

sudo python neural_artistic_style.py --subject images/meone.jpg --style images/lundstroem.jpg Password: CUDArray: CUDA back-end not available, using NumPy. Iteration: 0, cost: 25.7766 Iteration: 1, cost: 24.8901 Iteration: 2, cost: 23.8086 Iteration: 3, cost: 22.7018

dlspm commented 6 years ago

@zhongning7924 Excuse me ,I have the same problem with you , Can you tell me ? How do you solve.