Pip install pycuda on windows

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

I get an 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

It seems to me that I need to specify some path variable in cuda lib, but I do not understand which variable and why it is not set when installing the cuda toolkit.

UPDATE: I decided to solve this problem by installing prebuild pycuda from here , but maybe it will work slower because it has not been compiled on my machine.

+6
source share
1 answer

If someone is still looking for an answer:

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

Now this can be fixed in several ways (make sure you download the pycuda package and unpack it somewhere):

1. Change the setup.py parameter

That's where the main culprit is. These are the paths he is currently using:

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

Nvidia currently uses CUDA_PATH as an environment variable, and .lib files are stored in a separate x64 or Win32 folder. You can either add these paths to the array, or just get rid of the wrong 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 options created by configure.py

As already mentioned, configure.py creates the siteconf.py file. You can call configure.py with additional parameters to override the default library folders (which 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 the siteconf.py file directly

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

Complete 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).

What is it:)

(If you are wondering why I wrote down all 3 methods, and not just the simplest one, I really found out about the siteconf.py and configure.py file after I mixed up the default_lib_dirs setup.py in the setup.py file. The same goes for two links to the site, I found them after solving the problem manually)

+4
source

Source: https://habr.com/ru/post/956864/


All Articles