pycuda._driver.LogicError: cuModuleLoadDataEx failed: device kernel image is invalid - pycuda

I want to run simple code in pycuda
import numpy as np
import pycuda.driver as cuda
import pycuda.autoinit
from pycuda.compiler import SourceModule
mod = SourceModule("""
__global__ void doublify(float *a)
{
int idx = threadIdx.x + threadIdx.y*4;
a[idx] *= 2;
}
""",arch='sm_61')
I have chosen arch='sm_61' because if I remove it this error appears:
nvcc fatal : Value 'sm_86' is not defined for option
'gpu-architecture'
I have cuda 10.1 and cuda 11.2 and the default nvcc version is V10.1.
I don't want to remove any of them. (someone suggested this as a solution)
now I get this error:
pycuda._driver.LogicError: cuModuleLoadDataEx failed: device kernel
image is invalid -
how can I solve this issue?
The OS is windows 10.
pycuda 2022.2
Python 3.7.4
nvcc version: V10.1.105
I will change the pycuda version or python version if needed.

Related

Raspberry pi kernel module disagrees about version of symbol layout, although complied against running kernel

I created the simplest external kernel module for my Raspberry PI as a test:
#include <linux/module.h>
#include <linux/kernel.h>
int hello_init(void) {
printk("Hello World");
return 0;
}
void hello_exit(void) {
printk("Goodbye World!");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
I complied it successfully with the following line:
sudo make -C /lib/modules/$(uname -r)/build M=$PWD modules
I tried to use sudo insmod hello.ko, and got the following error:
insmod: ERROR: could not insert module hello.ko: Invalid module format
And following this error in dmesg:
hello: disagrees about version of symbol module_layout
I've read everything there is to read about this error online. All the research has yielded the assumption that this is caused by compiling the module against a kernel which differs from the running kernel in either version or configuration.
However, this is absolutely not my case. The running kernel was loaded by the distribution and was not changed by me (Raspberry PI 3). Moreover, inspection of the kernel's other modules and hello.ko (using modinfo) is yielding the exact same vermagic and flags, which are:
vermagic: 5.15.33-v8+ SMP preempt mod_unload modversions aarch64
Since all online material originates this fault in version difference, I'm at a lost.

Python import pdfplumber error " ModuleNotFoundError: No module named 'chardet' "

I encountered an error while importing pdfplumber in Python3, indicating module chardet is missing. However, running pip list from the cmd confirms that the package is installed, version 3.0.4. Anyone had similar experience? Any resolution?
Error Message:
~\AppData\Roaming\Python\Python37\site-packages\pdfminer\utils.py in <module>
3 """
4 import struct
----> 5 import chardet # For str encoding detection
6
7 # from sys import maxint as INF doesn't work anymore under Python3, but PDF
ModuleNotFoundError: No module named 'chardet'
Error: No module named chardet

I have pytorch installed in a environment but import torch produces an error

I have anaconda python3 kernel with pytorch and numpy installed in the environment. In jupyter notebook first line 'import torch' produces error.
I am using anaconda navigator to launch jupyter notebook and enter my environment and see pytorch is installed but not being imported. Tried various dir extensions 'from torch... import * but more error
import torch
ImportError Traceback (most recent call last)
<ipython-input-1-20507c95d9af> in <module>
1
----> 2 import torch
3
4
~/anaconda3/envs/udacity1/lib/python3.6/site-packages/torch/__init__.py in <module>
100 pass
101
--> 102 from torch._C import *
103
104 __all__ += [name for name in dir(_C)
ImportError: /home/frida/anaconda3/envs/udacity1/lib/python3.6/site-packages/torch/lib/libtorch.so.1: undefined symbol: nvrtcGetProgramLogSize
I was able to add this to the end of my path to establish a 'backend ' for my notebook kernel. Thanks to Kris Stern!
-m ipykernel install --user
first get your kernel path with
(which python3)
then connect it using
sudo (your path)/anaconda3/bin/python3 -m ipykernel install --user

Ipython notebook: in computing SIFT freatures using Python-Opencv: The kernel appears to have died/ in Python:Segmentation fault (core dumped)

Hi trying to execute the following simple program to detect SIFT features of an image in Ipython notebook, but everytime receiving an error message appears. I googled it, but couldn't find any solutions so far.
import cv2
import numpy as np
import itertools
Load Images:
img = cv2.imread("galaxy.png")
Find Keypoints:
detector = cv2.FeatureDetector_create("SIFT")
descriptor = cv2.DescriptorExtractor_create("SIFT")
skp = detector.detect(img) # in this line kernel dies!!
the kernel appears to have died
skp, sd = descriptor.compute(img, skp)
tkp = detector.detect(template)
tkp, td = descriptor.compute(template, tkp)
my system is Ubuntu 14.04 lts, ipython 3.2.0, python 2.7.
more over I tried it in python and got this error message:
Segmentation fault (core dumped)
I found a way around, but not a good way. I moved that notebook to another folder which it was the only file in that folder, ran it again and got no error. the bad side is that I need this notebook to be in a specific folder! Really Strange problem. any idea how to solve this problem in a better way!

Getting started with SciPy and first example doesn't run

Environment is Ubuntu 12.x LTS 64 bit. I ran the install as follows :
sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose
Everything installed great, and I tried out the 'getting started' example only to come upon this error as if my env. is't set correctly..
See orig # http://www.scipy.org/getting-started.html
usernamep#ubuntudev:~$ ipython --pylab
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
Type "copyright", "credits" or "license" for more information.
IPython 0.12.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
Welcome to pylab, a matplotlib-based Python environment [backend: TkAgg].
For more information, type 'help(pylab)'.
In [1]: from scipy import special, optimize
In [2]: f = lambda x: -special.jv(3,x)
In [3]: sol = optimize.minimize(f, 1.0)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/home/user/<ipython-input-3-ea43eb308d3c> in <module>()
----> 1 sol = optimize.minimize(f, 1.0)
AttributeError: 'module' object has no attribute 'minimize'
In [4]:
Do I need to reform their example's import? Checking their docs now...
optimize.minimize was introduced in Scipy v.0.11 (see http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html ).
On Debian, that would mean that you need Jessie or better. On Ubuntu, you appear to need raring or better.
Almost certainly the scipy you installed using apt-get is simply too old to have minimize: (0.10, I'd guess). The code works for me:
>>> from scipy import special, optimize
>>> def f(x): return -special.jv(3,x)
>>> sol = optimize.minimize(f, 1.0)
>>> sol
status: 0
success: True
njev: 17
nfev: 51
hess_inv: array([[ 4.70024446]])
fun: -0.43439442684052476
x: array([ 4.20118891])
message: 'Optimization terminated successfully.'
jac: array([ -3.72529030e-09])
I think you'll be better off using pip to install the stack.
python-scipy package in the Ubuntu 12 is a bit old. I think it is ver 0.9.0. The optimize.minimize function was added to scipy ver 0.11.0.