Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cudamat install error in Windows #57

Open
chzh1229 opened this issue Nov 4, 2015 · 5 comments
Open

Cudamat install error in Windows #57

chzh1229 opened this issue Nov 4, 2015 · 5 comments

Comments

@chzh1229
Copy link

chzh1229 commented Nov 4, 2015

Hello, I was currently trying to rerun a project using cudamat. When I tried to install cudamat, I have encountered a lot of troubles but solved them after all. But there was still one that kept me from finishing it.

My system is windows 10, my GPU is GTX970. I have had python 2.7.10 and the latest CUDA toolkit (v7.5) installed and both Visual studio 12 and 14 installed (the nvcc of 14 was not supported by CUDA so I installed 12). Also I installed pycuda as well (not sure if this matters.)

I first tried using the code from surban's branch, but after pip shows successful installed (also the lib was shown in pip list), when I ran nosetests, it gives the error which was similar to the one I will show in the next part.

Then I switched back to this branch and found that the Windows issue was supposed to be solved. I ran the installation following the instructions given in install.md, but a similar error was given, shown as below:

EE
======================================================================
ERROR: Failure: WindowsError ([Error 193] %1 is not a valid Win32 application)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\Program Files (x86)\Python27\lib\site-packages\nose\loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "D:\Program Files (x86)\Python27\lib\site-packages\nose\importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "D:\Program Files (x86)\Python27\lib\site-packages\nose\importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "C:\Users\Administrator\Desktop\cudamat\test\test_cudamat.py", line 3, in <module>
    import cudamat as cm
  File "D:\Program Files (x86)\Python27\lib\site-packages\cudamat-0.3-py2.7-win32.egg\cudamat\__init__.py", line 1, in <module>
    from .cudamat import *
  File "D:\Program Files (x86)\Python27\lib\site-packages\cudamat-0.3-py2.7-win32.egg\cudamat\cudamat.py", line 18, in <module>
    _cudamat = load_library('libcudamat')
  File "D:\Program Files (x86)\Python27\lib\site-packages\cudamat-0.3-py2.7-win32.egg\cudamat\cudamat.py", line 16, in load_library
    basename + ext))
  File "D:\Program Files (x86)\Python27\lib\ctypes\__init__.py", line 443, in LoadLibrary
    return self._dlltype(name)
  File "D:\Program Files (x86)\Python27\lib\ctypes\__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application

======================================================================
ERROR: Failure: WindowsError ([Error 193] %1 is not a valid Win32 application)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\Program Files (x86)\Python27\lib\site-packages\nose\loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "D:\Program Files (x86)\Python27\lib\site-packages\nose\importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "D:\Program Files (x86)\Python27\lib\site-packages\nose\importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "C:\Users\Administrator\Desktop\cudamat\test\test_learn.py", line 4, in <module>
    import cudamat as cm
  File "D:\Program Files (x86)\Python27\lib\site-packages\cudamat-0.3-py2.7-win32.egg\cudamat\__init__.py", line 1, in <module>
    from .cudamat import *
  File "D:\Program Files (x86)\Python27\lib\site-packages\cudamat-0.3-py2.7-win32.egg\cudamat\cudamat.py", line 18, in <module>
    _cudamat = load_library('libcudamat')
  File "D:\Program Files (x86)\Python27\lib\site-packages\cudamat-0.3-py2.7-win32.egg\cudamat\cudamat.py", line 16, in load_library
    basename + ext))
  File "D:\Program Files (x86)\Python27\lib\ctypes\__init__.py", line 443, in LoadLibrary
    return self._dlltype(name)
  File "D:\Program Files (x86)\Python27\lib\ctypes\__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application

----------------------------------------------------------------------
Ran 2 tests in 0.101s

FAILED (errors=2)

It shows error about loading the dll file libcudamat.dll, but the code looks good to me and the file is located where it is supposed to be. I tried adding the directory to the path but it does not help.

I hope someone could help me with this. Thanks.

@chzh1229
Copy link
Author

chzh1229 commented Nov 4, 2015

Also, the cudamat is unusable in all situations, similar error will be given whenever I try to import this lib.

@f0k
Copy link
Contributor

f0k commented Nov 9, 2015

Interesting, so the DLL is unreadable for some reason. What kind of terminal/console did you use to compile it, and what kind of terminal/console do you use when trying to import it?

Can you try to compile the DLL manually? The following set of commands should do it (starting from the cudamat subdirectory, the one that has cudamat.cu):

nvcc -c -O -o cudamat.obj cudamat.cu
nvcc -c -O -o cudamat_kernels.obj cudamat_kernels.cu
nvcc --shared -o cudamat.dll cudamat.obj cudamat_kernels.obj -lcublas

If this works, #53 would be the solution. Thanks!

@edtechchrward
Copy link

edtechchrward commented Jun 29, 2016

Interesting, so the DLL is unreadable for some reason. What kind of terminal/console did you use to compile it, and what kind of terminal/console do you use when trying to import it?

Can you try to compile the DLL manually? The following set of commands should do it (starting from the cudamat subdirectory, the one that has cudamat.cu):

nvcc -c -O -o cudamat.obj cudamat.cu
nvcc -c -O -o cudamat_kernels.obj cudamat_kernels.cu
nvcc --shared -o cudamat.dll cudamat.obj cudamat_kernels.obj -lcublas

If this works, #53 would be the solution. Thanks!

Okay, so I've got the cudamat.dll and I am working with Miniconda3 on windows7. So where do I put the dll?

@f0k
Copy link
Contributor

f0k commented Jun 29, 2016

Okay, so I've got the cudamat.dll and I am working with Miniconda3 on windows7. So where do I put the dll?

To install everything manually:

  • place cudamat.py, __init__.py, learn.py and rnd_multipliers_32bit.txt into a new cudamat directory
  • add cudamat.dll (renaming it to libcudamat.dll)
  • add libcudalearn.dll (which you need to compile first, replacing cudamat with learn in the compilation commands posted above)
  • move this new cudamat directory somewhere into your Python path. python -c "import sys; print sys.path" will tell you all the directories that are on your path. Alternatively, you could change the PYTHONPATH environment variable to include the directory containing your new cudamat directory (not the cudamat directory itself).

This is a bit hacky, but it should do the trick.

@edtechchrward
Copy link

To install everything manually:

place cudamat.py, __init__.py, learn.py and rnd_multipliers_32bit.txt into a new cudamat directory
add cudamat.dll (renaming it to libcudamat.dll)
add libcudalearn.dll (which you need to compile first, replacing cudamat with learn in the compilation commands posted above)
move this new cudamat directory somewhere into your Python path. python -c "import sys; print sys.path" will tell you all the directories that are on your path. Alternatively, you could change the PYTHONPATH environment variable to include the directory containing your new cudamat directory (not the cudamat directory itself).

This is a bit hacky, but it should do the trick.

For Miniconda3 I moved the new cudamatdirectory to Miniconda3/Lib/site-packages, then ran the example script from the cudamat readme.md file. It ran without error.
Thnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants