xiaozhenBoy / cudamat

Automatically exported from code.google.com/p/cudamat
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Install as local library for the whole system needs filepath of DLL/SO files. #11

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi!

I like to have my cudamat installation available systemwide, so I put it in 
/usr/local/lib/python2.7/dist-packages/cudamat/  . However, then the simple 
'import cudamat' statement will fail:

>>> import cudamat
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/cudamat/__init__.py", line 1, in <module>
    from cudamat import *
  File "/usr/local/lib/python2.7/dist-packages/cudamat/cudamat.py", line 10, in <module>
    _cudamat = ct.cdll.LoadLibrary('libcudamat.so')
  File "/usr/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libcudamat.so: cannot open shared object file: No such file or 
directory

This because at the start of "cudamat.py and "learn.py" when loading 
libcudamat.so, Python doesn't look in the correct directory. To fix this, the 
following change to that part of the code is sufficient:

_curdir = os.path.dirname(os.path.realpath(__file__))
if platform.system() == 'Windows':
    _cudamat = ct.cdll.LoadLibrary(os.path.join(_curdir, 'libcudamat.dll'))
else:
    _cudamat = ct.cdll.LoadLibrary(os.path.join(_curdir, 'libcudamat.so'))

It's a small change, but it would be nice to have it in the official repository 
because I run into it each time I'm installling cudamat :)

Original issue reported on code.google.com by thomas.u...@gmail.com on 28 Feb 2013 at 10:33

GoogleCodeExporter commented 9 years ago
I also just independently made the same change. It would also be awesome to 
have this packaged with setutools/distribute 

Original comment by WCDolphin@gmail.com on 16 Dec 2013 at 3:21

GoogleCodeExporter commented 9 years ago
In case you didn't notice, this was adressed in the github repo: 
https://github.com/cudamat/cudamat

Original comment by thomas.u...@gmail.com on 28 Dec 2013 at 9:01