gpt4 book ai didi

python - 使用 cuda 7.0 在 ubuntu 14.04 中安装 pycuda

转载 作者:太空宇宙 更新时间:2023-11-04 05:41:04 25 4
gpt4 key购买 nike

我正在尝试使用 cuda 7.0 安装 pycuda 没问题并且运行代码很好但是在使用 Installing PyCUDA on Ubuntu Linux 安装 pycuda 之后我无法安装和运行 pycuda尝试使用 pycuda 运行简单代码 简单代码是

import pycuda.driver as cuda
import pycuda.autoinit
from pycuda.compiler import SourceModule
import numpy

mod = SourceModule("""
___global___ void doublify(float *a)
{
int idx= threadIdx.x + threadIdx.y*4;
a[idx] *= 2;
}
""")
a = numpy.random.randn(4,4)
a = a.astype(numpy.float32)
a_gpu = cuda.mem_alloc(a.nbytes)
cuda.memcpy_htod(a_gpu,a)

func = mod.get_function("doublify")
func(a_gpu, block=(4,4,1))

a_doubled = numpy.empty_like(a)
cuda.memcpy_dtoh(a_doubled, a_gpu)
print a_doubled
print a

但是代码没有运行并显示这个错误

Traceback (most recent call last):
File "/home/pupuol/Documents/educuda.py", line 3, in <module>
import pycuda . autoinit
File "/usr/local/lib/python2.7/dist-packages/pycuda-2015.1.3-py2.7- linux-x86_64.egg/pycuda/autoinit.py", line 2, in <module>
import pycuda.driver as cuda
File "/usr/local/lib/python2.7/dist-packages/pycuda-2015.1.3-py2.7- linux-x86_64.egg/pycuda/driver.py", line 5, in <module>
from pycuda._driver import * # noqa
ImportError: libcurand.so.7.0: cannot open shared object file: No such file or directory

请帮帮我

最佳答案

这似乎是一个库路径问题。在运行 python 之前尝试这个。

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
# or somewhere else your cuda library is located

关于python - 使用 cuda 7.0 在 ubuntu 14.04 中安装 pycuda,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33882755/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com