Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip install pycuda on windows

I'm using VS2008, Win XP, latest CUDA toolkit. I run pip install pycuda on windows and get following log from C:\Documents and Settings\User\Application Data\pip\pip.log

I get error

LINK : fatal error LNK1181: cannot open input file 'cuda.lib'

error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\link.exe"' failed with exit status 1181

I think I need to specify some path variable to cuda lib, but I don't understand what variable and why it don't set during instalation of cuda toolkit.

UPDATE: I manged to resolve this issue installing prebuild pycuda from here , but maybe it will work slower because it wasn't compiled on my machine.

like image 312
mrgloom Avatar asked Oct 28 '13 11:10

mrgloom


People also ask

What is PyCUDA?

PyCUDA is a Python programming environment for CUDA it give you access to Nvidia's CUDA parallel computation API from Python.


1 Answers

In case someone is still looking for an answer:

configure.py generates a siteconf.py file containing the paths to CUDA .lib files used to compile pycuda. However, it uses incorrect paths (at least when on Windows and using toolkit V7.5).

Now this can be fixed multiple ways (make sure you've downloaded the pycuda package and decompressed it somewhere):

1. Modifying setup.py

This is where the main culprit lies. These are the paths it currently uses:

default_lib_dirs = [
    "${CUDA_ROOT}/lib", "${CUDA_ROOT}/lib64",
    # https://github.com/inducer/pycuda/issues/98
    "${CUDA_ROOT}/lib/stubs", "${CUDA_ROOT}/lib64/stubs",
    ]

Currently Nvidia uses CUDA_PATH as environmental variable, and the .lib files are stored within a separate x64 or Win32 folder. You can either add these paths to the array, or just get rid of the incorrect ones

default_lib_dirs = ["${CUDA_PATH}/lib/x64", "${CUDA_PATH}/lib/Win32"]

now run py configure.py to generate the siteconf.py file.

2. Override settings generated by configure.py

As mentioned, configure.py generates the siteconf.py file. You can call configure.py with optional parameters to override the default library folders (what we defined in setup.py). Partial output after running configure.py --help

--cudadrv-lib-dir=DIR
    Library directories for Cudadrv (default:
    ${CUDA_PATH}/lib/x64) (several ok)
--cudadrv-libname=LIBNAME
    Library names for Cudadrv (without lib or .so)
    (default: cuda) (several ok)
--cudart-lib-dir=DIR  Library directories for Cudart (default:
    ${CUDA_PATH}/lib/x64) (several ok)
--cudart-libname=LIBNAME
    Library names for Cudart (without lib or .so)
    (default: cudart) (several ok)
--curand-lib-dir=DIR  Library directories for Curand (default:
    ${CUDA_PATH}/lib/x64) (several ok)
--curand-libname=LIBNAME
    Library names for Curand (without lib or .so)
    (default: curand) (several ok)

3. Modify siteconf.py directly

The easiest method. Just run py configure.py to generate a siteconf.py file with default paths, and edit that file afterwards.
Later on I figured both these pages recommend doing just that: https://kerpanic.wordpress.com/2015/09/28/pycuda-windows-installation-offline/ https://wiki.tiker.net/PyCuda/Installation/Windows

Finish the installation

To wrap it all up, compile and install pycuda by running:

py setup.py build
py setup.py install

(this will use the previously generated/modified siteconf.py file).

That's it :)

(If you are wondering why I wrote down all 3 methods instead of just the most easiest one, I actually found out about the siteconf.py and configure.py file after I messed around with default_lib_dirs in the setup.py file. Same for the two website links, I found those after manually solving the problem)

like image 99
MarijnS95 Avatar answered Oct 15 '22 09:10

MarijnS95