arrayfire / arrayfire-python

Python bindings for ArrayFire: A general purpose GPU library.

Home Page:https://arrayfire.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: In function void print() after installation

WKrauze opened this issue · comments

I have a problem with arrayfire-python. I followed all installation instructions, including adding directories to LD_LIBRARY_PATH:
$ echo $LD_LIBRARY_PATH
/opt/arrayfire/lib64/::/opt/cuda/lib64/:/opt/cuda/nvvm/lib64/

In /etc/ld.so.conf.d/arrayfire.conf I have /opt/arrayfire/lib64

However, when I try to run helloworld.py from examples, I get:

Platform: CUDA Runtime 11.2, Driver: 455.45.01
[0] GeForce GTX 1070, 8119 MB, CUDA Compute 6.1
Create a 5-by-3 matrix of random floats on the GPU

A
[Element-wise arithmetic

Error: 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:

Process finished with exit code 0

When I am in the python console and I change backend to CPU I get:

af.info()
ArrayFire v3.8.0 (CPU, 64-bit Linux, build d99887a)
[0] Intel: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz

when I change back to CUDA I get:

af.info()
ArrayFire v3.8.0 (CUDA, 64-bit Linux, build d99887a)
Platform: CUDA Runtime 11.2, Driver: 455.45.01
[0] GeForce GTX 1070, 8119 MB, CUDA Compute 6.1

So for me it looks like arrayfire correctly recognizes CPU and CUDA.
I found similar problem here: https://groups.google.com/g/arrayfire-users/c/_524PBvEvGw?pli=1 however it was not solved.
Also. when I try to run another code for which I installed arrayfire, I get this error:

File "/home/wojtek/anaconda3/envs/multi-layer-born/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:

Process finished with exit code 1

which, as I believe, is related with the same issue.
Additional info:
I am using Anaconda, Python 3.8.5
Linux Manjaro 20.2.1

i have the same problem

The solution to this problem can be found on Slack channel.
To cite:

I think its the order in which the libraries are loaded. Python 3 and some of the wheels use a standard library that conflicts with ArrayFire's standard library sometimes.

And the solution: write in terminal:
LD_PRELOAD=<full_path_to_libafcuda> python your_python.py

For example:

LD_PRELOAD=/opt/arrayfire/lib64/libafcuda.so python3 helloworld.py

If you want to add this environment variable in PyCharm, follow the instructions given here.
For me this solves the problem.