linux下theano/tensorflow安装cuda支持gpu

  • Post author:
  • Post category:linux


本人在安装过程中碰到很多问题,一一记录下来

1.theano运行gpu,测试代码如下

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([], T.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, T.Elemwise) for x in f.maker.fgraph.toposort()]):
    print('Used the cpu')
else:
    print('Used the gpu')

最新版 的theano 运行报错,错误内容如下:


nvcc fatal   : Value ‘sm_61’ is not defined for option ‘gpu-architecture’

错误原因,sm_61需要cuda8.0的才能运行,安装cuda8.0

在安装目录运行如下命令:./cuda_8.0.27_linux.run

Do you accept the previously read EULA?
accept/decline/quit: accept

You are attempting to install on an unsupported configuration. Do you wish to continue?
(y)es/(n)o [ default is no ]: y

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 361.77?
(y)es/(n)o/(q)uit: n

Install the CUDA 8.0 Toolkit?
(y)es/(n)o/(q)uit: y

Enter Toolkit Location
 [ default is



版权声明:本文为vs412237401原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。