arrayfire / arrayfire-python

Python bindings for ArrayFire: A general purpose GPU library.
https://arrayfire.com
BSD 3-Clause "New" or "Revised" License
415 stars 65 forks source link

NumPy Array to AF Array in Windows + python2.7 #77

Closed ghost closed 8 years ago

ghost commented 8 years ago

data=np.random.random(size=(100,100)) af.np_to_af_array(data)

gets error: af.np_to_af_array(data) File "C:\Python27\lib\site-packages\arrayfire\interop.py", line 53, in np_to_af_array res = Array(in_ptr, shape, in_dtype) File "C:\Python27\lib\site-packages\arrayfire\array.py", line 428, in init raise TypeError("src is an object of unsupported class") TypeError: src is an object of unsupported class

My Environment: Python27 64 bit Windows 7 64 AF version: 3.3.2 or sys.version_info(major=2, minor=7, micro=10, releaselevel='final', serial=0) CUDA kit 7.5

More background: I just installed the package so likely a setup issue on my side... The examples work for me, both cpu & cuda.

Any ideas?

pavanky commented 8 years ago

@bscully Can you tell me how you installed arrayfire python wrapper?

ghost commented 8 years ago

pip install arrayfire

Should I try another way?

On Apr 26, 2016, at 11:57 PM, Pavan Yalamanchili notifications@github.com<mailto:notifications@github.com> wrote:

@bscullyhttps://github.com/bscully Can you tell me how you installed arrayfire python wrapper?

You are receiving this because you were mentioned. Reply to this email directly or view it on GitHubhttps://github.com/arrayfire/arrayfire-python/issues/77#issuecomment-214963886

pavanky commented 8 years ago

@bscully can you print out the output of isinstance(data.ctypes.data, int)

ghost commented 8 years ago

isinstance(data.ctypes.data, int) Out[58]: False

From: Pavan Yalamanchili [mailto:notifications@github.com] Sent: Wednesday, April 27, 2016 8:50 AM To: arrayfire/arrayfire-python arrayfire-python@noreply.github.com Cc: Ben Scully bscully@alphaparity.com; Mention mention@noreply.github.com Subject: Re: [arrayfire/arrayfire-python] NumPy Array to AF Array (#77)

@bscullyhttps://github.com/bscully can you print out the output of isinstance(data.ctypes.data, int)

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHubhttps://github.com/arrayfire/arrayfire-python/issues/77#issuecomment-215071475

pavanky commented 8 years ago

@bscully output of type(data.ctypes.data) please.

Can you also let me know if you are using a different python distribution ?

pavanky commented 8 years ago

@ZacDiggum I assume you are also on windows but are not seeing this issue?

ghost commented 8 years ago

type(data.ctypes.data) Out[61]: long

I'm running everything on windows and it's the standalone version, ie not anaconda or enthought etc

ghost commented 8 years ago

Update: The calculation examples work but not the graphics.
convolve.py full 2D convolution time: 1.67066 ms separable 2D convolution time: 1.58442 ms

intro.py (only kept the first several lines) ---- Intro to ArrayFire using signed(s32) arrays ---- ---- Sub referencing and sub assignment

ArrayFire v3.3.2 (CUDA, 64-bit Windows, build f65dd97) Platform: CUDA Toolkit 7.5, Driver: CUDA Driver Version: 7050 [0] GeForce GT 610, 2048 MB, CUDA Compute 2.1 ArrayFire v3.3.2 (CUDA, 64-bit Windows, build f65dd97) Platform: CUDA Toolkit 7.5, Driver: CUDA Driver Version: 7050 [0] GeForce GT 610, 2048 MB, CUDA Compute 2.1 A [3 3 1 1] 1 -1 4 2 2 2 4 0 3

surface.py Traceback (most recent call last): File "C:\Python27\lib\site-packages\IPython\core\interactiveshell.py", line 3066, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in runfile('C:\Users\Ben\Desktop\surface.py') File "C:\Eclipse\plugins\org.python.pydev_4.3.0.201508182223\pysrc\pydev_umd.py", line 167, in runfile execfile(filename, namespace) File "C:\Users\Ben\Desktop\surface.py", line 28, in win.surface(x, y, z) File "C:\Python27\lib\site-packages\arrayfire\graphics.py", line 240, in surface ct.pointer(_cell))) File "C:\Python27\lib\site-packages\arrayfire\util.py", line 75, in safe_call raise RuntimeError(to_str(err_str)) RuntimeError: In function cudaGraphicsResource cuda::InteropManager::getBufferResource(const fg::Surface ) In file C:/workspace/graphics-inst-src/src/backend/cuda/interopManager.cu:130 CUDA Error (63): OS call failed or operation not supported on this OS

more info: I do have a 2nd distribution with Anaconda. Switching between the 2 is easy which is why I said the standard python earlier. I started using PyCuda and could only get that to work with Anaconda.

Might be related to this error..

pavanky commented 8 years ago

looks like the original error only happens on windows + python 2.7. I will try to patch this in and make a release today.

pavanky commented 8 years ago

Fixed in master and latest release.

pavanky commented 8 years ago

@bscully This does not fix the graphics issues. If you are still having those errors, please create a new issue for it.

ghost commented 8 years ago

Uninstalled, ran pip install and now it works!! Interestingly when i tried compiling the master branch which looks to be version 3.4, it did not work. Does that make sense?

Either way, the current pip install is working great - thanks so much!

And as for the graphics error, will log another case.

pavanky commented 8 years ago

@bscully If you are using the command from the README (or use git clone), it uses develop branch not master. I patched this only in master so far. I will merge it into devel soon.

pavanky commented 8 years ago

@bscully FYI, I just merged the fixes into devel branch as well.