Sunday, August 16, 2015

Installing OpenBLAS for Theano on Windows

Once more, this proved to be quite difficult to do on Windows, so I'll explain how I finally got it to work. I'll assume you've read the previous post about the Theano installation and that you have mingw (64 bits) installed. The order in which you do these steps shouldn't really matter, but just in case, you can follow my order.

First, you need to download Open BLAS. Get the one called:

OpenBLAS-v0.2.14-Win64-int32.zip (I'm not sure if this also works with the -int64 version)

Next, make a folder C:\openblas. I don't think it must have this exact name, but it must not contain any spaces, so keep it simple.

Now, add this to your .theanorc file

Make sure you type it exactly like that, with the -L and everything.

Next, from the OpenBLAS zip you downloaded, extract the libopenblas.dll file from the bin folder and the libopenblas.a file from the lib folder to the openblas folder you created. I'm not sure if you need both or not, the dll might be enough, but I just copied both.

Finally, you also need to make the dependencies of this library available. I'm sure there's a better way to do this, but what I did was copy everything from C:\Program Files\mingw-w64\x86_64-5.1.0-posix-seh-rt_v4-rev0\mingw64\x86_64-w64-mingw32\lib (where I installed my mingw 64 bits) to the openblas folder I created. I guess you could also add this to your system Path, but that's arguably even uglier.

This did it for me. Please comment if you have any questions or suggestions on how to simplify this process.

Saturday, August 8, 2015

Installing Theano on Windows 10, 64 bits, Python 3.4 64 bits

Unfortunately, there seems to be little information regarding the installation of Theano on Windows systems. You can do it by searching on Google, but everything is spread out across different blogs, forums and groups. I'm going to try to compile this information in a single place. Hopefully, I'm not forgetting anything, but if I am, please leave a comment.

You will need numpy and scipy installed. These are easy enough to install on Windows, so I won't get into those details. I also assume that you haven't installed Python through a package like Anaconda.

First of all, run pip:


You can also update it from github to have the latest additions:



Now, the first thing I had to do was fix the problem described here. The fix involves copying the file python34.dll from C:\Windows\system32 to a temp folder and then running the following commands in a cmd window open in that temp folder (shift+right click in Explorer to open a cmd window in the folder you're in):


Then, copy the generated libpython34.a file to your system32 folder.

Next, you need to install a 64 bit MinGW. Add this to your System Path variable. It should look similar to this:


Next, you should create a file named .theanorc in C:\Users\<your username>. This is created by writing .theanorc. (notice the dot at the end) in the rename textbox in Explorer. If you don't add the dot at the end, you'll get an error. You'll want the following in this file:



Notice that you need Visual Studio 2013 for this. I tried using 2015, but that didn't work. It might work in future versions, but it didn't for me.

As a final step (although you really could have done this at any point), you should install cuDNN. Google for it, the link might change so I'm not going to post it.

To test that everything works, open IDLE or ipython and type import theano. You should get an output similar to this:



It might take a while for each output to show up, but as long as there are no erros, you should be fine.