【问题标题】:Theano Unable to Use GPUTheano 无法使用 GPU
【发布时间】:2018-11-11 22:05:00
【问题描述】:
(theano_p27) ubuntu@ip-***-**-**-***:~$ device=cuda0,floatX=float32 GPUARRAY_CUDA_VERSION=80 python test.py
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
ERROR (theano.gpuarray): Could not initialize pygpu, support disabled
Traceback (most recent call last):
File "/home/ubuntu/anaconda3/envs/theano_p27/lib/python2.7/site-packages/theano/gpuarray/__init__.py", line 227, in <module>
use(config.device)
File "/home/ubuntu/anaconda3/envs/theano_p27/lib/python2.7/site-packages/theano/gpuarray/__init__.py", line 214, in use
init_dev(device, preallocate=preallocate)
File "/home/ubuntu/anaconda3/envs/theano_p27/lib/python2.7/site-packages/theano/gpuarray/__init__.py", line 99, in init_dev
**args)
File "pygpu/gpuarray.pyx", line 658, in pygpu.gpuarray.init
File "pygpu/gpuarray.pyx", line 587, in pygpu.gpuarray.pygpu_init
GpuArrayException: cuInit: CUDA_ERROR_UNKNOWN: unknown error
[Elemwise{exp,no_inplace}(<TensorType(float32, vector)>)]
Looping 1000 times took 2.717710 seconds
Result is [1.2317803 1.6187934 1.5227807 ... 2.2077181 2.2996776 Used the cpu

我正在尝试使用 Amazon Web Services EC2 运行 GPU,当我尝试运行测试以让我的代码运行我的 gnu 时出现此错误,但它给了我这个错误。

请帮忙

编辑:我运行的代码是来自 Theano 网站的测试代码

from theano import function, config, shared, tensor
import numpy
import time

vlen = 10 * 30 * 768  # 10 x #cores x # threads per core
iters = 1000

rng = numpy.random.RandomState(22)
x = shared(numpy.asarray(rng.rand(vlen), config.floatX))
f = function([], tensor.exp(x))
print(f.maker.fgraph.toposort())
t0 = time.time()
for i in range(iters):
    r = f()
    t1 = time.time()
print("Looping %d times took %f seconds" % (iters, t1 - t0))
print("Result is %s" % (r,))
if numpy.any([isinstance(x.op, tensor.Elemwise) and
          ('Gpu' not in type(x.op).__name__)
          for x in f.maker.fgraph.toposort()]):
    print('Used the cpu')
else:
    print('Used the gpu')

【问题讨论】:

  • 欢迎来到 SO!如果您需要帮助,您需要发布失败的代码!
  • 什么实例类型?您是否安装了 GPU 驱动程序?
  • @BrandonMiller Ubuntu 实例类型是 t2.micro,带有深度学习 AMI (Ubuntu) 版本 9.0,我认为我没有安装任何 GPU 驱动程序
  • 您是否连接了弹性 GPU 或其他东西?默认情况下,t2.micro 肯定没有 GPU。
  • @BrandonMiller 哦,我不知道,抱歉,我是 AWS 新手。谢谢

标签: python amazon-web-services gpu theano theano-cuda


【解决方案1】:

回应后续的cmets。为了在 AWS 上通过 Deep Learning AMI 配置和使用 GPU,建议使用以下实例 (source):

Amazon EC2 P3 Instances 拥有多达 8 个 NVIDIA Tesla V100 GPU。

Amazon EC2 P2 Instances 拥有多达 16 个 NVIDIA NVIDIA K80 GPU。

Amazon EC2 G3 Instances 拥有多达 4 个 NVIDIA Tesla M60 GPU。

查看EC2 Instance Types 并选择加速计算以查看 不同的 GPU 实例选项。

另外你可以试试Elastic GPUs

最后,它可以使用您通常需要从 Nvidia 站点安装适当驱动程序的 GPU 实例。查看上面引用的关于 GPU 类型的文本。下载驱动并运行;例如:

./NVIDIA-Linux-x86_64-384.81.run

您还可以传递-silent 标志以使用配置管理或其他方式安装它。此外,请记住,您必须在您打算使用的实例大小上安装驱动程序。如果您创建一个 AMI 映像,并在 p3.2xlarge 上安装了驱动程序,然后尝试在 p3.8xlarge 上运行某些东西,您可能需要重新安装驱动程序。

【讨论】:

    猜你喜欢
    • 2017-04-25
    • 2013-08-12
    • 2015-09-12
    • 2016-06-23
    • 2017-05-13
    • 2018-05-08
    • 2017-02-06
    • 1970-01-01
    • 2016-11-03
    相关资源
    最近更新 更多