Skip to content

Instantly share code, notes, and snippets.

@ElefHead
Last active July 12, 2022 14:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ElefHead/93becdc9e99f2a9e4d2525a59f64b574 to your computer and use it in GitHub Desktop.
Save ElefHead/93becdc9e99f2a9e4d2525a59f64b574 to your computer and use it in GitHub Desktop.
A guide to install pymc3, theano with CUDA on windows 10 -- Dec 2019

I am writing this gist because I spent 6 hours navigating links trying to get Theano to work with CUDA on windows 10. Hopefully, you wouldn't have to. Once theano is setup and running, you can install pymc3 and it all works. I had tensorflow-gpu setup and running on windows 10; it isn't as simple as pip install theano.

I will list down the instructions, with the links where I found them. Hope this helps someone.

This set of instructions depend on anaconda. Also, this is sort of hacky in the end.

Ok let's begin.


  1. Follow this guide to install MS Visual Studio, CUDA and CuDNN. I have MS Visual Studio version 17 community. I installed it via the MS Visual Studio installer, while installing it will prompt you to install libraries, choose Desktop development with C++ workload.
  2. If you skipped over the desktop C++ workload, do not worry. Bring up the MS Visual Studio installer, track your version and click "modify" and then install Desktop development with C++.
  3. Add the visual studio C++ path to environment. Mine is something like C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64.
  4. Install Anaconda, add python to your environment variables.
  5. As confirmation, you should by now have Cuda, python, visual studio, and visual studio C++ location in your path system environment. You should also have a system variable called CUDA_PATH.
  6. We need to install mingw64, libpython and pygpu
conda install m2w64-toolchain libpython pygpu
  1. Let's install theano now
conda install theano
  1. Add a THEANO_FLAGS environment variable. Set it to floatX=float32,device=cuda.
  2. Install pymc3
conda install pymc3

Are we done? Not quite. When you run any simple program using either theano or pymc3, it will default to cpu because of an error. The error will be along the lines of 'Could not load "nvrtc64_xx.dll(replace xx by error log version number).
Here's a hacky solution - go to your CUDA bin and copy the nvrtc64_<version>.dll and paste it into anaconda bin.

cp "NVIDIA GPU Computing Toolkit/CUDA/v10.1/bin/nvrtc64_<your version number>.dll" ~/Anaconda3/Library/bin/nvrtc64_<error log version number>.dll

It will then raise errors about blas: (b'Missing Blas library', 5). Repeat above for blas :

cp "NVIDIA GPU Computing Toolkit/CUDA/v10.1/bin/cublas64_<your version number>.dll" ~/Anaconda3/Library/bin/cublas64_<match nvrtc64 error log version number>.dll"

Now we're done. When you run any code, it will throw a warning saying your cuda version is higher, but the program will run on the GPU so that's fine. This is quite hacky and if someone finds out a real solution, please feel free to message me on twitter @Elefhead.


References:

@VincentTam
Copy link

Thx 4 great guide! This saves me hours of testing. :)
The link to the blog post in (1) no longer works.

image

@ElefHead
Copy link
Author

@VincentTam Glad to be of help!

The link to the blog post in (1) no longer works.

I no longer use a windows machine, would you recommend a link that works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment