Troubles with arrayfire python

97 views
Skip to first unread message

Юрий Сидоров

unread,
Sep 9, 2020, 10:10:55 AM9/9/20
to ArrayFire Users
Hi! I've got some troubles
When I launch

import arrayfire as af
af.set_backend('cuda')
ArrayFire v3.7.2 (CUDA, 64-bit Linux, build 218dd2c)
Platform: CUDA Runtime 10.0, Driver: 450.66
[0] GeForce GTX TITAN, 6083 MB, CUDA Compute 3.5

but when I try to run tests I've got error

python -m arrayfire.tests
ERROR:root:Traceback (most recent call last):
 File "/home/linuxboy/anaconda3/lib/python3.7/site-packages/arrayfire/tests/simple/_util.py", line 32, in run
   test(verbose)
 File "/home/linuxboy/anaconda3/lib/python3.7/site-packages/arrayfire/tests/simple/algorithm.py", line 20, in simple_algorithm
   af.eval(k)
 File "/home/linuxboy/anaconda3/lib/python3.7/site-packages/arrayfire/device.py", line 218, in eval
   __eval(*args)
 File "/home/linuxboy/anaconda3/lib/python3.7/site-packages/arrayfire/device.py", line 168, in __eval
   safe_call(backend.get().af_eval(args[0].arr))
 File "/home/linuxboy/anaconda3/lib/python3.7/site-packages/arrayfire/util.py", line 79, in safe_call
   raise RuntimeError(to_str(err_str))
RuntimeError: In function cuda::Module common::compileModule(const string&, const std::vector<std::basic_string<char> >&, const std::vector<std::basic_string<char> >&, const std::vector<std::b
asic_string<char> >&, bool)
In file src/backend/cuda/compile_module.cpp:

Simple            arith: FAILED
arrayfire.Array()
Type: float

I run on Kubuntu 18.04.

If i run arrayfire examples all ok!
What should I do?

Pradeep Garigipati

unread,
Sep 10, 2020, 7:25:09 AM9/10/20
to Юрий Сидоров, ArrayFire Users
Hi,

We have recently pushed some fixes to master to fix tests in the python wrapper project, but I haven't seen the error you posted during the debugging session though.

Are you using the latest master branch of arrayfire-python to run the tests ?

If examples are running fine, it could be something related to the python environment, I am not certain though. The line at which it fails is a very basic statement of creating an array of random numbers. Try copying this line to a working example and run the modified example and check what happens. Thay may help narrow down the problem further.

Regards,
Pradeep.

--
You received this message because you are subscribed to the Google Groups "ArrayFire Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arrayfire-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/arrayfire-users/b471a628-781d-4e5c-9d48-b46ada2dd88en%40googlegroups.com.


--

PercentBoat4164

unread,
Sep 28, 2020, 11:05:11 PM9/28/20
to ArrayFire Users
Hey, I am encountering a similar issue. I am running Ubuntu 20.04 using python 3.8. Here are my results of af.info() with the different backends.

af.set_backend("cpu")
ArrayFire v3.7.2 (CPU, 64-bit Linux, build 218dd2c)
[0] AMD: AMD Ryzen 5 3600 6-Core Processor

af.set_backend("cuda") or af.set_backend("opencl")
ArrayFire v3.7.2 (CUDA, 64-bit Linux, build 218dd2c)
Platform: CUDA Runtime 10.0, Driver: 450.66
[0] GeForce RTX 2060 SUPER, 7981 MB, CUDA Compute 7.5


My problem arises when I try to run this function. It is part of a program that is suggested for testing by Arrayfire.

def calc_pi_device(samples):
    # Simple, array based API
    # Generate uniformly distributed random numbers
    x = af.randu(samples)
    y = af.randu(samples)
    # Supports Just In Time Compilation
    # The following line generates a single kernel
    within_unit_circle = (x * x + y * y) < 1
    # Intuitive function names
    return 4 * af.count(within_unit_circle) / samples


The error only arises when this function is run with the cuda, or opencl backends. They are as follows:

cuda:
Traceback (most recent call last):
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/GPUtesting.py", line 19, in <module>
    print(calc_pi_device(100000000))
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/GPUtesting.py", line 14, in calc_pi_device
    return 4 * af.count(within_unit_circle) / samples
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/venv/lib/python3.8/site-packages/arrayfire/algorithm.py", line 383, in count
    return _reduce_all(a, backend.get().af_count_all)
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/venv/lib/python3.8/site-packages/arrayfire/algorithm.py", line 26, in _reduce_all
    safe_call(c_func(c_pointer(real), c_pointer(imag), a.arr))
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/venv/lib/python3.8/site-packages/arrayfire/util.py", line 79, in safe_call
    raise RuntimeError(to_str(err_str))
RuntimeError: In function cuda::Module common::compileModule(const string&, const std::vector<std::basic_string<char> >&, const std::vector<std::basic_string<char> >&, const std::vector<std::basic_string<char> >&, bool)
In file src/backend/cuda/compile_module.cpp:

opencl:
Traceback (most recent call last):
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/GPUtesting.py", line 19, in <module>
    print(calc_pi_device(100000000))
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/GPUtesting.py", line 14, in calc_pi_device
    return 4 * af.count(within_unit_circle) / samples
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/venv/lib/python3.8/site-packages/arrayfire/algorithm.py", line 383, in count
    return _reduce_all(a, backend.get().af_count_all)
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/venv/lib/python3.8/site-packages/arrayfire/algorithm.py", line 26, in _reduce_all
    safe_call(c_func(c_pointer(real), c_pointer(imag), a.arr))
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/venv/lib/python3.8/site-packages/arrayfire/util.py", line 79, in safe_call
    raise RuntimeError(to_str(err_str))
