andersbll / cudarray

CUDA-based NumPy
MIT License
234 stars 61 forks source link

ImportError: libcudarray.so: cannot open shared object file #10

Closed wielandbrendel closed 9 years ago

wielandbrendel commented 9 years ago

Hi, first of all: amazing work you are doing with cudarray! I like the concept quite a lot. The installation runs smoothly (after updating Cython), except that I can't use the CUDA backend. Every time I try, I get the following error message,

ImportError                               Traceback (most recent call last)
<ipython-input-4-342f252c3bce> in <module>()
----> 1 import cudarray as ca
      2 a = ca.random.uniform(size=(100, 10))
      3 for _ in range(1000):
      4     ca.softmax(a)

/usr/local/lib/python2.7/dist-packages/cudarray-0.1-py2.7-linux-x86_64.egg/cudarray/__init__.py in <module>()
     28         try:
     29             from .base import *
---> 30             from .cudarray import *
     31             from .linalg import *
     32             from .elementwise import *

/usr/local/lib/python2.7/dist-packages/cudarray-0.1-py2.7-linux-x86_64.egg/cudarray/cudarray.py in <module>()
      1 import numpy as np
      2 from .wrap.array_data import ArrayData
----> 3 from . import elementwise
      4 from . import base
      5 from . import helpers

/usr/local/lib/python2.7/dist-packages/cudarray-0.1-py2.7-linux-x86_64.egg/cudarray/elementwise.py in <module>()
      1 import numpy as np
      2 import cudarray
----> 3 from .wrap import elementwise
      4 from . import helpers
      5 

ImportError: libcudarray.so: cannot open shared object file: No such file or directory

The file exists at /usr/local/lib but adding it to the standard search paths didn't help. Any ideas?

And while we are at it, just a short question on cudarray: all operations are done on the GPU, so there is no back-and-forth copy between host and device, right?

Thanks a lot in advance! Wieland

wielandbrendel commented 9 years ago

Alright, I solved it myself. The solution was to set the LD_LIBRARY_PATH to /usr/local/lib. I had done this before posting, however I missed to completely restart ipython (instead of just the ipython kernel).

For those interested, here is a short excerpt from a Dockerfile to install cudarray:

ENV INSTALL_PREFIX /usr/local
ENV CUDA_PREFIX /usr/local/cuda-6.5
ENV CUDNN_ENABLED 0
ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH

# upgrade cython to latest version
RUN pip2.7 install --upgrade cython

RUN cd /opt/ && \
    git clone --recursive https://github.com/andersbll/cudarray.git

RUN cd /opt/cudarray && \
    make && \
    make install && \
    python2 setup.py install
andersbll commented 9 years ago

Hi Wieland,

I'm very sorry about the late reply. Due to a concussion I've been unable to use a computer.

I'm glad you managed to compile CUDArray. AFAIK, on Debian/Ubuntu it is not necessary to set LD_LIBRARY_PATH when installing to the INSTALL_PREFIX you have specified. I'm not sure if the problem is caused by wrong assumptions of CUDArray or by a lacking Docker environment setup. I might look into this when I get better.

Thank you for the detailed solution to the problem! Anders

Closed #10 https://github.com/andersbll/cudarray/issues/10.

— Reply to this email directly or view it on GitHub https://github.com/andersbll/cudarray/issues/10#event-235436847.