I am trying to use skcuda in my python code but whenever i want to use it, it rises the following exception:
Traceback (most recent call last):
File "/home/rohola/Projects/Python/wordnetwork/s.py", line 6, in <module>
from skcuda import cusolver
File "/home/rohola/anaconda3/lib/python3.4/site- packages/skcuda/cusolver.py", line 51, in <module>
raise OSError('cusolver library not found')
OSError: cusolver library not found
i was just tried to use skcuda
from skcuda import cusolver
handle = cusolver.cusolverDnCreate()
i installed pycuda, NVIDIA CUDA Toolkit. What's wrong about my code or dependencies?
import ctypes
a = ctypes.cdll.LoadLibrary( "/usr/local/cuda-8.0/targets/x86_64-linux/lib/libcusolver.so" )
gets me
OSError: /usr/local/cuda-8.0/targets/x86_64-linux/lib/libcusolver.so: undefined symbol: GOMP_critical_end
which seems to be a yet unsolved issue according to this github thread
Though, a 7.5 version which
/usr/lib/x86_64-linux-gnu/libcusolver.so
seems to point to works well. And author's fix seems to work with it.
I finally found a solution to my problem. Firstly, i searched for libcusolver.so with
locate libcusolver.so
and then changed the following code in cusolver.py from:
_libcusolver = ctypes.cdll.LoadLibrary(_libcusolver_libname)
to:
_libcusolver = ctypes.cdll.LoadLibrary("/usr/local/cuda-7.5/targets/x86_64-linux/lib/"+_libcusolver_libname)
now the following code:
from skcuda import cusolver
handle = cusolver.cusolverDnCreate()
works without any error.
UPDATE:
If you have installed cuda8.0 or 9.0 the best way to solve the problem is to find this line in cusolver.py:
_libcusolver = ctypes.cdll.LoadLibrary(_libcusolver_libname)
and add this line before it:
ctypes.CDLL('libgomp.so.1', mode=ctypes.RTLD_GLOBAL)
You have to make sure that you already installed libgomp.
Related
I'm trying to make a GPU usage monitor, but I have an AMD GPU, so I had to use the pyadl library instead of some better for NVIDIA.
this is my code:
from pyadl import *
device = ADLManager.getInstance().getDevices()[0]
print(device.getCurrentUsage())
and this is the error:
Traceback (most recent call last):
File "c:\Users\MSI_user\Documents\dev\Arduino\projects\pyArduino\passData-9.py", line 3, in <module>
print(device.getCurrentUsage())
File "C:\Users\MSI_user\Documents\dev\Arduino\projects\pyArduino\pyArd\lib\site-packages\pyadl\pyadl.py", line 293, in getCurrentUsage
return ADLManager.getInstance().getCurrentUsage(self)
File "C:\Users\MSI_user\Documents\dev\Arduino\projects\pyArduino\pyArd\lib\site-packages\pyadl\pyadl.py", line 182, in getCurrentUsage
raise ADLError("Failed to get CurrentUsage")
pyadl.pyadl.ADLError: Failed to get CurrentUsage
I have researched quite a bit, but I don't have any idea how to fix it. Here is also the github link for the python lib - pyadl
Maybe this lib is too old, but I haven't found any better for AMD GPUs. If you know any, please recommend.
Please help :D
I have a simple graph and need to draw it on my screen, here is my code:
def gera_grafo(matriz):
grafo = nx.to_networkx_graph(matriz, create_using=nx.Graph)
nx.draw(grafo)
plt.show()
return grafo
Where matrix is an adjacency list containing the weights of the connections. The coda was working just fine, but i had to create a new python virtualenv and since then, even though all the required libraries are correctly installed it throws an error on the nx.draw() call. The error I got is:
Traceback (most recent call last):
File "/run/media/luisola/A216C03316C009ED/Users/Luis/Documents/Iniciação Científica/inicia-o-cient-fica/venv/lib/python3.9/site-packages/networkx/utils/decorators.py", line 396, in _random_state
random_state_arg = args[random_state_index]
IndexError: tuple index out of range
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/run/media/luisola/A216C03316C009ED/Users/Luis/Documents/Iniciação Científica/inicia-o-cient-fica/criacao_do_grafo.py", line 58, in <module>
grafo = gera_grafo(matriz)
File "/run/media/luisola/A216C03316C009ED/Users/Luis/Documents/Iniciação Científica/inicia-o-cient-fica/criacao_do_grafo.py", line 39, in gera_grafo
nx.draw(grafo)
File "/run/media/luisola/A216C03316C009ED/Users/Luis/Documents/Iniciação Científica/inicia-o-cient-fica/venv/lib/python3.9/site-packages/networkx/drawing/nx_pylab.py", line 123, in draw
draw_networkx(G, pos=pos, ax=ax, **kwds)
File "/run/media/luisola/A216C03316C009ED/Users/Luis/Documents/Iniciação Científica/inicia-o-cient-fica/venv/lib/python3.9/site-packages/networkx/drawing/nx_pylab.py", line 333, in draw_networkx
pos = nx.drawing.spring_layout(G) # default to spring layout
File "/run/media/luisola/A216C03316C009ED/Users/Luis/Documents/Iniciação Científica/inicia-o-cient-fica/venv/lib/python3.9/site-packages/decorator.py", line 214, in fun
return caller(func, *(extras + args), **kw)
File "/run/media/luisola/A216C03316C009ED/Users/Luis/Documents/Iniciação Científica/inicia-o-cient-fica/venv/lib/python3.9/site-packages/networkx/utils/decorators.py", line 400, in _random_state
raise nx.NetworkXError("random_state_index is incorrect") from e
networkx.exception.NetworkXError: random_state_index is incorrect
Is this an error on my code? If so, what can i do? Thanks in advance
As stated for this question: networkx shows random_state_index is incorrect
Their was a problem with decorator=5.0.0. As discussed in the related issue on GitHub (https://github.com/networkx/networkx/issues/4718) decorator>=5.0.X should be available soon. So either wait a little bit to upgrade or downgrade to an old version as suggested in the SO question above.
Edit decorator==5.0.5 or >=5.0.7 fixes the error
As discussed in the issue linked above, decorator has now been updated and fixed.
I was using decorator==5.0.6, and got the same error.
However, upgrading to 5.0.7 solves my problem.
If you are using MacOS - BigSur, networkx won't work the way you want it to. I needed to go and open my project in Ubuntu.
Its worked for me, after downgrade the networkx and decorator
networkx 2.3 pypi_0 pypi
decorator 4.3.0 pypi_0 pypi
OS: Mac OS BigSur
Since I am using Windows 10, the suggestion given by Sparky05 worked for me by updating the version of decorator module in python by using pip install decorator==5.0.7.
Also you can update the version of networkx library. I will share the link for updating it later, but it will not work if you are using Spyder IDE. It will work in VSCode.
I write below code and it gives me error in first line! whats wrong is with this code:
import volatility.conf as conf
import volatility.registry as reg
import volatility.commands as commands
import volatility.addrspace as addrspace
import volatility.plugins.taskmods as taskmode
# configure volatility
reg.PluginImporter()
config=conf.ConfObject()
reg.register_global_options(conf,commands.Command)
reg.register_global_options(conf,addrspace.BaseAddressSpace)
config.parse_options()
config.PROFILE="Linuxfedora32x64"
config.LOCATION="./dumps/mem.lime"
p=taskmode.PSList(config)
for process in p.calculate:
print(process)
the error code:i think there is some code insode conf.py witch in not support in python 3.6 .but volatility is copatible with python 3.6. so i don't know what to do :
Traceback (most recent call last):
File "../PycharmProjects/volpractive/test.py", line 6, in <module>
import volatility.conf as conf
File "/anaconda3/lib/python3.6/site-packages/volatility-2.6-py3.6.egg/volatility/conf.py", line 84
except (optparse.BadOptionError, optparse.OptionValueError), err:
You were right, the line:
except (optparse.BadOptionError, optparse.OptionValueError), err:
is not Python3 compatible (according to [Python]: The try statement).
According to [GitHub]: volatilityfoundation/volatility - (2.6) volatility/README.txt:126+ (as it is at this point):
Requirements
============
- Python 2.6 or later, but not 3.0. http://www.python.org
Note:
The stacktrace is still incomplete (missing the last line - should be SyntaxError); that would have cleared things up much sooner
So, you have to run it with Python2.6+ (of course you could also modify the code (at least the part that you need) to be Python3 compatible, but I doubt that's feasible).
Keeping it relatively simple. I'm trying to open a fileopenbox to select a file using easygui.
easygui.fileopenbox()
And easyGUI throws this error
'module' object has no attribute 'askopenfilename'
The Stack Trace
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\test.py", line 377, in <module>
easygui.fileopenbox()
File "C:\Python27\lib\site-packages\easygui\boxes\fileopen_box.py", line 103, in fileopenbox
func = ut.tk_FileDialog.askopenfilenames if multiple else ut.tk_FileDialog.askopenfilename
AttributeError: 'module' object has no attribute 'askopenfilename'
Whats going on here?
Nothings changed on my system at all, but it almost looks like for some reason python cant find this tkInter function.
Has anyone come across this?
Thanks!
Edit: An additional screenshot showing that the method is not found
https://gyazo.com/8b9ba0f6c23561d13babe7ce4c8b67a1
Try uninstalling your Easygui and install latest one.
Also try update Python version.
I've been trying to build pHash(http://phash.org/) on my windows machine and haven't been having any luck. I'm new to programming desktop applications. I will be using the pHash library with Python through ctypes. Could someone post the steps involved with building pHash?
What I tried, was opening pHash.sln with Visual Studio 2008 and chooing the Release(as opposed to debug) and building pHash. I wasn't sure where it was building to as I couldn't find the file. I tried looking in Visual Studio's projects folder but it wasn't there so I assumed it was building to pHash/release/pHash.dll, but when I load that dll with ctypes.cdll none of the functions listed in the pHash docs(http://phash.org/docs/howto.html) seem to be accessible, e.g. ph_dct_imagehash(), ph_dct_videohash.
Here is an example of my code:
import ctypes
import inspect
PHASHPATH = "C:\Users\me\Downloads\phash\release\pHash.dll"
phash_dll = ctypes.CDLL(PHASHPATH)
phash_dll['ph_dct_imagehash']
The response I get is:
Traceback (most recent call last):
File "C:\Users\me\workspace\project\src\opencv.py", line 12, in <module>
phash_dll['ph_dct_imagehash']
File "C:\Program Files (x86)\Python27\lib\ctypes\__init__.py", line 371, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'ph_dct_imagehash' not found
I'm new at this, so please bear with me. Thanks.
EDIT:
I'm running Python 2.7.
Except for some dirent functions, no pHash functions are exported from pHash.dll. That can be verified with DependencyWalker http://www.dependencywalker.com/. Try adding __declspec(dllexport) in front of the function declarations in pHash.h (e.g. for ph_dct_imagehash) and recompile.