RuntimeError: In function cl::Program opencl::buildProgram(const std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >&, const std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >&)
In file src/backend/opencl/compile_module.cpp:


For a little more information here is another scenario with an error, and without an error. This section was all run with the opencl backend.

If I execute
y = af.randu(100)
af.display(y)

I get
y
[

I thought this might be due to the just in time compilation. So I had it multiply all the results by 1.
y = af.randu(100) * 1
af.display(y)

I got the following error though.
y
[Traceback (most recent call last):
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/GPUtesting.py", line 19, in <module>
    af.display(y)
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/venv/lib/python3.8/site-packages/arrayfire/array.py", line 1426, in display
    safe_call(backend.get().af_print_array_gen(name.encode('utf-8'),
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/venv/lib/python3.8/site-packages/arrayfire/util.py", line 79, in safe_call
    raise RuntimeError(to_str(err_str))
RuntimeError: In function void print(const char*, af_array, int, std::ostream&, bool) [with T = float; af_array = void*; std::ostream = std::basic_ostream<char>]
In file src/api/c/print.cpp:


If anyone has a suggestion please let me know. Thank you for your time.

Pradeep Garigipati

unread,
Sep 30, 2020, 10:34:48 PM9/30/20
to PercentBoat4164, ArrayFire Users
Please run the code with environment variables AF_PRINT_ERRORS, AF_TRACE set to 1 and all respectively, and share the full log.

You can do that by running "export AF_PRINT_ERRORS=1 && export AF_TRACE=all" from command line before running the python script.



--

PercentBoat4164

unread,
Oct 2, 2020, 1:15:39 AM10/2/20
to ArrayFire Users
I ran the following with the environment variables set as you requested

import arrayfire as af



def calc_pi_device(samples):
    # Simple, array based API
    # Generate uniformly distributed random numbers
    x = af.randu(samples)
    y = af.randu(samples)
    # Supports Just In Time Compilation
    # The following line generates a single kernel
    within_unit_circle = (x * x + y * y) < 1
    # Intuitive function names
    return 4 * af.count(within_unit_circle) / samples


af.set_backend('cuda')
print(calc_pi_device(100))

and received this as output

In function cuda::Module common::compileModule(const string&, const std::vector<std::basic_string<char> >&, const std::vector<std::basic_string<char> >&, const std::vector<std::basic_string<char> >&, bool)
In file src/backend/cuda/compile_module.cpp:
Traceback (most recent call last):
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/GPUtesting.py", line 18, in <module>
    print(calc_pi_device(100))
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/GPUtesting.py", line 14, in calc_pi_device
    return 4 * af.count(within_unit_circle) / samples
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/venv/lib/python3.8/site-packages/arrayfire/algorithm.py", line 383, in count
    return _reduce_all(a, backend.get().af_count_all)
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/venv/lib/python3.8/site-packages/arrayfire/algorithm.py", line 26, in _reduce_all
    safe_call(c_func(c_pointer(real), c_pointer(imag), a.arr))
  File "/home/thaddeus/Documents/Programming/Python/VideoStreaming/venv/lib/python3.8/site-packages/arrayfire/util.py", line 79, in safe_call
    raise RuntimeError(to_str(err_str))
RuntimeError: In function cuda::Module common::compileModule(const string&, const std::vector<std::basic_string<char> >&, const std::vector<std::basic_string<char> >&, const std::vector<std::basic_string<char> >&, bool)
In file src/backend/cuda/compile_module.cpp:

I hope this helps. Thank you for taking the time to help me out.

Pradeep Garigipati

unread,
Oct 4, 2020, 7:21:57 AM10/4/20
to PercentBoat4164, ArrayFire Users
The error message still seems minimal, not sure what that is the case. Usually, with trace and print environment variables set, it should print out a whole lot more to the console.

Let me try to reproduce this on my end. Right now, I have neither the Ryzen nor RTX card. I shall try to access a similar compute version card.

Sorry about the inconvenience.

Pradeep.



--

PercentBoat4164

unread,
Oct 4, 2020, 10:57:55 PM10/4/20
to ArrayFire Users
Alright. If there is any other information I can give don't hesitate to ask.

Thanks

Barbara F

unread,
May 21, 2021, 9:17:38 PMMay 21
to ArrayFire Users
I have similar problem Running latest AF libraries and latest python wrapper. Running on Linux, python 3.8. I have created new environment and installed only ArrayFire.
LD_LIBRARY_PATH is set to /path/to/arrayfire/lib64
running test:

python -m arrayfire.tests

Results:

Simple        algorithm: FAILED


ERROR:root:Traceback (most recent call last):

  File "/home/xxx/yyy/anaconda3/envs/aft/lib/python3.8/site-packages/arrayfire/tests/simple/_util.py", line 32, in run

    test(verbose)

  File "/home/xxx/yyy/anaconda3/envs/aft/lib/python3.8/site-packages/arrayfire/tests/simple/algorithm.py", line 20, in simple_algorithm

    af.eval(k)

  File "/home/xxx/yyy/anaconda3/envs/aft/lib/python3.8/site-packages/arrayfire/device.py", line 218, in eval

    __eval(*args)

  File "/home/xxx/yyy/anaconda3/envs/aft/lib/python3.8/site-packages/arrayfire/device.py", line 168, in __eval

    safe_call(backend.get().af_eval(args[0].arr))

  File "/home/xxx/yyy/anaconda3/envs/aft/lib/python3.8/site-packages/arrayfire/util.py", line 79, in safe_call

    raise RuntimeError(to_str(err_str))

RuntimeError: In function cl::Program opencl::buildProgram(const std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >&, const std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > >&)

In file src/backend/opencl/compile_module.cpp:


Segmentation fault (core dumped)


Reply all
Reply to author
Forward
0 new messages